0

Is there any java library by which I can get a number of entries in the Xref Table of PDF?

Document.xref_length()

pyMuPdf has this, but I want it in java.

maester
  • 1
  • 2
  • In case of incremental updates, do you need the raw number of entries or the number where only one entry for each object number is counted? – mkl Feb 08 '22 at 07:48
  • Thanks, @mkl for replying. I just want the raw number of entries here. And also there will be no updates. – maester Feb 08 '22 at 08:39
  • Well, if there are no incremental updates, those two numbers will coincide... ok... – mkl Feb 08 '22 at 09:14
  • 1
    I had a look at iText and PdfBox. In either case you don't get the actual, raw number of entries. What you can get is information on how large it should be (according to the highest object number of the _valid_ cross reference entries or according to the **Size** entry in the trailer), on the number of found valid entries (after repairs if any), etc. – mkl Feb 08 '22 at 09:52
  • Why do you want to get those numbers? What if not a XREF was provided, but a XREFSTREAM? – PatrickF Feb 08 '22 at 11:12
  • That **Size** entry you find is from the trailer (or the cross reference stream dictionary) of a single revision PDF. And indeed, if the PDFs are completely valid in regard to this, that value also is the number of the cross reference table entries. But the OP didn't tell what they need that number for. And as you don't need it for PDF manipulation with PDF libraries (which usually handle the cross reference reading and writing under the hood), the OP might need this for special cases... – mkl Feb 09 '22 at 00:15

0 Answers0