Aspose.Pdf

How to create PDF/A-1b with Aspose.Pdf

Introduction to PDF/A

The PDF/A formats specified in the ISO 19005 standard strive to provide a consistent and robust subset of PDF, which can safely be archived for a long period of time, or it can be used for reliable data exchange in enterprise and government environments. The standard is based on PDF 1.4, and imposes some restrictions regarding the use of color, fonts, annotations, and other elements.

  There are two flavors of PDF/A-1: PDF/A-1b and PDF/A-1a. PDF/A-1b (formally ISO 19005-1 Level B) ensures that the visual appearance of a document is preserved even after the long time. In simple terms, PDF/A-1b ensures that the document will look like the same when; it is processed some time in the future. PDF/A-1a (formally ISO 19005-1 Level A) is based on level B, but adds some additional properties: it adds structure information and reliable text semantics in order to preserve the document's logical structure and natural reading order. In simple words, PDF/A-1a not only ensures that the document will look the same when it is processed some time in the future, but its contents (semantics) also can be reliably interpreted and will be accessible to physically impaired users.

Aspose.Pdf and PDF/A

Aspose.Pdf currently supports creation of PDF/A-1b. Pdf class has provided a Conformance property, which can be used to indicate whether to create a PDF/A-1b output or not. Developers can create PDF/A-1b output by setting the Conformance property of Pdf class to a pre-defined value of PdfConformance enumeration: PdfConformance.PdfA1B. The pre-defined values of PdfConformance enumeration are listed below:

Pre-defined value

Description

None  (default value)

Create a PDF without any conformance

PdfA1B

Create a PDF/A-1b output

Once the Conformance property of Pdf class has been set to the pre-defined value PdfConformance.PdfA1B”, Aspose.Pdf will automatically detect whether the current document comply with the restrictions of PDF/A-1b. In case any conflict occurs, Aspose.Pdf will throw exceptions which include the detail about the conflict.

How to create PDF/A-1b with Aspose.Pdf

In order to create PDF/A-1b output, developers only need to set the Conformance property of Pdf class to the pre-defined value PdfConformance.PdfA1B before the Save method of Pdf class is called. Although this looks very simple, developers should notice that PDF/A standard imposes some restrictions regarding the use of color, fonts, annotations, and other elements. Aspose.Pdf also has its own restrictions about the use of fonts, color, and other elements. Some of the limitations imposed, are listed below:

Adobe Acrobat Preflight tool can be used to verify the compliance of PDF document with the PDF/A standard.The following example shows how to use Aspose.Pdf to create PDF/A-1b compliant output.

Code Snippet

[C#]

//Create pdf document

Pdf pdf1 = new Pdf();

 

//Instantiate License class and call its SetLicense method to use the license

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense("Aspose.Custom.lic");

 

//Set the conformance property of Pdf class to predefined value

pdf1.Conformance = PdfConformance.PdfA1B;

 

//Add a section into the pdf document

Section sec1 = pdf1.Sections.Add();    

//Save the document

pdf1.Save("d:\\aspose\\HelloWorld.pdf");

 

[VB.NET]

'Create pdf document

Dim pdf1 As Pdf = New Pdf()

 

'Instantiate License class and call its SetLicense method to use the license

Dim license As License = New License

license.SetLicense("Aspose.Pdf.lic")

 

'Add a section into the pdf document

Dim sec1 As Section = pdf1.Sections.Add()

 

'Set the conformance property of Pdf class to predefined value

pdf.Conformance = PdfConformance.PdfA1B

 

'Save the document

pdf1.Save("HelloWorld.pdf")