【发布时间】:2021-08-25 01:46:23
【问题描述】:
我有一个简单的网络 API
- 克隆 .docx 文件
- 将克隆的 .docx 转换为 .pdf 格式
using DocumentFormat.OpenXml.Packaging;
[HttpPost("clone")]
public IActionResult CloneBillFromTemplate()
{
var templateFilePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Bill", "PaymentTempl.docx");
var clonedFilePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Bill", "ClonedBill.docx");
var pdfFilePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Bill", "FinalBill.pdf");
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(templateFilePath, true))
{
var clonedDoc = wordDoc.Clone(clonedFilePath);
System.Threading.Thread.Sleep(500);
clonedDoc.Save();
clonedDoc.Close();
}
using (var converter = new OfficeConverter.Converter())
{
converter.Convert(clonedFilePath, pdfFilePath);
}
return Ok();
}
在调试(肯定:3)和 IIS 时一切正常
但是当我部署到 Azure 应用服务时,我得到了这种类型的错误(堆栈跟踪 + 异常消息)。
无法读取注册表以检查 Word 版本
找不到注册表项 Word.Application\CurVer 在 OfficeConverter.Word..ctor() 在 OfficeConverter.Converter.get_Word() 在 OfficeConverter.Converter.Convert(String inputFile, String outputFile, Stream logStream) at ....
你们能帮我解决这个问题吗?谢谢大家!!!
**随时询问您需要检测此问题的更多信息
更新 看起来这是我正在使用的 pdf 转换器包的问题,而不是 OpenXML
【问题讨论】:
-
你能粘贴整个堆栈跟踪消息吗
-
@Sajeetharan 嗨,刚刚更新了包含堆栈跟踪的问题
-
好吧,我认为这个问题不是在打开的 xml 上,而是在我用来转换为 pdf 文件的其他 pacakge 上
标签: c# azure azure-web-app-service openxml