Convert PDF to PDF/A, PDF/E, and PDF/X in Java

Aspose.PDF for Java can validate and convert standard PDF files into archival and exchange-oriented PDF standards.

Convert PDF to PDF/A

Use this example when a standard PDF should be converted into a PDF/A-compliant archival document.

  1. Open the source PDF in a Document instance.
  2. Call document.convert(...) with PdfFormat PDF_A_1B and ConvertErrorAction Delete.
  3. Write the validation log to a sidecar XML file so compliance issues are recorded during conversion.
  4. Save the validated PDF/A output.
public static void convertPdfToPdfA(Path inputFile, Path outputFile) {
    try (Document document = new Document(inputFile.toString())) {
        document.convert(logFile(outputFile, "-log.xml").toString(), PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);
        document.save(outputFile.toString());
    }
}

Convert PDF to PDF/E

Use this example when a PDF should be converted into the engineering-oriented PDF/E standard.

  1. Create PdfFormatConversionOptions for PdfFormat PDF_E_1 and the desired log-file path.
  2. Open the source PDF in a Document instance.
  3. Call document.convert(options) so the compliance conversion is executed with the prepared options object.
  4. Save the resulting compliant PDF file.
public static void convertPdfToPdfE(Path inputFile, Path outputFile) {
    PdfFormatConversionOptions options = new PdfFormatConversionOptions(
            logFile(outputFile, "-log.xml").toString(), PdfFormat.PDF_E_1, ConvertErrorAction.Delete);

    try (Document document = new Document(inputFile.toString())) {
        document.convert(options);
        document.save(outputFile.toString());
    }
}

Convert PDF to PDF/X

Use this example when a PDF should be converted into the print-oriented PDF/X standard.

  1. Create PdfFormatConversionOptions for PdfFormat PDF_X_4 and the desired log-file path.
  2. Configure an OutputIntent such as FOGRA39 so the print-target color profile is embedded into the conversion settings.
  3. Open the source PDF in a Document instance and call document.convert(options).
  4. Save the converted PDF/X output.
public static void convertPdfToPdfX(Path inputFile, Path outputFile) {
    PdfFormatConversionOptions options = new PdfFormatConversionOptions(
            logFile(outputFile, "-log.xml").toString(), PdfFormat.PDF_X_4, ConvertErrorAction.Delete);
    options.setOutputIntent(new OutputIntent("FOGRA39"));

    try (Document document = new Document(inputFile.toString())) {
        document.convert(options);
        document.save(outputFile.toString());
    }
}