Here is a sample java program showing how to add a redaction annotation to a PDF document, export them as xfdf and then re-import them into another PDF document using Qoppa library jPDFProcess.
// create a new PDF and append a page to it PDFDocument doc1 = new PDFDocument(); PDFPage page1 = doc1.appendNewPage(72 * 8.5, 72 * 11); // create redaction annotation and set properties Redaction annotation = doc1.getAnnotationFactory().createRedaction(""); // set annotation bounds annotation.setRectangle(new Rectangle2D.Double(100, 100, 100, 100)); // annotation border color (Red) annotation.setColor(Color.RED); // annotation opacity annotation.setOpacity(50); // redaction color (Gray) annotation.setInternalColor(Color.GRAY); // set overlay text color (Blue) annotation.setOverlayTextColor(Color.BLUE); // set overlay font police and size annotation.setOverlayFont("Times-Roman", 8); // set overlay text annotation.setOverlayText("[NEW TERM]"); // set overlay repeat annotation.setOverlayTextRepeats(true); // add redaction annotation to page 1 page1.addAnnotation(annotation); // export annotations to an xfdf file doc1.exportAnnotsAsXFDF("C:/support/redaction.xfdf", null); // create a new PDF and append a page to it PDFDocument doc2 = new PDFDocument(); doc2.appendNewPage(72 * 8.5, 72 * 11); // import annotations from FDF into PDF doc2.importAnnotsXFDF("C:/support/redaction.xfdf"); // save the PDF doc2.saveDocument("C:/support/redaction.pdf"); |
Here are the attributes in the XFDF files specific to the redaction annotation:
coords Optional
interior-color Optional
overlay-text Optional
overlay-text-repeat Optional
justification Optional