Get Security Info
This guide will show you how to get information about locked or password-protected PDF documents. The program returns whether or not a PDF is encrypted and the encryption method used.
Before you begin
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
security folder in the unipdf-examples directory.
Configure environment variables
Replace the UNIDOC_LICENSE_API_KEY with your API credentials from your UniCloud account.
How it works
9-15 import the UniPDF packages and other required dependencies.
17-24 authenticate your request with your
UNIDOC_LICENSE_API_KEY with the init function.
The main function in lines
26-39 validates your input and passes it as an argument to the
41-80 define the
printSecurityInfofunction, which accepts inputPath as a parameter. The function checks if the input PDF is encrypted or not and the encryption method.
Run the code
Run this command to get security info about locked PDFs. This will also get all the required dependencies to run the program.
You will get the locked PDF’s encryption status on the terminal.