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.
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.
Configure environment variables
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
init function defined in lines
20-27 loads your metered license key and authenticates your request.
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.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
Finally the time taken is measured using
float64(time.Since(start)) / float64(time.Millisecond) in line
Run the code
Run this command to validate the PDF/A standard on the
go run pdfa_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: 42.82 ms
PDF/A-1 verapdf validation report
The following image shows a validation report from verapdf for the same file.