pdf-lib: Trying to parse invalid object
When I open my beautiful PDF with this lib, all is great. But because the file is big, I compressed it using smallpdf.com, and now when I open the compressed version, I get these warnings:
Trying to parse invalid object: {"line":140,"column":0,"offset":33170})
Invalid object ref: 9 0 R
Trying to parse invalid object: {"line":301,"column":0,"offset":65943})
Invalid object ref: 21 0 R
Trying to parse invalid object: {"line":309,"column":0,"offset":65969})
Invalid object ref: 22 0 R
Trying to parse invalid object: {"line":317,"column":0,"offset":65995})
Invalid object ref: 23 0 R
Any idea why? Is this an issue if I just use drawText
?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (6 by maintainers)
@yakupteke did you read this thread?..
Hi @Hopding, do you mind reopening this issue?
I am on
"pdf-lib": "1.16.0"
and I am still seeing this problem (even for non encrypted PDFs).Thank you.
@antoinerousseau Version
1.4.1
is now published. It contains the fix for this issue (@yakupteke it will hopefully fix your issue as well). The full release notes are available here.You can install this new version with npm:
It’s also available on unpkg:
As well as jsDelivr:
Still getting this error. I’m on latest (1.11.2)
Link for the PDF file: https://www.icloud.com/iclouddrive/0de0B7Vuvr6gTeYYAn4c9GC_Q#large
Errors:
Haha, indeed. They are useless as far as I can tell. Though, even if they aren’t, smallpdf.com could eliminate the extra whitespace in them. But they only contribute a few bytes to the total size of the document, so I guess it’s probably more effort than its worth for them.
@Hopding hi, I use
"pdf-lib": "^1.17.1",
in puppeteer,page.pdf([options]
returns: <Promise> Promise which resolves with PDF buffer.error log:
I’m not sure if this is a bug or a concurrency problem, it’s not necessary, I found it in the error log, I look forward to your help, thank you very much
@deammer It looks like the problem you’re encountering is due to the fact that your PDF is encrypted.
pdf-lib
does not currently support encrypted documents.Just to be clear, when I run the following script:
It produces the following output:
Notice the encryption error. The
ignoreEncryption
flag is explained here. It doesn’t actually do anything but suppress the error. I only added it to the library for backwards compatibility reasons. In hindsight it probably should not have been added.