2

I've got a pdf figure with millions of semi-transparent points that I made in R. I want to flatten it to reduce filesize and then export it back out as a PDF (as a vector still, not a bitmap).

If there is a command line option, I can run it from within R using a system() call. Is there a way to do this?

generic_user
  • 380
  • 2
  • 5
  • 19
  • @Radu Not a duplicate. He wants to do this from within R. – Seth Nov 01 '13 at 15:16
  • @Seth I don't think there's as much focus on doing this from R as there is in whatever we suggest needing to be executable from the command line so that R could call it. The important bit that I missed before is that the they want the output to be a flattened vector. – Oli Nov 01 '13 at 15:18

1 Answers1

2

I would look at exporting from R in SVG (PDF will work, but SVG is easier to wrangle, being text based) and then run that through Inkscape.

Inkscape? A graphical application, Oli? Are you mad?

Actually Inkscape can be run from the command line to do batch operations. I use it like that on a server (called from Python) to generate PDF certificates for a client of mine. Here's its man page.

It's most comfortable with SVG. If your input is an SVG you can vacuum-defs and export as PDF in one swift motion.

Oli
  • 293,335