Hello
Perhaps this is a silly question but I am still going to ask it :-)
I have a following code fragment:
public static void main( String[] args ) throws Exception {
PdfReader reader = new PdfReader("/tmp/input.pdf");
File tmpFile = File.createTempFile("tmp_stamper", ".pdf");
System.out.println("Reader page size " +
reader.getPageSize(1).getWidth() + "x" + reader.getPageSize(1).getHeight());
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(tmpFile));
System.out.println("Stamper Size " +
stamper.getWriter().getPageSize().getWidth() + "x" +
stamper.getWriter().getPageSize().getHeight());
Image img = Image.getInstance("http://kombajn.ath.cx/test.jpg");
img.setAbsolutePosition(0, 0);
for(int n = 1; n < reader.getNumberOfPages(); n++) {
PdfContentByte page = stamper.getUnderContent(n);
//
img.scaleAbsolute(stamper.getReader().getPageSize(n).getWidth(),
stamper.getReader().getPageSize(n).getHeight()); // THIS WORKS FINE
img.scaleAbsolute(page.getPdfDocument().getPageSize().getWidth(),
page.getPdfDocument().getPageSize().getHeight()); // THIS DOESN'T
page.addImage(img);
}
stamper.close();
reader.close();
}
The input focument /tmp/input.pdf is a simple PDF document with pages which
have 612x792 pixels (US Letter Portrait).
Question is: why page size retrieved from PdfStamper differes from page size
from the PdfReader? This code when run will output this:
Reader page size 612.0x792.0
Stamper Size 595.0x842.0
and the img.scaleAbsolute will not work correctly when the page size is
taken from the page.getPdfDocument().getPageSize() but it will work just
fine
when width and height is from the PdfReader? Why is that?
Thanks
Karol
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
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/