这个简单的主题重点关注如何在 C# 中将 PCL 转换为 PDF。它包括配置开发环境的详细信息以及使用 C# 将 PCL 转换为 PDF 的工作示例代码。开发的应用程序可以在 Windows、Linux 或 macOS 内的任何 .NET 配置环境中使用。
在 C# 中将 PCL 导出为 PDF 的步骤
- 设置环境以使用Aspose.PDF for .NET将PCL文件转换为PDF
- 创建 PclLoadOptions 类的实例并设置所需的加载属性
- 通过将 PclLoadOptions 对象作为参数传递,将源 PCL 文件加载到 Document 对象中
- 将 PCL 文件以 PDF 形式保存在磁盘上
上述步骤有助于通过简单的 API 接口使用 c#* 开发 *PCL 到 PDF 转换器。该过程首先使用 PclOptions 类的实例设置 PCL 文件加载选项,然后从磁盘加载源 PCL 文件并使用 Document 类的实例将其保存为 PDF。
使用 C# 开发 PCL 到 PDF 转换器的代码
using System; | |
using Aspose.Pdf; | |
namespace TestPDF | |
{ | |
public class ConvertPclToPdf | |
{ | |
public static void PclToPdfConverter() | |
{ | |
String path = @"/Users/KnowledgeBase/TestData/"; | |
// Applying product license to convert PCL to PDF in C# | |
License PclToPdfLic = new License(); | |
PclToPdfLic.SetLicense(path + "Conholdate.Total.Product.Family.lic"); | |
PclLoadOptions pclOptions = new PclLoadOptions | |
{ | |
BatchSize = 2 | |
}; | |
// Load the source PCL | |
Document pclDocument = new Document(path + "hidetext.pcl", pclOptions); | |
//Save the PCL to PDF | |
pclDocument.Save(path + "Export_Pcl_Test.pdf"); | |
} | |
} | |
} |
此示例代码演示了使用几行代码在 C# 中将 PCL 文件转换为 PDF 的过程。 PclLoadOptions 公开一些属性,例如设置转换的批量大小、禁用字体许可证验证、加载格式和警告处理程序以自定义 PCL 文件加载。通过设置所需的 PCL 文件加载选项,您可以在 C# 中轻松将 PCL 导出为 PDF。
这个清晰的示例指导我们使用 C# 将 PCL 转换为 PDF。如果您想清除 PDF 文件中的元数据,请参阅有关 如何在 C# 中清除 PDF 中的元数据 的文章。