Hello,

I am new and are learning to use the itext package to generate pdf file. I am using the latest library.

I tried to generate the pdf file with text and image. The second image can not fit into the the first page. It did not showup in the pdf file. I have to manually call document.newPage() to start a new page. Then the image showed up.

Could you anyone please reply me and tell me what I did wrong here or point me to the right direction to look?

thanks.

Here is my code:
Document document = new Document(PageSize.A4, 80, 50, 30, 65);
PdfWriter.getInstance(document, new FileOutputStream("a.pdf"));
document.addTitle("my Report");

document.open();

Paragraph p1 = new Paragraph(new Chunk("header 1\n\n", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)));
p1.setAlignment(Paragraph.ALIGN_CENTER);
document.add(p1);


Graphic grx=new Graphic();
grx.setHorizontalLine( 2, 100, Color.black);
grx.stroke();
document.add(grx);

Phrase phrase=new Phrase(new Chunk("Products: Akamai Express - Object Delivery",
FontFactory.getFont(FontFactory.HELVETICA, 12)));
phrase.add(new Chunk("Header2\n\n\n"));
document.add(phrase);



Paragraph p2 = new Paragraph(new Chunk("status1\n\n\n", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)));
p2.setAlignment(Paragraph.ALIGN_CENTER);
p2.add(new Chunk("status2\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
p2.add(new Chunk("status3\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
p2.add(new Chunk("status4\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
p2.add(new Chunk("status5\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
p2.add(new Chunk("status6MB\n\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
document.add(p2);


Paragraph p3 = new Paragraph(new Chunk("header4\n",FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)));
p3.setAlignment(Paragraph.ALIGN_CENTER);
document.add(p3);
document.add(Image.getInstance("image.jpg"));


document.newPage();

Paragraph p4 = new Paragraph(new Chunk("\header5\n",
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)));
p4.setAlignment(Paragraph.ALIGN_CENTER);

Image img=Image.getInstance("image1.jpg");
p4.add(img);
document.add(p4);

document.close();

_________________________________________________________________
Watch LIVE baseball games on your computer with MLB.TV, included with MSN Premium! http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/




-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to