Cannot read property 'compressed' of undefined
See original GitHub issueWe ran into a pdfjs (v2.4.5) problem: https://github.com/nbesli/pdf-merger-js/issues/42
The following code-snipped…
const doc = new pdf.Document()
const src = await fs.readFile(path.join(FIXTURES_DIR, 'issue-42.pdf'))
const ext = new pdf.ExternalDocument(src)
doc.addPagesOf(ext)
const fileBuffer = await doc.asBuffer()
await fs.writeFile(path.join(TMP_DIR, 'Testfile_issue-42.pdf'), fileBuffer)
…results in this error:
TypeError: Cannot read property 'compressed' of undefined
at parseObject (node_modules/pdfjs/lib/object/reference.js:81:15)
at PDFReference.get [as object] (node_modules/pdfjs/lib/object/reference.js:15:17)
at Function.addObjectsRecursive (node_modules/pdfjs/lib/parser/parser.js:68:35)
at Function.addObjectsRecursive (node_modules/pdfjs/lib/parser/parser.js:84:18)
at Function.addObjectsRecursive (node_modules/pdfjs/lib/parser/parser.js:75:16)
at ExternalDocument.write (node_modules/pdfjs/lib/external.js:62:14)
Please find the problematic PDF file attached: issue-42.pdf
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
pdf-merger-js throws a TypeError and Fails - Stack Overflow
Uncaught TypeError : Cannot read property 'compressed' of undefined. and the merger would fail. I tried different versions of node with the ...
Read more >Examples
This tutorial shows how PDF.js can be used as a library in a web browser. examples/ provides more examples, including usage in Node.js...
Read more >Error loading PDF (Cannot read properties of undefined ...
Hi,. I'm trying the PDF Viewer to see if it suits the needs of our company and trying various PDFs, I have encountered...
Read more >Uncaught TypeError: Cannot read property 'messages' of ...
The error happens when the library `cv.jquery.validate` is added by BigPipe and compressed. I just disabled the library compressing in ...
Read more >split and merge pdf pages [36753526] - Issue Tracker - Google
TypeError : Cannot read property "0" from null. (line 50, file "Code") ... I believe it is in some type of compressed data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for the report! I looked into it and the cause of the issue seems to be that
pdfjsdoes not support hybrid-reference files. More specifically, the support for theXRefStmproperty of the trailer is not yet implemented. While it successfully falls back to the normale xref table (instead of the xref stream), the normal xref table is missing the object with the ID46, which is thus unknown and causes the error you’ve posted.Possible solutions:
XRefStmI don’t have the time right now to implement it, but I’ll keep it in the back of my mind.
Any suggested temporary fixes that we might be able to use to circumvent this error while the issue is waiting to be resolved?