Here is a sample java program showing how to open a PDF, add a company logo image at the top of each page, then save the document using Qoppa’s PDF library jPDFProcess.
// Load document PDFDocument pdfDoc = new PDFDocument ("C:\\myfolder\\input.pdf", null); // Load foreground image BufferedImage logoImage = ImageIO.read(new File("C:\\myfolder\\logo.jpg")); for (int i=0; i< pdfDoc.getPageCount(); i++) { // get current page PDFPage currentPage = pdfDoc.getPage(i); // add image logo on top currentPage.drawImage(logoImage, 0, 0, null, null, new ImageCompression(ImageCompression.COMPRESSION_DEFLATE, 1.0f)); } // Save the PDF pdfDoc.saveDocument ("C:\\myfolder\\output.pdf"); |
Download Full Java Sample Code
You may need to first resize pages of the PDF and shift their content down before adding a new logo.