import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.List;
import com.lowagie.text.PageSize;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfAnnotation;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
import com.lowagie.text.pdf.SimpleBookmark;
public class MainClass {
public static void main(String[] args) throws Exception {
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
PdfReader reader = new PdfReader("test.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("my.pdf"));
stamper.insertPage(1, PageSize.A4);
PdfContentByte cb = stamper.getOverContent(1);
cb.beginText();
cb.setFontAndSize(bf, 18);
cb.setTextMatrix(36, 770);
cb.showText("Inserted Title Page");
cb.endText();
List list = SimpleBookmark.getBookmark(reader);
HashMap map = new HashMap();
map.put("Title", "Title Page");
map.put("Action", "GoTo");
map.put("Page", "1 FitH 806");
list.add(0, map);
stamper.setOutlines(list);
stamper.close();
}
}