• 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
Getting Started
Validating against PDF/A or PDF/X
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.

Getting Started

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

Validating against PDF/A or PDF/X

// 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"); 
}

Converting to PDF/A

// 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);
// Validate the document
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