<分区>
您好,我正在尝试在 C# 控制台应用程序中将 DOCX 转换为 PDF。
我在 stack overflow 中发现了类似的问题,但没有得到正确的答案意味着无法继续这些方法。
string strFolderPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString();
strFolderPath = "E:\\Test\\TestDocument\\TemplateFiller\\";
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document doc = word.Documents.Open(@strFileFullPath);
string strPDFFilePath = strFolderPath + "AcknowledgementLetter.pdf";
doc.Activate();
doc.SaveAs2(@strPDFFilePath, WdSaveFormat.wdFormatPDF);
doc.Close();
- 此代码在本地运行,因为安装了 ms office,但在 服务器抛出异常,因为它需要 MS Office 安装。
- iTextSharp 没有将 Docx 转换为 pdf 格式。
- 已安装 PDF/XPS exporter,但如何提供引用 能够得到。
任何机构都可以提供样本将 DOCX 转换为 PDF 而无需/有许可证(更便宜)。以及通常我们将如何实现此功能。请回复。