MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Rectangle;
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();
        writer.addAnnotation(PdfAnnotation.createText(writer, new Rectangle(50, 780, 70, 800), "Comment",
                "This is a Comment", false, "Comment"));
        writer.addAnnotation(PdfAnnotation.createText(writer, new Rectangle(100, 780, 120, 800), "Help",
                "This is a Help ", true, "Help"));
        document.close();
    }
}