PDF/A-2 Validate Standard
This guide will show how to validate PDF/A-2 standards to a file using UniPDF library.
Before you begin
Before starting to follow along with this guide 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.
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
Configure environment variables
UNIDOC_LICENSE_API_KEY with your API credentials from your UniCloud account.
How it works
import section in lines
9-18 imports the necessary UniPDF packages.
init function defined in lines
20-27 loads the metered license key and authenticates your requests.
main function contains the code used to validate the PDF/A-2 standard. The path of the input file is read from the command line arguments. A new
CompliancePdfReader is instantiated from the input using
model.NewCompliancePdfReader(inputFile) in line
47. A list of different PDF/A-2 standard profiles is instantiated in lines
53-57. The loop in lines
60-64 iterates through each standard and runs validation using
Run the code
Run this command to validate the PDF/A-2 standard on the
go run pdfa2_validate_standard.go <input.pdf>
The following message is a sample output printed on the terminal after running the code with sample input file.
Processing time: 22.19 ms
PDF/A-2 verapdf validation report
The following image shows a validation report from verapdf for the same file.