Here is some Java sample code to add a new redaction annotation and then burn / apply it on a page of a PDF document using Qoppa’s PDF library jPDFProcess.

Java Library to Add & Burn Redaction Annotations:

jPDFProcess can redact text, images and shapes / path commands in PDF documents, it is extremely sophisticated as it can remove the part of an images that intersects with the redaction annotations.

package jPDFProcessSamples;
 
import java.awt.Color;
import java.awt.geom.Point2D;
import java.util.Vector;
 
import com.qoppa.pdf.annotations.Redaction;
import com.qoppa.pdfProcess.PDFDocument;
import com.qoppa.pdfProcess.PDFPage;
 
public class RedactionApplyBurn
{
    public static void main (String [] args)
    {
        try
        {
            // Load the document
            PDFDocument pdfDoc = new PDFDocument ("C:\\myfolder\\input.pdf", null);
 
            if(pdfDoc.getPageCount() > 0)
            {
 
            	// this is a rectangle for the redaction annotation bounds
            	Point2D.Double[] rectangle = new Point2D.Double[4];
            	rectangle[0] = new Point2D.Double(200,200);
            	rectangle[1] = new Point2D.Double(250,200);
            	rectangle[2] = new Point2D.Double(200,250);
            	rectangle[3] = new Point2D.Double(250,250);
            	Vector quads = new Vector();
            	quads.add(rectangle);
 
            	// create a redaction annotation
            	Redaction redacAnnot = pdfDoc.getAnnotationFactory().createRedaction("", quads);
            	redacAnnot.setInternalColor(Color.black);
 
            	// add the annotation to the page
            	PDFPage page = pdfDoc.getPage(0);
            	page.addAnnotation(redacAnnot);
 
            	// save doc with redaction
            	pdfDoc.saveDocument ("C:\\myfolder\\input_redact_annot.pdf");
 
            	// apply / burn redaction annotations
            	page.applyRedactionAnnotations();
 
            	// save doc with redaction
            	pdfDoc.saveDocument ("C:\\myfolder\\input_redact_burn.pdf");
 
            }
        }
        catch (Throwable t)
        {
            t.printStackTrace();
        }
        }
 
}

Client-Side Tools to Add Redaction Annotations:

On the client-side, the following tools published by Qoppa Software can be used to add redaction annotations visually (as well as burn them):

All Qoppa’s tools are 100% compliant with the PDF specifications and Adobe products.

Tagged: