boazsegev / combine_pdf

A Pure ruby library to merge PDF files, number pages and maybe more...
MIT License
733 stars 154 forks source link

HP Scan invalid Length workaround #215

Open mfazekas opened 2 years ago

mfazekas commented 2 years ago

Fixes: #191

It looks that some version of HP Scan produces invalid pdf files. Where the length value would point ot of the file.

8 0 obj
<</Length 2200
/Type
/Metadata
/Subtype 
/XML>>
stream
endstream
endobj

I've added a new relaxed: option to allow read such files. Not sure if it's any better than https://github.com/boazsegev/combine_pdf/pull/209. More complicated for sure. Also if we'd need the new option for this?

RBIII commented 2 years ago

Any idea when this might merge? I added it to my local and it seems to be working

juliolinarez commented 1 year ago

Works for me. Nice solution

osvaldoalvaradodev commented 1 year ago

Any idea when they merge into the main branch of this?

mfazekas commented 9 months ago

@boazsegev I've now rebased the pr to current master

boazsegev commented 9 months ago

Does this actually solve cases where Length is invalid but still within the file's range?

Wouldn't it be better to test for endsteam and if it's not there search for it while ignoring the Length data?

mfazekas commented 9 months ago

@boazsegev thanks much for looking into it.

I've updated my PR: