In this article we will be seeing how to convert .docx document to pdf document in SharePoint 2010.Word Automation Services is a new feature available in SharePoint 2010. It supports converting Word documents to other formats. Here we are going to convert the word document into pdf document. In the API for Word Automation Services there are different ways to convert documents including AddFile(), AddFolder() and AddLibrary() methods. Here we will be using AddLibrary() method to convert the word document. You need to specify two list inputList (where the word documents are present) and the outputList (where the converted pdf files should be created).This article describes the following steps to show how to call the Word Automation Services to convert a document:
namespace Test{ static class Program { static void Main(string[] args) { using (SPSite spSite = new SPSite( "http://servername:4040/")) { using(SPWeb web=spSite.OpenWeb()) { SPList inputList=web.Lists["Shared Documents"]; SPList outputList=web.Lists["PDF Library"]; //Defines a collection of settings for all conversions within a single conversion job. ConversionJobSettings jobSettings=new ConversionJobSettings(); jobSettings.OutputFormat = SaveFormat.PDF; //Represents a collection of file conversions (of single files or entire libraries) that share a common set of conversion properties and are logically tracked as a single unit. ConversionJob pdfConversion = new ConversionJob("Word Automation Services", jobSettings); // Set the credentials to use when running the conversion job. pdfConversion.UserToken = spSite.UserToken; pdfConversion.AddLibrary(inputList,outputList); pdfConversion.Start(); } } } }}
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: