C# .NET Core 使用 LibreOffice 将 Word 转换为 PDF
C# .NET Core 使用 LibreOffice 将 Word 转换为 PDF
本文将介绍如何在 .NET Core 中使用 LibreOffice 将 Word 文档转换为 PDF 格式。
安装 LibreOffice
- 下载 LibreOffice 安装包,可以从官网 https://www.libreoffice.org/ 下载。
- 安装 LibreOffice,按照安装向导提示进行安装即可。
在 .NET Core 中使用 LibreOffice
- 安装 NuGet 包: Novell.LibreOffice
- 引入命名空间: using Novell.LibreOffice.Convert;
- 代码示例:
var document = new Document('inputPath');
document.ConvertToPdf('outputPath');
其中 'inputPath' 是 Word 文件路径,'outputPath' 是 PDF 文件路径。
注意:
- 确保安装了 LibreOffice,并且已配置环境变量。
- 使用前请先确保 Novell.LibreOffice NuGet 包已成功安装。
原文地址: https://www.cveoy.top/t/topic/opgy 著作权归作者所有。请勿转载和采集!