pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Lehmkuehler <andr...@lehmi.de>
Subject Re: FW: Need Solution to Add Image file in PDF with PDFBox
Date Tue, 14 Feb 2012 19:29:44 GMT
Hi,

Am 14.02.2012 14:38, schrieb Manoj Patel:
>
> Hi,
>
> I am trying to add image file in PDF with PDFBox but it's not display proper image for
testImage.png and it's working fine for test.png file.
>
> Both files having transparent background so why one is working and another is not working.
>
> I had built new pdfbox and fontbox jar from svn.
>
> Please suggest solution for the problem.
>
> I have shared document at https://skydrive.live.com/?sc=documents&cid=c420713a859e927d#cid=C420713A859E927D&id=C420713A859E927D%21109
>
> Please see two pdf files (NEWVERSION.pdf and NEWVERSION2.pdf) so you can get the problem.
I have used AddImageToPDF.java file to
> add Image in PDF.
Seems to be a problem with your png. I got the following trace when I try to 
load the image using ImageIO:

java.io.UTFDataFormatException: malformed input around byte 785
	at java.io.DataInputStream.readUTF(DataInputStream.java:612)
	at javax.imageio.stream.ImageInputStreamImpl.readUTF(ImageInputStreamImpl.java:309)
	at 
com.sun.imageio.plugins.png.PNGImageReader.parse_iTXt_chunk(PNGImageReader.java:443)
	at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:652)
	at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1314)
	at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1601)
	at javax.imageio.ImageIO.read(ImageIO.java:1400)
	at javax.imageio.ImageIO.read(ImageIO.java:1286)
	at 
org.apache.pdfbox.examples.pdmodel.AddImageToPDF.createPDFFromImage(AddImageToPDF.java:84)
	at org.apache.pdfbox.examples.pdmodel.AddImageToPDF.main(AddImageToPDF.java:127)
javax.imageio.IIOException: Error reading PNG metadata
	at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:695)
	at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1314)
	at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1601)
	at javax.imageio.ImageIO.read(ImageIO.java:1400)
	at javax.imageio.ImageIO.read(ImageIO.java:1286)
	at 
org.apache.pdfbox.examples.pdmodel.AddImageToPDF.createPDFFromImage(AddImageToPDF.java:84)
	at org.apache.pdfbox.examples.pdmodel.AddImageToPDF.main(AddImageToPDF.java:127)
Caused by: java.io.UTFDataFormatException: malformed input around byte 785
	at java.io.DataInputStream.readUTF(DataInputStream.java:612)
	at javax.imageio.stream.ImageInputStreamImpl.readUTF(ImageInputStreamImpl.java:309)
	at 
com.sun.imageio.plugins.png.PNGImageReader.parse_iTXt_chunk(PNGImageReader.java:443)
	at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:652)
	... 6 more


Maybe you should convert your image to jpg and retry the whole thing.

> Regards
> Manoj


BR
Andreas Lehmkühler

Mime
View raw message