• Common Slider

    Common Slider

    Qoppa Software offers a suite of carefully designed and developed products to cover every aspect of PDF processes and document workflows.

jPDFPreflight Developer Guide

jPDFPreflight Developer Guide

Contents

javalogo

Introduction
Loading a Document
Validating against PDF/A
Validating against PDF/X
Converting to PDF/A
Conversion Options
Distribution and JAR files

Source Code Samples
Javadoc API

Introduction

jPDFPreflight is a Java library to verify PDF compliance with different standards, including PDF/A and PDF/X and to convert documents to these standards.

Loading a Document

Simply load the document using the following call:

// Load the PDF Document
PDFPreflight pdfPreflight = new PDFPreflight("C:\\input.pdf", null);

Validating against PDF/A

The following PDF/A profiles are available for validation: PDFA_1_B_Verification, PDFA_2_B_Verification, PDFA_3_B_Verification. Here is sample code to validate against PDFA_1_B_Verification.

// Validate the document
PreflightResults results = pdfPreflight.verifyDocument(new PDFA_1_B_Verification(), null);
//Get validation results
if (results.isSuccessful())
{
System.out.println("PDF is compliant");
}
else
{
System.out.println("PDF is not compliant");
// Add annotations to the document
results.addResultAnnotations();
// Append report to the document
results.appendPreflightReport(612, 792);
// Save the PDF document (with annotations and report)
pdfPreflight.saveDocument("C:\\validationreport.pdf"); 
}

Validating against PDF/X

The following PDF/X profiles are available for validation: PDFX_1a_2001, PDFX_1a_2003, PDFX_3_2002, PDFX_3_2003. Here is a code sample to validate against PDFX_3_2002:

// Validate the document
PreflightResults results = pdfPreflight.verifyDocument(new PDFX_3_2002(), null);
//Get validation results
if (results.isSuccessful())
{
System.out.println("PDF is compliant");
}
else
{
System.out.println("PDF is not compliant");
// Add annotations to the document
results.addResultAnnotations();
// Append report to the document
results.appendPreflightReport(612, 792);
// Save the PDF document (with annotations and report)
pdfPreflight.saveDocument("C:\\validationreport.pdf"); 
}

Converting to PDF/A

The following PDF/A profiles are available for conversion: PDFA_1_B_Conversion, PDFA_2_B_Conversion, PDFA_3_B_Conversion. Here is sample code to convert to PDF/A-1b.

// Convert the document
PreflightResults results = pdfPreflight.convertDocument(new PDFA_1_B_Conversion(), null);
// Get conversion results
if (results.isSuccessful())
{
System.out.println("PDF was converted successfully");
// Save the PDF/A Document
pdfPreflight.saveDocument("C:\\output_pdfa.pdf"); 
} 
else 
{ System.out.println("PDF was not converted"); 
// Add annotations to the document 
results.addResultAnnotations(); 
// Append report to the document 
results.appendPreflightReport(612, 792); 
// Save the PDF document (with annotations and report)
pdfPreflight.saveDocument("C:\\conversionreport.pdf"); 
}

Conversion Options

It is possible to overwrite the default conversion options for PDF/A conversion:

// Create a new conversion profile
PDFA_1_B_Conversion profile = new PDFA_1_B_Conversion();
// Set conversion options
PDFAConversionOptions options = (PDFAConversionOptions) profile.getConversionOptions();
// delete any embedded files
options.setEmbeddedFiles(PDFAConversionOptions.OPTION_DELETE);
// give a warning / error during conversion if transparency is found
options.setTransparency(PDFAConversionOptions.OPTION_WARN);
// delete any unsupported annotations 
options.setUnsupportedAnnotations(PDFAConversionOptions.OPTION_DELETE);
// convert the document to PDF/A
PreflightResults results = pdfPreflight.convertDocument(new PDFA_1_B_Conversion(), null);

Distribution and JAR Files

Only the jPDFPreflight.jar file is always required for deployment, the remaining jar files are used to work with specific features in some PDF documents:

jPDFPreflight.jar – This is the main jar file for the component, it is always required.

cmaps.jar – This jar file contains CMaps, used to read and display character encodings used with CJK (Chinese, Japanese, Korean) content.

cmykProfile.jar – This jar file contains a CMYK profile used to accurately convert CMYK colors to RGB for display.

bcpkix-jdk14-147.jar and bcprov-jdk14-147.jar – These files contain the Bouncycastle security libraries, they are only used to verify digital signatures, when present.

jai_imageio.jar – This jar file contains Java’s ImageIO image decoders, including a decoder for JPEG 2000 images. This is only used when a document contains JPEG 2000 images.

jai_codec.jar – This jar file contains additional image encoders / decoders for ImageIO, it is necessary when opening and saving TIFF files.

Javadoc API
Source Code Samples