Available Now: Explore our latest release with enhanced accessibility and powerful IDP features

How to Convert PDF to PDF/A with Apryse

By Apryse | 2024 Feb 28

Sanity Image
Read time

5 min

It is possible to convert from PDF to PDF/A in many different ways, using many different solutions. If you’re interested in converting a small number of PDF files to PDF/A, look no further than Apryse’s free online PDF/A converter tool.

If you’re interested in learning how to integrate PDF to PDF/A conversion functionality into a workflow or an application in an enterprise or archival setting, Apryse offers a PDF/A Library, including a command-line tool, which can be used to enable PDF/A conversion on Windows, Linux or MacOS devices, server-side and client-side—and even via a browser!

PDF to PDF/A Conversion with Apryse SDK & PDF/A Manager CLI

Copied to clipboard

Start by downloading a trial of the Apryse PDF/A Library, which includes the veraPDF-tested PDF/A Converter Command-Line tool, able to convert 20+ file formats to any of the PDF/A variants.

To get started on embedding Apryse’s SDK PDF/A conversion features into a desktop, mobile or web application, we offer code samples in many major programming languages:

Once you’re ready to begin converting files, you will need to configure your solution to convert to your desired PDF/A standard (PDF/A-1, -2, -3 or -4) and associated PDF/A conformance level (a, b and u, as well as 4e and 4f).

You can read about the different PDF/A versions.

For most applications and where you are not constrained by a policy, we recommend picking PDF/A-2b.

With the command-line tool, PDF/A Manager, you can easily convert files to PDF/A-2b by copy-pasting the following into the prompt.

# command line
pdfa --outdir output-folder --level 2B --convert --linearize path_to_your_pdf_file

For other PDF/A variants change the level in the command.

You can also validate a PDF (before or after conversion) against PDF/A-2b with the following:

# command line
pdfa --outdir output-folder --level 2B path_to_your_pdf_file

Web-Based Conversion to PDF/A

Copied to clipboard

Using JavaScript & WebAssembly, Apryse even makes it possible to convert to and validate PDF/A purely client-side within a browser. Samples and test files are available as follows, with the PDF/A conversion sample appended below:

//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------
(exports => {




  exports.runPDFA = () => {
    const PDFNet = exports.Core.PDFNet;

    const main = async () => {
      try {
        console.log('PDFA validation test begins.');

        const inputURL = '../TestFiles/';
        const inputFilename = 'newsletter.pdf';

        const convert = false;
        const pwd = '';
        let exceptions;
        const maxRefObjs = 10;
        const firstStop = false;
        const url = inputURL + inputFilename;

        const pdfa = await PDFNet.PDFACompliance.createFromUrl(convert, url, pwd, PDFNet.PDFACompliance.Conformance.e_Level1B, exceptions, maxRefObjs, firstStop);

        const errorCount = await pdfa.getErrorCount();
        if (errorCount === 0) {
          console.log(inputFilename + ' is a valid PDFA.');
        } else {
          console.log(inputFilename + ' is NOT a valid PDFA.');
          for (let i = 0; i < errorCount; i++) {
            const errorCode = await pdfa.getError(i);
            const errorMsg = await PDFNet.PDFACompliance.getPDFAErrorMessage(errorCode);
            const numRefs = await pdfa.getRefObjCount(errorCode);
            if (numRefs > 0) {
              const objs = [];
              for (let j = 0; j < numRefs; j++) {
                const objRef = await pdfa.getRefObj(errorCode, j);
                objs.push(objRef);
              }
              console.log('Error:' + errorMsg + '. Objects:' + objs.toString());
            }
          }
        }
      } catch (err) {
        console.log(err);
      }
      try {
        console.log('PDFA conversion test begins.');

        const inputURL = '../TestFiles/';
        const inputFilename = 'fish.pdf';
        const outputFilename = 'fish_pdfa.pdf';

        const convert = true;
        const pwd = '';
        let exceptions;
        const maxRefObjs = 10;
        const urlInput = inputURL + inputFilename;

        console.log('Converting input document: ' + inputFilename);
        const pdfa = await PDFNet.PDFACompliance.createFromUrl(convert, urlInput, pwd, PDFNet.PDFACompliance.Conformance.e_Level1B, exceptions, maxRefObjs);

        const errorCount = await pdfa.getErrorCount();
        if (errorCount === 0) {
          console.log(inputFilename + ' is a valid PDFA.');
        } else {
          console.log(inputFilename + ' is NOT a valid PDFA.');
        }

        console.log('Save and validate the converted document: ' + outputFilename);
        const linearize = true;
        const docBuffer = await pdfa.saveAsFromBuffer(linearize);
        saveBufferAsPDFDoc(docBuffer, outputFilename);
        const validateOnly = false;
        const pdfaValidate = await PDFNet.PDFACompliance.createFromBuffer(validateOnly, docBuffer, pwd, PDFNet.PDFACompliance.Conformance.e_Level1B, exceptions, maxRefObjs);
        const errorCountValidate = await pdfaValidate.getErrorCount();
        if (errorCountValidate === 0) {
          console.log(outputFilename + ' is a valid PDFA.');
        } else {
          console.log(outputFilename + ' is NOT a valid PDFA.');
        }
      } catch (err) {
        console.log(err);
      }
    };

    // add your own license key as the second parameter, e.g. PDFNet.runWithCleanup(main, 'YOUR_LICENSE_KEY')
    PDFNet.runWithCleanup(main);
  };
})(window);
// eslint-disable-next-line spaced-comment
//# sourceURL=PDFATest.js

Convert PDF to PDF/A without Cutting Corners

Copied to clipboard

When you run the Apryse PDF/A converter feature using any of the above solutions, Apryse checks if your PDF file is compliant with the PDF/A (ISO 19005 or ISO 32000) standard and converts your PDF file to a PDF/A compliant document. In so doing, the converter does a deep dive into your file to parse its contents. It then performs only the light-touch edits necessary to fix any violations it encounters, and without taking any shortcuts that could impact the original interactivity or accessibility of your files, such as rasterizing vector information into an image.

The Apryse PDF/A converter will preserve tags, logical structure and color information present in the input PDF files, while enabling you to configure the solution to add or exclude certain criteria. And at the end of the conversion process, you will get a detailed report listing any issues the converter encountered and issues the converter fixed, including any corrected or outstanding PDF/A violations and their associated PDF object(s).

Auto-Conversion - Still Not 100%

Copied to clipboard

In most cases, and assuming you have chosen a reasonable PDF/A standard and conformance level, your files will convert automatically and without any issues. However, before or after conversion, you may want to inspect and possibly edit a PDF object manually.

You can achieve this with Apryse’s demo CosEdit tool.

In the image below, we’ve juxtaposed a Apryse PDF/A converter command-line tool output report (on the left) with the CosEdit window (on the right).

Inspect and edit a PDF object manually

The current PDF object under inspection in CosEdit has been given yellow highlights where it appears in both windows. You can see that the file passed conversion and re-validation without any outstanding issues. But were an error to appear, it would do so within the “PDF/A Revalidation Results (After Conversion)” section.

The new output file (license_pdfa.pdf) is accessible through the link at the bottom of the output report. Whereas the original file (license.pdf) is preserved and can be accessed through a link at the top.

For more answers to your PDF/A-related questions, be sure to check out our complete PDF/A guide!

This article was originally published in 2018 and has been updated to contain the latest information.

Sanity Image

Apryse

Share this post

email
linkedIn
twitter