word自动保存为pdf

时间:2012-05-15 09:25:11

标签: pdf converter doc word-automation

在MS Word 2010中将文档另存为pdf时,我们会获得其他选项,例如“optimize for”。这些选项不能设置为c#中Document.Saveas函数的参数。请告诉我如何在保存pdf之前设置这些选项。

Document doc = word.Documents.Open(ref filename, ref oFalse, ref oTrue, ref oFalse, "?#nonsense@$", "?#nonsense@$", ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oFalse, ref oFalse, WdDocumentDirection.wdLeftToRight, ref oTrue);
doc.Activate();
object outputFileName = wordFile.FullName.Replace(".docx", ".pdf");
object fileFormat = WdSaveFormat.wdFormatPDF;
// Save document into PDF Format
doc.SaveAs(ref outputFileName, ref fileFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oFalse);

1 个答案:

答案 0 :(得分:2)

Document.ExportAsFixedFormat中的OptimizeFor参数将满足您的需求