Sirs,
I am developing a java class to import JPEG images into a multipage PDF. The
files are stored into a single directory which has images with different
sizes, like first page is an A4 (portrait), second page is an A5 and the
third page is an A4 (landscape). I suppose that I am doing something wrong
because the multipage PDF is created but all pages remains with the first
page Image size. Any thoughts?
See the sample code bellow:
public class Image2Pdf
{
public static final String RESULT = "./Teste/Image2Pdf.pdf";
public static final String PAGE1 = "./Teste/img001.jpg";
public static final String PAGE2 = "./Teste/img002.jpg";
public static final String PAGE3 = "./Teste/img003.jpg";
public static final void main(String[] args) throws IOException,
DocumentException {
Image img = Image.getInstance(PAGE1);
Rectangle rectangle = new Rectangle(img);
Document document = new Document(rectangle);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(RESULT));
document.open();
img.setAbsolutePosition(0, 0);
document.add(img);
//Page 2
document.newPage();
img = Image.getInstance(PAGE2);
rectangle = new Rectangle(img);
writer.setPageSize(rectangle);
img.setAbsolutePosition(0, 0);
document.add(img);
//Page 3
document.newPage();
img = Image.getInstance(PAGE3);
rectangle = new Rectangle(img);
writer.setPageSize(rectangle);
img.setAbsolutePosition(0, 0);
document.add(img);
document.close();
}
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/