Ryan Wexler wrote: > I am capturing images from a scanner and converting them into pdfs. I > am having a couple problems. > > The main issue is that when I add the image to the pdf the edges of it > go missing.
As far as I can see your image is bigger than your page. > The bottom edge of the image is missing. Oddly it seems as if an > empty area is appended to the top of the image. You're talking about the margin of the document, aren't you? > The right edge and > left edges are missing. Correct, the image is too large for the document. > Here is the code I am using: > PdfWriter.getInstance(document, > new FileOutputStream("c:\\testpdfimg.pdf")); > document.open(); > com.lowagie.text.Image itextimage = > com.lowagie.text.Image.getInstance("c:\\test.jpg"); > document.add(itextimage); > document.close(); You forgot to mention the line: Document document = new Document(); meaning you created an A4 page with margins of half an inch. Such a page is 595 x 842 pts. Your image is 636 x 877 pts. You have a 36pt margin, so you miss 842 - 36 - 877 = -71 and 595 - 36 - 636 = -77 So you are losing almost an inch in height, and over an inch in width. > Also when I tried creating the image directly from a BufferedImage > which I pull from the scanner without first saving it as a jpg like > so: > com.lowagie.text.Image itextimage = > com.lowagie.text.Image.getInstance(image, null); > document.add(itextimage); > > Then the size of the pdf is almost 10 times as large. Why is that? The number of pixels is different, isn't it? > Is there a way around it? Er... what is the question? (I'm sorry, but did you read any of the documentation?) -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php