Articles about European Sharepoint Hosting Service
European SharePoint Server 2010 Hosting :: Using Word Automation Services in SharePoint 2010
The Word Automation Service is a shared service application that will convert word documents (doc & docx formats) to PDF, RTF, DOCX formats. The conversion job runs asynchronously using the SharePoint timer. The process can be configured through central administration at Application Management\Managed Service Applications\Word Automation Services, to do more or less work depending on load your servers are under.
What’s nice is that the conversion jobs can be initiated through code very easily. The following example will create a job to convert all word documents in “Shared Documents” to PDFs. Note for this to work add a reference to Microsoft.Office.Word.Server (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Word.Server.dll):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
static void Main(string[] args) { using (var site = new SPSite("http://athena")) { SPList listToConvert = site.RootWeb.Lists["Shared Documents"]; ConversionJob job = new ConversionJob("Word Automation Services"); job.UserToken = site.UserToken; job.Settings.UpdateFields = true; job.Settings.OutputFormat = SaveFormat.PDF; job.Settings.OutputSaveBehavior = SaveBehavior.AlwaysOverwrite; job.AddLibrary(listToConvert, listToConvert); job.Start(); } } |
This code can be used to do a document library wide conversion, or to target individual documents for conversion, say for example an event receiver that automatically generates a read-only version of a document when it is uploaded to a library.
Hope this helps.
Print article | This entry was posted by Derek Bierhoff on August 18, 2011 at 4:04 am, and is filed under European Sharepoint Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |