Hi,
I'm trying to render images as PDF dynamically, using the page size of the
original image.
When I look at my PDF the page size seems to be incorrectly set. When I use
Paragraph instead of Image the page size works as expected.
Looking into the source, my guess is the difference between creating the
PdfPage with pagesize instead of newpagesize??
Here's my code:
public static void main(String[] args) {
// creation of the document with a certain size and certain margins
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try {
// creation of the different writers
PdfWriter.getInstance(document , new
FileOutputStream("C:\\text.pdf"));
// we open the document for writing
document.open();
document.add(new Paragraph("Initial page"));
document.setMargins(0, 0, 0, 0);
Image image = new Jpeg(new URL("file:E:\\Programme\\Microsoft
Office\\Templates\\1031\\PAGES11\\photo.tem\\SAMPLE12.JPG"));
document.setPageSize((Rectangle) image);
document.newPage();
document.add(image);
Image image2 = new Jpeg(new URL("file:E:\\Programme\\Microsoft
Office\\Templates\\1031\\WEBS11\\personal.tem\\IMAGES\\PARROT1.JPG"));
document.setPageSize((Rectangle) image2);
document.newPage();
document.add(image2);
} catch(DocumentException de) {
System.err.println(de.getMessage());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
document.close();
}
Regards,
Elmar
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/