In SharePoint 2010, you can add "Word Automation Services" from Central Admin as shown below
Once the service is in place, we can easily convert Word documents to PDF as shown in below snippet
private voidConvertDocFileToPDF(SPFile filex)
{
ConversionJobSettings settings = newConversionJobSettings();
settings.OutputFormat = SaveFormat.PDF;
ConversionJob job = newConversionJob(ConfigurationHelper.Instance.DocumentConversionService, settings);
job.UserToken = SPUserToken.SystemAccount;
stringpdfFile = filex.Url.Replace("docx", "pdf");
job.AddFile("http://<your site URL>/"+ filex.Url, "http://<your site URL>/"+ pdfFile);
job.Start();
}
Ensure to add reference to “Microsoft.Office.Word.Server” present under 14 hive “ISAPI” folder.
To test this, run “Word Automation Services Timer Job”
1 comment:
It throws an error
The name 'ConfigurationHelper' does not exist in the current context
Post a Comment