【发布时间】:2018-03-11 00:47:48
【问题描述】:
我正在开发 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();
}
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: c# ms-word sharepoint-2010 pdf-generation eventreceiver