pdfjs icon indicating copy to clipboard operation
pdfjs copied to clipboard

The PDF version 1.5 can't read

Open kylinliang opened this issue 3 years ago • 3 comments

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?

kylinliang avatar Jan 09 '21 01:01 kylinliang

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?

rkusa avatar Mar 09 '21 12:03 rkusa

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 avatar Nov 27 '21 15:11 owen800q

@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.

rkusa avatar Dec 03 '21 08:12 rkusa