
概述
在 C# 中将 PS 转换为 PDF 是许多开发人员的一项重要任务。 Aspose.Page for .NET 在这个过程中扮演着重要角色。同时,它在各个行业中被广泛使用。此外,Aspose.Page for .NET 简化了转换过程。此外,它提供了一种强大而高效的解决方案。但是,让我们开始实现如何以编程方式将 PostScript 转换为 PDF。
C# Postscript 库安装
要开始,请通过以下 NuGet 使用命令安装 Aspose.Page for .NET:
Install-Package Aspose.Page
或从 这里 下载该库。Aspose.Page for .NET 提供了易于集成、灵活性和先进的自定义选项,使其成为在 C# 中将 PostScript 转换为 PDF 的理想选择。
在 C# 中将 PostScript 转换为 PDF - 代码片段
要使用 Aspose.Page for .NET 在 C# 中将 PostScript 转换为 PDF,请按照以下步骤操作:
- 使用源 PostScript 文件初始化 PsDocument 类。
- 如果您想在存在小错误的情况下转换 PostScript 文件,请设置 suppressErrors 标志。
- 创建 PdfSaveOptions 类的对象。
- 如果您想添加特殊文件夹以存储字体,请设置 AdditionalFontsFolders 的值。操作系统中的默认字体文件夹始终包含在内。
- 通过调用 SaveAsPdf 方法将文档保存为 PDF。
以下是将 PS 转换为 PDF 的示例 C# 代码片段:
// Define the working directory. | |
string dataDir = "/Desktop"; | |
// Initialize PsDocument class with a source PostScript file. | |
PsDocument document = new PsDocument(dataDir + "input.ps"); | |
// If you want to convert Postscript file despite of minor errors set suppressErrors flag. | |
bool suppressErrors = true; | |
// Create an object of the PdfSaveOptions class. | |
PdfSaveOptions options = new PdfSaveOptions(suppressErrors); | |
// Set the value of the AdditionalFontsFolders if you want to add special folder where fonts are stored. Default fonts folder in OS is always included. | |
options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" }; | |
// Save document as PDF by calling the SaveAsPdf method. | |
document.SaveAsPdf(dataDir + "outputPDF_out.pdf", options); |
输出:

在线 PS 转 PDF 转换器
尝试这个 在线 的 PostScript 转 PDF 转换器。它是免费的,易于使用,并提供高准确性。最重要的是,它由 Aspose.Page for .NET 提供支持。

获取免费许可证
通过访问此 链接 获取 Aspose 产品的免费试用。
结论
总之,您可以使用 Aspose.Page for .NET 在 C# 中无缝地将 PostScript 转换为 PDF。探索 Aspose.Page for .NET 以了解更多关于此 PostScript 到 PDF 转换的内容。
公共资源
其他资源,例如文档或社区论坛,可以帮助读者进一步增强他们的理解或技能,超越博客内容。