0

我正在开发 SharePoint 2010 事件接收器。我在特定列表上运行此事件接收器,并且在某些条件下,我在库中创建 word 文档的副本并使用动态值编辑其属性,然后使用 word 自动化服务将此文档转换为同一库中的 PDF。

我的 word 文档已正确创建,并在 word 文档中插入了所需的文档属性。代码正确执行,但文档未转换为 PDF。

下面是转换代码:

using (SPSite spSite = new SPSite("http://MySharePoint Site"))
            {

                SPServiceContext serviceContext = SPServiceContext.GetContext(spSite.WebApplication.ServiceApplicationProxyGroup, SPSiteSubscriptionIdentifier.Default);

                var wordAutomationProxy = (WordServiceApplicationProxy)serviceContext.GetDefaultProxy(typeof(WordServiceApplicationProxy));

                //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(wordAutomationProxy, jobSettings);
              // Set the credentials to use when running the conversion job.
                pdfConversion.UserToken = spSite.UserToken;                    
                pdfConversion.AddFile(DocFilePath, PDFFilePath);
                pdfConversion.Start();

}
4

1 回答 1

0

我重新创建了自动化服务这个词,这解决了我的问题。没有代码更改。

于 2017-10-06T06:13:29.090 回答