How to add images in pdf and how to add images in pdf
Public class synchronized test {public static void main (String [] args) throws Exception {PdfReader reader = new PdfReader ("E: \ src.pdf"); int n = reader. getNumberOfPages (); // the number of pages in pdf Document document = new Document (reader. getPageSize (n); float width = document. getPageSize (). getWidth (); float height = document. getPageSize (). getHeight (); // output file export Stamper stamp = new export Stamper (reader, new FileOutputStream ("E: \ outputfileworkflow"); export contentbyte over; Image img = Image. getInstance ("E: \ test.jpg"); width = width-img.getWidth (); height = height-img.getHeight (); img. setAbsolutePosition (width, height); // The coordinate origin is img in the lower left corner. setAlignment (Image. ALIGN_RIGHT); if (n> 0) {over = stamp. getOverContent (1); // display the image on the page (1 on the first page) over. addImage (img);} stamp. close ();}}
Note: itextpdf-5.4.5.jar packages are required
<dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.4.5</version></dependency>