-
Notifications
You must be signed in to change notification settings - Fork 153
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
Clarify error optional content #28
Comments
Some PDF files are designed to display different content according to the media on which they are displayed. For example, a PDF file might display one way when viewed on screen and it might replace some images or text when printed on paper... Just like some websites use the CSS media query. These PDF file required very specific instructions inside their structure. Ignoring these instructions might produce corrupted files or files that look very different than what you wanted them to look like. Because of the issues related with this structure, these files are not supported for now and cannot be merged with other PDF files.
|
What's the best way to rescue from this error? I tried wrapping my |
@andyrue , could you post your code you tried? The following should work (I think, I don't have a file to test with): filename = 'file.pdf'
begin
pdf = CombinePDF.load filename
rescue => e
puts "Couldn't load #{filename}: #{e.message}"
end |
Seems there was some ruby process stuck. I killed it with activity monitor and the |
Would you support a PR to add an option to ignore this error? For my use case I'd be happier with potentially weird output than no output at all, and when I've tested commenting out the |
Hi Joel, Thanks for asking. If the PR allowed this as a non-default option, yeah sure. I think it's better if the default would fail then to risk quite failures (missing data), but I definitely understand that different implementations might prefer a different behavior. P.S. If you're writing in a option flag to the existing API (i.e. |
Thanks for your quick response (and for the gem!) I've put something together and will create a PR :) |
Ran into this issue and found an odd solution using the libreconv gem. Essentially you convert the pdf to a pdf with libreoffice and this will make the pdf compatible with combinepdf. Hope this helps someone, took me hours to figure this out. Libreconv.convert(document_path, document_path) |
@chrisconcepcion - I'm struggling to get |
Try this: CombinePDF.load("your_file.pdf", unsafe: true, allow_optional_content: true) |
i get the following runtime error "Optional Content PDF files aren't supported and their pages cannot be safely extracted", this is a one off error and doesn't normally happen so looks to be pdf specific.
I've had a look at the code but can you quickly clarify the issue here for me please. Thanks.
The text was updated successfully, but these errors were encountered: