Comments (10)
Try this:
CombinePDF.load("your_file.pdf", unsafe: true, allow_optional_content: true)
from combine_pdf.
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.
On Sep 3, 2015, at 05:04, cw6365 [email protected] wrote:
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.
—
Reply to this email directly or view it on GitHub.
from combine_pdf.
Thanks for your quick response (and for the gem!) I've put something together and will create a PR :)
from combine_pdf.
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)
from combine_pdf.
What's the best way to rescue from this error? I tried wrapping my CombinePDF.load
command in a begin, rescue
but it hangs upon running.
from combine_pdf.
@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
from combine_pdf.
Seems there was some ruby process stuck. I killed it with activity monitor and the begin
rescue
works now. Thanks for your quick response!
from combine_pdf.
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 raise
my test PDFs look just terrific!
from combine_pdf.
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. CombinePDF.load file_name, unsafe: true
), it might be better to use a hash then a simple argument, allowing for future features and alterations.
from combine_pdf.
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 Libreconv.convert
to work with a .pdf to. .pdf. Getting an error about source file could not be loaded
. However, it works if I test with a .txt file to a .pdf.
Do you have any other tips you have for getting around this issue?
from combine_pdf.
Related Issues (20)
- How to PDF Encrypted Property Change ??
- LIbreOffice / Scribus & embedding fonts HOT 2
- Line break is not working HOT 1
- Parsing specific PDF in 1.0.21 - RangeError: index out of range (works in 1.0.20) HOT 5
- General PDF error - Combine PDF fails on specific PDF file HOT 1
- Seeking maintainers?
- How to use Arial black font in pdf?
- Fuzzer + various crashes
- SystemStackError: stack level too deep for docx file HOT 1
- Broken when parsing PDF with empty object
- Element missing error when rendering
- CombinePDF.parse is unable to process some PDF files
- Smart links are not updating or working in the combine process
- no implicit conversion of Symbol into Integer when using fonts()
- Combine many files at the same time and memory usage
- Web optimized PDFs improperly parsed
- center watermark HOT 1
- ParsingError: Optional Content PDF - with some PDF files uploaded HOT 5
- Couldn't connect reference
- paragraph text is collapsing when trying to combine file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from combine_pdf.