Topic: Convert a PDF to EPS with ruby
As part of my app I have to convert user uploaded PDF files to EPS files and would like to do it automatically using ruby.
Unfortunately the PDFs contain an embedded EPS which is mostly created using circa 1995 software and the our back-end graphics program (which uses it later on in a workflow) chokes when trying to read the old and busted output format of said 1993 software (the joys of text vector graphics files).
I have tried the following but none of them work to the level needed.
1. Shell out to Inkscape to convert from PDF to EPS
- Only works with Inkscape 0.47 r22583 (Apr 4 2010) or later version of Inkscape which is unavailable on our RHEL server. I could try compiling from source but that is a total nightmare so last option. Using an RPM from (For example) Fedora Core brings in a huge number of dependencies and just feels like it will break something.
2. Shell out to the GIMP
- Using script-fu in a command line prompt works but the output quality of the EPS is very low, much lower than an EPS from a working version of Inkscape
3. Use rcairo, Since Inkscape uses the cairo library and that library has ruby bindings why not just use them directly?
- As far as I can see rcairo is only for generating, it cannot open PDFs and I do not have the knowledge / time to import a PDF and get it outputting via the rcairo library.
4. Use pdf2ps then ps2eps
- ghostscript chokes when trying to read format
5. Use ImageMagick's convert function
- Also chokes when trying to read format (I think it uses gs from 4.)
6. use pdftops -eps
Using pdftops with the -eps parameter creates a 20mb eps file from a 50kb pdf file. More importantly it also ignores the viewport so imposition marks are copied.
If anyone has any advice I am all ears, so far is looks like compiling Inkscape from source but I know that that is going to be painful. Any other suggestions would be most welcome.
[Edit] It looks like I might be able to use poppler for reading and cairo for writing (Assuming I can get the gem dependencies sorted out). I am in unknown territory here so if anyone has some advice, experience or examples then I am still all ears.
Last edited by RurouniJones (2010-11-08 02:45:31)