0

I am trying to set a list of images in a PDF document using iText with Java, i could just insert some of them in the first page but i don't know how to jump to the next pages in order to put the rest of my pictures

for(int i = 0; i < 25; i++) {
    Image myImg = Image.getInstance("/home/code/img"+i+".png");
    imgPaper.setAbsolutePosition(50, 728-(y*58)); 
    document.add(myImg);
    y++;
}
user3166804
  • 23
  • 1
  • 6

2 Answers2

2

The OP clarified his question in a comment

i have already another pages, i just want how to jump to them 

You seem to be creating a new document using a PdfWriter. That class is designed to create a pdf one page after the other. As soon as you start a new page, all former ones are written to file.

Thus, in this process you cannot jump to arbitrary pages. You have to add all information for a page while it is the current one.

If, after creating a multi page document, you need to manipulate the content of its pages, first close the document (finishing it), read it into a PdfReader, and apply a PdfStamper which allows you to manipulate arbitrary pages of an existing PDF.

Alternatively, especially if your images constitute something like a water mark or header/footer Logos, consider using page events in your pdf creation process with the PdfWriter.

mkl
  • 90,588
  • 15
  • 125
  • 265
0

try to add a new line to your document

document.add( Chunk.NEWLINE );

link for info:

How to insert blank lines in PDF?

Community
  • 1
  • 1
  • i guess you haven't understand my question, i am asking about inserting images in different pages.. not to leave a space between them. – user3166804 Mar 27 '14 at 23:12