保存的Word docx文件为PDF [英] Saving Word DOCX files as PDF
问题描述
我使用OPENXML创建的Word docx文件。我想一旦被创建为PDF文件来保存这些文件。有没有一种方法可以让我在OPENXML做到这一点?我认为答案是否定的。如果没有,有没有推荐的库或工具,我可以用它来/打印docx文件保存为PDF格式(编程,在.NET)?我看着sharpPDF(PDFSharp),而且似乎这个库只是从头开始生成PDF,不节能的docx为PDF。
I'm using openxml to create Word DOCX files. I'd like to save these documents once they are created as PDF files. Is there a way I can do this in openxml? I assume the answer is no. If it is no, is there a recommended library or tool I can use to save / print DOCX files as PDF (programatically, in .NET)? I looked at sharpPDF (PDFSharp), and it seems this library is only for generating PDFs from scratch, not saving DOCX as PDF.
我可以以某种方式打印到已安装的PDF打印机,无论是可爱的PDF或内置到Windows 7在一个完全自动化的方式将PDF打印机?
Can I somehow Print to an installed PDF printer, either Cute PDF or the PDF printer built in to Windows 7 in a fully automated fashion?
更新:寻找自由与非病毒牌照,而preferably不需要额外安装
Update: Looking for free with non-viral license, and preferably doesn't require additional installations.
推荐答案
您可以使用Word的自动化做到这一点。你需要有安装的话。
You could do this with Word automation. You need to have word installed.
var TheDocument = TheWordApp.Documents.Open(docName);
TheDocument.ExportAsFixedFormat(
docName.Replace(".docx", ".pdf"),
Word.WdExportFormat.wdExportFormatPDF,
OptimizeFor: Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen,
BitmapMissingFonts: true, DocStructureTags: false);
((Word._Document)TheDocument).Close();
这篇关于保存的Word docx文件为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!