Convert PDF to PDF/A, PDF/E, and PDF/X in Java
Contents
[
Hide
]
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.
- Open the source PDF document.
- Run the PDF/A compliance conversion with the required target standard.
- 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.
- Open the source PDF document.
- Run the compliance conversion for PDF/E.
- 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.
- Open the source PDF document.
- Run the compliance conversion for PDF/X.
- 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());
}
}