本文介绍如何使用Spire.PDF for .NET将PDF转为符合PDF/A-1A, 2A, 3A, 1B, 2B和3B标准的PDF。
C#
using System;
using Spire.Pdf.Conversion;
namespace ConvertPdf2PdfA
{
class Program
{
static void Main(string[] args)
{
//指定输入文档路径
String inputFile = @"C:\Users\Administrator\Desktop\sample.pdf";
//指定输出文档的存放文件夹
String outputFolder = @"C:\Users\Administrator\Desktop\Output\";
//创建PdfStandardsConverter对象,传入输入文档路径
PdfStandardsConverter converter = new PdfStandardsConverter(inputFile);
//转换为PdfA1A
converter.ToPdfA1A(outputFolder + "ToPdfA1A.pdf");
//转换为PdfA1B
converter.ToPdfA1B(outputFolder + "ToPdfA1B.pdf");
//转换为PdfA2A
converter.ToPdfA2A(outputFolder + "ToPdfA2A.pdf");
//转换为PdfA2B
converter.ToPdfA2B(outputFolder + "ToPdfA2B.pdf");
//转换为PdfA3A
converter.ToPdfA3A(outputFolder + "ToPdfA3A.pdf");
//转换为PdfA3B
converter.ToPdfA3B(outputFolder + "ToPdfA3B.pdf");
}
}
}
VB.NET
Imports System
Imports Spire.Pdf.Conversion
Namespace ConvertPdf2PdfA
Class Program
Shared Sub Main(ByVal args() As String)
'指定输入文档路径
Dim inputFile As String = "C:\Users\Administrator\Desktop\sample.pdf"
'指定输出文档的存放文件夹
Dim outputFolder As String = "C:\Users\Administrator\Desktop\Output\"
'创建PdfStandardsConverter对象,传入输入文档路径
Dim converter As PdfStandardsConverter = New PdfStandardsConverter(inputFile)
'转换为PdfA1A
converter.ToPdfA1A(outputFolder + "ToPdfA1A.pdf")
'转换为PdfA1B
converter.ToPdfA1B(outputFolder + "ToPdfA1B.pdf")
'转换为PdfA2A
converter.ToPdfA2A(outputFolder + "ToPdfA2A.pdf")
'转换为PdfA2B
converter.ToPdfA2B(outputFolder + "ToPdfA2B.pdf")
'转换为PdfA3A
converter.ToPdfA3A(outputFolder + "ToPdfA3A.pdf")
'转换为PdfA3B
converter.ToPdfA3B(outputFolder + "ToPdfA3B.pdf")
End Sub
End Class
End Namespace