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

Trying to parse invalid object. #1274

Open
2 tasks done
Aizaz-ul-haq opened this issue Jul 15, 2022 · 3 comments
Open
2 tasks done

Trying to parse invalid object. #1274

Aizaz-ul-haq opened this issue Jul 15, 2022 · 3 comments

Comments

@Aizaz-ul-haq
Copy link

Aizaz-ul-haq commented Jul 15, 2022

What were you trying to do?

I am trying to merge three pdf files. one of these files (find the attached file) can not be parsed and keeps returning the following errors:

Trying to parse invalid object: {"line":2327,"column":6,"offset":396013}) Invalid object ref: 15 0 R Trying to parse invalid object: {"line":2424,"column":6,"offset":473052}) Invalid object ref: 417 0 R E:\Me\example-project\BackEnd\falaya-backend\node_modules\pdf-lib\src\core\errors.ts:26but got instance of ${actual ? actual.constructor.name : actual}; ^ Error: Expected instance of PDFDict, but got instance of undefined
The file is not encrypted, there could be some fields using x/y coordinates since it is being generated by a pdf signing software that could be causing this issue. but I am not sure.

The pdf file I am using is: pdf file

How did you attempt to do it?

document = await PDFDocument.load(document.buffer, { ignoreEncryption: true });

What actually happened?

I got the following errors:
Trying to parse invalid object: {"line":2327,"column":6,"offset":396013}) Invalid object ref: 15 0 R Trying to parse invalid object: {"line":2424,"column":6,"offset":473052}) Invalid object ref: 417 0 R E:\Me\example-project\BackEnd\falaya-backend\node_modules\pdf-lib\src\core\errors.ts:26 but got instance of ${actual ? actual.constructor.name : actual}; ^ Error: Expected instance of PDFDict, but got instance of undefined

What did you expect to happen?

Load the pdf and merge all the documents in a single pdf file.

How can we reproduce the issue?

Load the attached file.

Version

1.4.1

What environment are you running pdf-lib in?

Node

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

@pheidler
Copy link

A little late, but I was having the same issue and this appears to be the root cause: #623 (comment)

@davidstackio
Copy link

davidstackio commented Jun 16, 2024

The example pdf provided is encrypted. You can tell by the (SECURED) message when opening in a pdf reader app (not the browser). See: https://www.quora.com/How-would-I-know-if-a-PDF-document-is-password-protected

I'm having the same issue with my encrypted/secured pdfs.

Depending on your use case you may be able to use a fork of this repo as described here: #1616

Related comment: #1260 (comment)

@davidstackio
Copy link

Possible duplicate #1260

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

No branches or pull requests

3 participants