I'm a newbie with Itext. I'm using iText 1.4.8.
I've written a simple code for generate a pdf file with PageSize.A4.rotate().
When the file is generated I've that the first age is different by other pages.
Where Do I wrong?
Thanks a lot
Pierluigi
public class TestPdf {
public void createPdf() throws FileNotFoundException, DocumentException{
Document document = new Document(PageSize.A4.rotate());
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("d:/Test.pdf"));
document.open();
setConvenzione(document);
for (int i = 0; i < 10; i++) {
document.newPage();
setConvenzione(document);
}
document.close();
}
private void setConvenzione(Document document) throws DocumentException{
Graphic grx = new Graphic();
grx.rectangle(30, 500, 500, 80);
grx.stroke();
document.add(grx);
Phrase[] righe = new Phrase[3];
float leading = 24;
righe[0] = new Phrase(leading, "Convenzione N. " + "00829292");
righe[1] = new Phrase(leading, "Ambito " + "ROMA");
righe[2] = new Phrase(leading, "Ente " + "34363");
document.add(righe[0]);
document.add(Chunk.NEWLINE);
document.add(righe[1]);
document.add(Chunk.NEWLINE);
document.add(righe[2]);
}
public static void main(String[] args) {
TestPdf tPdf = new TestPdf();
try {
tPdf.createPdf();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
}