开发者

Problem when try to add image to a pdf

开发者 https://www.devze.com 2023-01-20 09:41 出处:网络
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 corrupt

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 durin开发者_运维百科g 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)


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?


It looks like there was a problem with the current code. Lowering the number of the colors of the image solved the issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号