调试PDF错误 [英] Debugging PDF for error

查看:589
本文介绍了调试PDF错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PDFClown java库创建PDF文件。



有时,使用Adobe Acrobat Reader打开这些文件时,会收到以下着名的错误消息:


此页面上存在错误,Acrobat可能无法正确显示页面,请联系创建PDF文档的人员以纠正问题。


只有在向下滚动到第8个页面时,才读取(使用Adobe)附件文件,然后滚动回到3'td页面。或者,缩小到33.3%也会产生消息。



只有为了记录,Foxit阅读器才能完美地读取文件,以及像浏览器这样的其他PDF阅读器。 / p>

我的问题是:


  1. 我的文件有什么问题? (附件


  2. 如何找到错误?有没有一个工具告诉你这个错误在哪里?


谢谢! / p>

解决方案

好的,这不容易 -



由于PDFC中的错误我的主要信息流在PDF页面已被损坏。
结束后,它有一个过去的实例的副本。
这导致了一个部分文本部分,没有启动命令BT - 在流结尾没有一个BT,留下了一个ET。



一旦我纠正了这一点,跑得很好。



感谢大家的帮助。
如果没有@Bruno建议的工具RUPS,那么调试时间会更加困难。



编辑:



该错误在Buffer.java:clone()(第217行)



而不是行:



clone.append(data);



需要:



clone.append(data,0,this.length);



如果没有这种修正,它会克隆整个数据缓冲区,并将克隆的缓冲区的长度设置为数据[ ]。长度。如果Buffer.length小于data []的长度,这是非常有问题的。
在我的情况下,结果是流中有垃圾。


I'm creating PDF files using PDFClown java library.

Sometimes, when openning these files with Adobe Acrobat Reader I get the famous error message:

"An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem."

The error shows while reading (with Adobe) the attached file only when scrolling down to the 8'th page, then scrolling back up to 3'td page. Alternatively, Zooming out to 33.3% will also produce the message.

Just for the record, Foxit reader reads the file flawlessly, as well as other PDF readers like browsers.

My questions are:

  1. What's wrong with my file?? (file is attached)

  2. How can I find what's wrong with it? is there a tool which tells you where does the error lie?

Thanks!

解决方案

Ok, this wasn't easy -

Due to a bug in PDFClown the my main stream of information in the PDF page has been corrupted. After it's end it had a copy of a past instance of it. This caused a partial text section without the starting command "BT" - which left a single "ET" without a "BT" in the end of the stream.

once I corrected this, it ran great.

Thank you all for your help. I would have much more difficult time debugging it without the tool RUPS which @Bruno suggested.

edit:

The bug was in the Buffer.java:clone() (line 217)

instead of line:

clone.append(data);

needs to be:

clone.append(data, 0, this.length);

Without this correction it clones the whole data buffer, and set the cloned Buffer's length to the data[].length. This is very problematic if the Buffer.length is smaller than the data[].length. The result in my case was that in the end of the stream there was garbage.

这篇关于调试PDF错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆