Validate Standard

This guide shows the process of validating PDF/A standard using UniPDF library.

Before you begin

First you should get your API key from your UniCloud account.

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

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.





How it works

The necessary UniPDF packages and other go libraries are imported using import section in lines 9-18. The init function defined in lines 20-27 loads your metered license key and authenticates your request.

The main function defined in lines 29-69 validates the PDF/A standard. In lines 30-35 the path to the input file is read from the command line arguments. The starting time is instantiated in line 38. A new compliance reader is instantiated using NewCompliancePdfReader(inputFile) in line 47. A list of standards containing pdfa.Profile1A and pdfa.Profile1B is instantiated in lines 54-57. In lines 60-64 the for loop iterates through each profile and validates the PDF/A standard using standard.ValidateStandard(detailedReader).

Finally the time taken is measured using float64(time.Since(start)) / float64(time.Millisecond) in line 67.

Run the code

Run this command to validate the PDF/A standard on the <input.pdf> file.

go run pdfa_validate_standard.go <input.pdf>

Sample output

The following message is a sample output printed on the terminal after running the code with sample input file.

Processing time: 42.82 ms

PDF/A-1 verapdf validation report

The following image shows a validation report from verapdf for the same file.

PDF/A-1 validation

Got any Questions?

We're here to help you.