Fix 'pos=': index out of range (RangeError) #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a problem with the CombinePDF gem. There's a document they are trying to print but the PDF files they uploaded have some formatting issues that is causing a problem in CombinePDF. When it's trying to combine the pages in the background it raises the error: /var/deploy/backend_app/shared/bundle/ruby/3.1.0/gems/combine_pdf-1.0.22/lib/combine_pdf/parser.rb:364:in 'pos=': index out of range (RangeError)
This problem as been identified as being a problem in CombinePDF 1.0.2.22+
boazsegev#205
A user submitted a PR to ignore the error, but it's been ignored by the project maintainer. This thread has been out there for over a year.
boazsegev#209
I am not an expert in the low level PDF byte specification, so I don't know specifically what's wrong with the stream in these files. I ran the file through the validator at https://www.pdf-online.com/osa/validate.aspx an it did not detect any issues.
I see the following possible solutions:
Try to fix the PDFs in production and reupload them. I can't guarantee that I can fix the stream problem in the PDFs, and whatever tool they used at Falcon to generate those problematic PDFs they will probably use again and it won't fix this as a recurring issue.
Downgrade to CombinePDF 1.0.21. Con: I don't know what features we would be missing in the latest version.
Fork the CombinePDF project and we maintain our own version of the gem with the patch.
Maybe there's another path to fixing this. Would like to hear your suggestions.
Please let me know how I should proceed.
#205 Parsing specific PDF in 1.0.21 - RangeError: index out of range (works in 1.0.20)
https://github.com/[boazsegev/combine_pdf](https://github.com/boazsegev/combine_pdf)|boazsegev/combine_pdfboazsegev/combine_pdf | Jan 19th, 2022 | Added by GitHub
#209 Swallow "index out of range" error
https://github.com/[boazsegev/combine_pdf](https://github.com/boazsegev/combine_pdf)|boazsegev/combine_pdfboazsegev/combine_pdf | Apr 5th, 2022 | Added by GitHub