boazsegev / combine_pdf

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

How to combine PDFs that have optional content? #199

Open amorimlucas opened 2 years ago

amorimlucas commented 2 years ago

I'm trying to combine multiple PDFs where one or more have optional content. When I try to do so, I get the following error:

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

Does anyone know of a way to combine PDFs with optional content? Thank you.

OlexYakov commented 2 years ago

You could have read the Known Limitations section.

Sometimes the CombinePDF will raise an exception even if the PDF could be parsed (i.e., when PDF optional content exists)... I find it better to err on the side of caution, although for optional content PDFs an exception is avoidable using CombinePDF.load(pdf_file, allow_optional_content: true).