使用aspose将word转pdf中设置字体为Linux字体
时间: 2024-04-15 14:29:43
浏览: 808
要在使用 Aspose 将 Word 转换为 PDF 时设置字体为 Linux 字体,您可以按照以下步骤进行操作:
1. 确保您已经安装了所需的 Linux 字体。可以从适合您需求的字体提供商或在线字体库获取所需字体文件。
2. 在代码中指定要使用的字体名称。例如,如果您希望使用 Linux 下的 Arial 字体,可以将字体名称设置为 "Arial"。
3. 使用 Aspose 提供的 API 来设置所需字体。以下是一个示例代码片段,演示如何在 Aspose.Words 中将字体设置为 Linux 字体并将 Word 文档转换为 PDF:
```java
// 加载 Word 文档
Document doc = new Document("input.docx");
// 创建 FontSettings 对象
FontSettings fontSettings = new FontSettings();
fontSettings.setFontsFolder("/path/to/linux/fonts/folder", true); // 设置 Linux 字体文件夹路径
fontSettings.DefaultFontName = "Arial"; // 设置要使用的字体名称
// 将 FontSettings 对象分配给文档
doc.FontSettings = fontSettings;
// 保存为 PDF
doc.Save("output.pdf", SaveFormat.Pdf);
在上述示例中,通过创建一个 `FontSettings`
相关推荐















