I am working with itext pdf library. I want to add a content at the end of the existing pdf.
Say for example the existing pdf(say Original.pdf) is having say 4 pages, so I want to add another page i.e. page no 5 with content Hello World I am added content and save it in the same pdf i.e. Original.pdf
So after closing my Original.pdf will contain 5 pages i.e 4 pages(with default content they already have) + 1 page with content Hello World I am added content
I am using this code but showing an exception
String in="Original.pdf";
String out="Original.pdf";
PdfReader reader = new PdfReader(in);
PdfStamper stamper = new PdfStamper(reader,new FileOutputStream(out));
int totalPages=reader.getNumberOfPages();
stamper.insertPage(totalPages+1, PageSize.A4);
stamper.addAnnotation(
PdfAnnotation.createText(
stamper.getWriter(),
new Rectangle(30f, 750f, 80f, 800f),
"inserted page", "This page is the title page.",
true,
null)
,
reader.getNumberOfPages()
);
stamper.close();
java.io.EOFException
Thanks in advance.