Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xref table not found at offset #507

Open
ndvo opened this issue Mar 16, 2023 · 2 comments
Open

xref table not found at offset #507

ndvo opened this issue Mar 16, 2023 · 2 comments

Comments

@ndvo
Copy link

ndvo commented Mar 16, 2023

I am getting an error parsing this file.
The xref table does exists. Maybe there are less strict rules to reaching it.

The error is:
PDF::Reader::MalformedPDFError Exception: xref table not found at offset ...

fail_to_parse.pdf

@paulsizer
Copy link

@ndvo Do you get anywhere with this? I have just got this error with a PDF I am trying to parse

@ndvo
Copy link
Author

ndvo commented Jul 26, 2024

Well my goal was rather limited. I was only parsing the PDF to check if it was protected or not.
I ended up adding a rescue for this exception and parsing the file with CombinePDF.
Something like this:

rescue ::PDF::Reader::MalformedPDFError => error
  if error.message.match(/xref table not found at offset/).present?
    pdf = CombinePDF::PDFParser.new(value.read, allow_optional_content: true)
    pdf.parse

    if pdf.root_object[:Encrypt].present?
      record.errors.add(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants