SimpleAnnotationsPDF.java Source code

Java tutorial

Introduction

Here is the source code for SimpleAnnotationsPDF.java

Source

import java.io.FileOutputStream;
import java.net.URL;

import com.lowagie.text.Annotation;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfAction;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class SimpleAnnotationsPDF {
    public static void main(String[] args) {
        Document document1 = new Document(PageSize.A4, 10, 10, 10, 10);
        try {
            PdfWriter writer1 = PdfWriter.getInstance(document1, new FileOutputStream("SimpleAnnotationsPDF.pdf"));
            writer1.setPdfVersion(PdfWriter.VERSION_1_5);
            document1.open();

            Annotation a1 = new Annotation("authors", "Text for an annotation", 250f, 700f, 350f, 800f);
            document1.add(a1);
        } catch (Exception de) {
            de.printStackTrace();
        }
        document1.close();
    }
}