gpt4 book ai didi

c# - 如何在服务器上未安装 MS Office 的情况下在 C# 控制台应用程序中将 Docx 转换为 PDF

转载 作者:行者123 更新时间:2023-11-30 18:23:00 25 4
gpt4 key购买 nike

<分区>

您好,我正在尝试在 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();
  1. 此代码在本地运行,因为安装了 ms office,但在服务器抛出异常,因为它需要 MS Office安装。
  2. iTextSharp 没有将 Docx 转换为 pdf 格式。
  3. 已安装 PDF/XPS exporter,但如何提供引用能够得到。

任何机构都可以提供样本将 DOCX 转换为 PDF 而无需/有许可证(更便宜)。以及通常我们将如何实现此功能。请回复。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com