PDF to PDF/A

Convert PDF to PDF/A using Java

PDF is a versatile file format created by Adobe that gives people an easy, reliable way to present and exchange documents - regardless of the software, hardware, or operating systems being used. Furthermore, PDF/A is an archival format of PDF that embeds all fonts used in the document within the PDF file. Also, as the PDF/A file contains everything needed to display it and nothing which could negatively impact the display, so many users desire to export PDF to PDF/A. So in this step-by-step guide, we are going to explore the details for converting PDF to PDF/A using Java.

PDF Conversion API

Aspose.PDF Cloud provides the capabilities to create, edit and manipulate PDF documents. It offers the feature to load PDF file and convert to a plethora of supported formats. Now in order to use the SDK, first we need to add the reference of Aspose.PDF Cloud SDK for Java in our Java application by including following details in pom.xml (maven build type project).

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-cloud-pdf</artifactId>
        <version>21.11.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

Once the SDK reference has been added, we need to obtain your client credentials from Cloud Dashboard. In case you are not already registered, please register using valid email address and fetch your personalized credentials.

PDF to PDF/A using Java

This section provides all the necessary details to load PDF document from cloud storage and convert to PDF/A format. Please note that the API currently supports the following PDF/A formats (PDF/A1-A, PDF/A1-B, PDF/A-3A).

  • Firstly, create an instance of PdfApi where we pass the personalized credentials as arguments
  • Secondly, read the input PDF using File instance and upload it to cloud storage using uploadFile(…) method of PdfAPi class
  • Thirdly, define the PDF/A type as PDFA1A using string variable
  • Lastly, call the method putPdfInStorageToPdfA(…) to convert PDF to PDF/A and save the output to cloud storage

PDF Convert to PDF/A using cURL Commands

We also have an option to perform the PDF to PDF/A conversion using cURL commands. So a prerequisite for this approach is to generate a JWT access token (based on client credentials) using the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once the JWT is generated, we need to execute the following command to load the PDF from Cloud storage and convert to PDF/A-1b format. After the conversion, we are going to save the output on a local drive.

curl -X -v GET "https://api.aspose.cloud/v3.0/pdf/PdfWithAcroForm.pdf/convert/pdfa?type=PDFA1B" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <JWT Token>" \
-o "Resultant.pdf"

Conclusion

In this article, we have gone through all the necessary steps to use the Java REST API for converting PDF to PDF/A format. The complete process has been simple and straightforward, and can be easily integrated into new or in your existing Java application. Either you need to convert a single PDF or perform a batch processing of multiple forms, this guide makes it easy to convert PDF to PDF/A compliance format.

We highly recommend exploring the Product Documentation, as it contains all the information regarding other exciting features of the API. In case you desire to get an access to the source code of Cloud SDK, it is available on GitHub (published under MIT license). Lastly, in case you encounter any issues while using the API, please feel free to contact us via free Product Support Forum.

Please visit the following links to learn more about: