Add image to an existing Pdf document : Image « PDF « Java Tutorial


import com.lowagie.text.Image;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

public class MainClass {
  public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("HelloWorldRead.pdf");
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloWorldStamper2.pdf"));
    Image img = Image.getInstance("watermark.jpg");
    img.setAbsolutePosition(200, 400);
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    PdfContentByte under, over;
    int total = reader.getNumberOfPages() + 1;
    for (int i = 1; i < total; i++) {
      under = stamper.getUnderContent(i);



29.35.1.Add image to an existing Pdf document
29.35.2.Image transition
29.35.3.Create chunk from Image
29.35.4.Scale Absolute
29.35.5.Scale Percent
29.35.6.Scale Percent: 100, 50
29.35.7.Image Wrapping
29.35.8.Image Alignment
29.35.9.Image Mask
29.35.10.Convert java.awt.Image to com.lowagie.text.Image
29.35.11.Black and White
29.35.12.Red and Yellow
29.35.13.Rotate 30 degrees
29.35.14.Get Image height and width
29.35.15.Rotate 45 degreesRotate 45 degrees
29.35.16.Image Absolute Position
29.35.17.Pattern Matrix for an image