These are the images, one of them is the background image, after doing some
processing, not done in this sample, we draw a logo and some text, in the
background image, and store it in png format, (image.png), then it's read
and converted to pdf as the simple example code show before, and then I get
the image.pdf.
You can view that some lines appear in the background image (gray rectables)
and in images draw over the background too.
I've used lastest version of iText now.
The code is something like:
//process background and draw elements inside
BufferedImage res=getImage();
//write to png file
try {
ImageIO.write(res, "PNG", new
File("c:"+File.separator+"image.png"));
} catch (Exception e) {
e.printStackTrace();
}
//get and store pdf
try {
com.itextpdf.text.Rectangle pageSize = new
com.itextpdf.text.Rectangle(267.7f, 167.2f);
Document document = new Document(pageSize);
PdfWriter.getInstance(document, new
FileOutputStream("c://image.pdf"));
document.open();
com.itextpdf.text.Image
img1=com.itextpdf.text.pdf.codec.PngImage.getImage("c://image.png");
img1.setAbsolutePosition(0, 0);
img1.scaleAbsolute(267.7f, 167.2f); // tried too with
convertBmp.scaleToFit same result
document.add(img1);
document.close();
} catch (Exception e) {
e.printStackTrace();
}
http://itext-general.2136553.n4.nabble.com/file/n4548445/image.pdf image.pdf
http://itext-general.2136553.n4.nabble.com/file/n4548445/image.png image.png
http://itext-general.2136553.n4.nabble.com/file/n4548445/background2.png
background2.png
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/PNG-to-PDF-creates-lines-around-boxes-automatically-tp4548343p4548445.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php