ropensci / rsvg

SVG renderer for R based on librsvg2
Other
95 stars 1 forks source link

exported pdf not opened by preview.app #22

Closed tbates closed 3 years ago

tbates commented 3 years ago
tmp = DiagrammeR::grViz('digraph{a->b; c->a; c->b; c->d;}') # make a graph
tmp = DiagrammeRsvg::export_svg(tmp) #export as SVG
tmp = charToRaw(tmp) # flatten
rsvg::rsvg_png(tmp, "g.png") # save as png in current working directory
rsvg::rsvg_pdf(tmp, "g.pdf") # save as pdf

preview.app says the pdf is damaged or in an unrecognised format

If you open the png, all is fine. And the pdf file shows a valid preview-image if you do quick-view in the Finder (on MacOS 11.2).

Not sure if this is an Apple Preview.app bug, or an rsvg pdf export problem, or something else.

Here's the miscreant file

g.pdf

jeroen commented 3 years ago

The code you give above seems to work on my mac. Are you using the latest version of rsvg?

g.pdf

tbates commented 3 years ago

Thanks for looking!

I'm on CRAN packageVersion("rsvg") [1] ‘2.1’

But the example pdf opens for you in preview.app, it may be a bug in preview Version 11.0 (1018.2)

Will pass on to Apple feedback.