pdfjs
pdfjs copied to clipboard
The PDF version 1.5 can't read
Hello! I try to merge two pdf files, the pdf file version is 1.5. got error message "Expected compressed object stream". but when I try to merge other pdf file (version 1.3) that work fine.
What should I do to solve this problem?
This is probably not related to the version itself, but to the specific PDF file. Are you able to share the PDF file for testing?
Hi @rkusa
I got the same issue and incorrect header check exception thrown when merge 1.5 version PDF file on browser env
It should be caused by res = inflate(obj.content.content)
in lib/util.js
Could you help to troubleshoot with the sample below?
20211127195420058_GC000002593HK_c2d7fe5c-2e37-4fb9-809c-aac2a5018632 (4).pdf
@owen800q It looks like a specific issue with your example PDF. To make sure that it is not an issue with pako
(used for decompressing the data), I've also tried it with require('zlib').inflateSync()
and got the same error. The only reason I can think of that your PDF is broken is that it was explicitly saved as a text file. Eg. fs.writeFile(fileName, pdfString, 'utf8')
instead of fs.writeFile(fileName, pdfString, 'binary')
. Thanks for sharing the example.