/** * This will overlay a document and write out the results.<br> * <br> * usage: java PDF.Overlay <overlay.pdf> <document.pdf> <result.pdf> * * @param args The command line arguments. * @throws IOException If there is an error reading/writing the document. * @throws COSVisitorException If there is an error writing the document. */ public static void main(String[] args) throws IOException, COSVisitorException { if (args.length != 3) { usage(); System.exit(1); } else { PDDocument overlay = null; PDDocument pdf = null; try { overlay = getDocument(args[0]); pdf = getDocument(args[1]); Overlay overlayer = new Overlay(); overlayer.overlay(overlay, pdf); writeDocument(pdf, args[2]); } finally { if (overlay != null) { overlay.close(); } if (pdf != null) { pdf.close(); } } } }