views:

33

answers:

1

I am generating pdf using java and itext. When I add image that we used before in previous version of the pdf everything is fine. But when I replace it with the new one(they are both png-s) it corrupts the PDF(my PDF reader return "not a pdf or corrupted).
Are there any special things that must be set when saving the image? It gives me the same problem with jpg.

P.S. There are no exceptions thrown during the generation of the pdf.

UPDATE:
I finaly succeeded to add the image, but it was after decreasing the number of its colours. Also I am using iText 2.0.6 (by lowagie.com)

A: 

If you have Acrobat 9 Pro (or a trial thereof) you can run the PDF Syntax check. Advanced->Preflight... Profiles tab, "PDF analysis", "Report PDF syntax issues", then click "analyze" at the bottom of the dialog.

Can you share your PDF? I'd be happy to poke at it a bit. Opening a PDF in a text editor can be quite informative.

I suspect that an exception is being thrown, and silently caught, leaving your PDF in an Undefined State. Can your debugger turn any thrown exception into a breakpoint?

Also, what version of iText are you using?

Mark Storer
Please check the update.
Ilian Iliev
Ah... I don't think PNGs with alpha channels are supported (or at least weren't at that point, that may have changed). As such, iText probably _is_ throwing an exception that is silently caught. Something along the lines of "Hey, we don't support this". Finding out where it's caught would allow me to make sure this doesn't happen to the next person.
Mark Storer