import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfAction;
import com.lowagie.text.pdf.PdfAnnotation;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter writer = PdfWriter
.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
PdfAnnotation text = PdfAnnotation.createText(writer, new Rectangle(200f, 250f, 300f, 350f),
"Fox", "The fox is quick", true, "Comment");
PdfAnnotation javascript = new PdfAnnotation(writer, 200f, 550f, 300f, 650f, PdfAction
.javaScript("app.alert('hi');\r", writer));
Chunk fox = new Chunk("test").setAnnotation(text);
Chunk dog = new Chunk("javascript").setAnnotation(javascript);
document.add(fox);
document.add(dog);
document.close();
}
}