Use the png driver to create a PNG file of acceptable resolution. Make your plot. Close the png device.
Then use readPNG from the package: png to read it.
Then open the PDF driver, create an empty area without borders and borders in (0,0) (1,1) and draw png with rasterImage. Add extra pages by creating new stories. Close the PDF driver.
This should give you a PDF version with raster versions of the graphs. There are a few tricky bits to set the graphics correctly, and the png resolution is crucial, but I think the above has all the ingredients.
> png("plot.png") > makeplot(100000) # simple function that plots 100k points > dev.off() X11cairo 2 > plotPNG = readPNG("plot.png") > pdf("plot.pdf") > par(mai=c(0,0,0,0)) > plot(c(0,1),c(0,1),type="n") > rasterImage(plotPNG,0,0,1,1) > dev.off()
Then check plot.pdf ...
source share