I've just started to work with iText (5.4.2, latest version) and there are two things that I haven't yet managed to get straight.
- Creating documents in landscape. All pages are rendered portrait.
- Inserting images on a given position (number of millimeters from top & left).
I have the code below.
Document d = new Document(PageSize.A4_LANDSCAPE,0,0,0,0);
PdfWriter writer = PdfWriter.getInstance(d, new FileOutputStream("C:/test.pdf"));
document.open();
document.newPage();
Image img = Image.getInstance(String.format("C:/file.png"));
img.scaleToFit(400,240);
document.left(100f);
document.top(150f);
document.add(img);
document.close();
But the page is rendered in Portrait (not Landscape) and the image is put in the top left corner (not 10 and 15 units away from it as requested). What am I doing wrong?