Annotated Images : Annotation « PDF « Java Tutorial






import java.io.FileOutputStream;

import com.lowagie.text.Annotation;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
  public static void main(String[] args) throws Exception {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();
    Image gif = Image.getInstance("Logo.gif");
    gif.setAnnotation(new Annotation(0, 0, 0, 0, "http://www.java2s.com"));
    gif.setAbsolutePosition(30f, 750f);
    document.add(gif);
    Image jpeg = Image.getInstance("dog.jpg");
    jpeg.setAnnotation(new Annotation("picture", "dog", 0, 0,
        0, 0));
    jpeg.setAbsolutePosition(120f, 550f);
    document.add(jpeg);
    document.close();
  }
}








29.34.Annotation
29.34.1.Add Annotation
29.34.2.Annotated Images
29.34.3.Text Annotations
29.34.4.PdfAnnotation and Javascript