Apply PDF/A-3 Standard

This guide will show how to apply PDF/A-3 standards to a file using UniPDF library.

Before you begin

First things first, you should get your API key from your UniCloud account.

If you don’t have a development environment setup, That is if this is your first time using UniPDF SDK, follow this guide to set up a local development environment.

Project setup

Clone the project repository

In your terminal, clone examples repository. It contains the Go code we will be using for this guide.

git clone https://github.com/unidoc/unipdf-examples.git

Navigate to the pdfa folder in the unipdf-examples directory.

cd unipdf-examples/pdfa

Configure environment variables

Replace the UNIDOC_LICENSE_API_KEY with your API credentials from your UniCloud account.

Linux/Mac

export UNIDOC_LICENSE_API_KEY=PUT_YOUR_API_KEY_HERE

Windows

set UNIDOC_LICENSE_API_KEY=PUT_YOUR_API_KEY_HERE

How it works

The following example code applies PDF/A-3 standard to a file, specifically PDF/A-3B.

The import section in lines 9-18 imports the UniPDF packages and other libraries. The metered license key is loaded from the system environment using the init function defined in lines 20-27.

The main function defined in lines 29-65 applies the PDF/A-3 standard and writes the document to a file. The input and output file paths are read in lines 30-36 from the command line arguments. The starting time is instantiated in line 39.

In lines 46-56 a new PdfReader is instantiated from the input file and converted to a PdfWriter object. The standard is applied using pdfWriter.ApplyStandard(pdfa.NewProfile3B(nil)) in line 55. Then the document is written to file in line 58. Finally the time taken to process the file is measured in line 63.

Run the code

Run this command to create apply the PDF/A-3 standard on the <input.pdf> file.

go run pdfa3_apply_standard.go <input.pdf> <output.pdf>

Sample output

Processing time: 132.17 ms

Got any Questions?

We're here to help you.