Pdf version information not correct using pdfbox

久未见 提交于 2019-12-13 10:16:59

问题


We are having a pdf which when opened in Acrobat Reader shows a version of 1.5 but when using Pdfbox(version 1.8.3) the version shows 1.3.

The code that we are using:

`aDocument.getDocument().getVersion()`

where aDocument is an instance of PDDocument. Pdfbox version we are using is 1.8.3

Any help regarding this will be highly appreciated.


回答1:


Hitesh Saliya already discussed that PDF in his question Adobe showing incorrect PDF Version (of PDF) in Properties. In this answer it became appearant that

  • version 1.3 was correct if one only takes the version header into account (there are no Version catalog entries in the document to consider);
  • at least version 1.5 was correct if one also took into account that object streams, cross reference streams, layers, and transparency are used.

In a way, therefore, both PDFBox and Adobe Reader are correct.

Thus, one first has to decide what one considers the version of a PDF document to be.

  • Is it the version the PDF file claims to be?

    As a special case, what about PDFs claiming different versions? E.g. different entries in header and catalog, or different entries in different incremental updates.

  • Is it the version a chosen indicator program (e.g. Adobe Reader in a fixed version) recognizes for the PDF?

  • Is it the smallest / the largest version according to the respective PDF reference/specification the PDF is valid?

    Could even any version in that range be a correct answer (resulting not in the version but the versions of a document)?

  • Some mixture of the above, e.g. the maximum of the version claimed and the lowest version according to which the PDF is valid?

Seriously, though, one can hardly expect anything more than option 1 to be implemented in a general purpose PDF library.



来源:https://stackoverflow.com/questions/27031917/pdf-version-information-not-correct-using-pdfbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!