Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'pos=': index out of range (RangeError) #1

Merged
merged 3 commits into from
Jun 22, 2023

Conversation

wakproductions
Copy link
Collaborator

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

funkypierre and others added 3 commits March 30, 2022 16:29
* introduce raise_on_encrypted option

* add some detail to the exception

* update the README to specify the raise_on_encrypted option

* 🔪 the CombinePDF.encrypted? method that is no longer needed

* apply patch from @kimyu92

* add guards

* docs + cleanup

* fix release date in changelog

* Adds Github Actions workflow for tests

- Allows us to test the gem on multiple versions of Ruby

---------

Co-authored-by: Levi Wilson <[email protected]>
Co-authored-by: Bo <[email protected]>
Co-authored-by: David Wessman <[email protected]>
@wakproductions wakproductions merged commit c64022e into master Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants