PDF/A-2 Apply Standard
This guide will show how to apply PDF/A-2 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.
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
The following example code applies PDF/A-2 standard to a file, specifically PDF/A-2B.
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
main function defined in lines
29-65 applies the PDF/A-2 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
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.NewProfile2B(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
Run the code
Run this command to create apply the PDF/A-2 standard on the
go run pdfa2_apply_standard.go <input.pdf> <output.pdf>
Processing time: 24.71 ms