boazsegev / combine_pdf

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

ParsingError: Optional Content PDF - with some PDF files uploaded #230

Open MatteoVella opened 11 months ago

MatteoVella commented 11 months ago

After uploading some PDF files, during the process of combining two pdfs, the process crashes and returns the following error:

CombinePDF::ParsingError: Optional Content PDF files aren't supported and their pages cannot be safely extracted.

I attach below one of the files that returned the error: pdf_test.pdf

While other PDF files like the following completed the process without any errors: pdf_test_2.pdf

What could the error be related to?

MatteoVella commented 9 months ago

Hi @boazsegev, can you help me, please?

MatteoVella commented 9 months ago

Hi @boazsegev, any news from this issue?

Let me know, thanks

boazsegev commented 8 months ago

Hi @MatteoVella

Did you try allowing optional content (see Known Limitations)?

filename = 'pdf_test.pdf'
CombinePDF.load(filename, allow_optional_content: true).

For me it works fine once that option is enabled.

magnum commented 8 months ago

thank you @boazsegev we're using both methods

CombinePDF.load

to load file from a local path and

CombinePDF.parse

to load a file via http can we use allow_optional_content: true with both methods?

boazsegev commented 8 months ago

Yes, the extra options are passed through to the parse method.

Essentially load is just parse with an IO.binread.