0

I am trying to convert this example pdf to png using the animation package the same way it´s done here Convert pdf to png in R

library("animation")
ani.options(outdir = "//Usuarios/Facturas")
pdf("Factura.pdf")
plot(1:10)
dev.off()
im.convert("Factura.pdf", 
           output = "Factura.png")

But I have this error:

Error

Same error than here: Error using magick R to import PDF but that solution makes reference to an external software that I don´t find in the original post (and I haven´t installed). I red that Ghostscript do what I want (pdf to png), but isn´t what animation package suppose to do?

Or I messed up my brain?

Thanks

Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
GonzaloReig
  • 77
  • 1
  • 6
  • [this](https://stackoverflow.com/questions/18617270/convert-pdf-to-png-in-r) might help. – heisenbug47 Jun 18 '19 at 12:31
  • This is the original post I said – GonzaloReig Jun 18 '19 at 12:33
  • If you do not have ImageMagick installed with Ghostscript delegate, then install it. If it is installed, then it could be an issue with the policy.xml file. See https://stackoverflow.com/questions/52861946/imagemagick-not-authorized-to-convert-pdf-to-an-image/52863413#52863413. – fmw42 Jun 18 '19 at 15:30

2 Answers2

0

The animation package uses ImageMagick for some of its features (which is why ImageMagick is listed as a system requirement in the manual). ImageMagick in turn apparently uses Ghostscript for PDF rendering. So yeah: the Ghostscript issues discussed here are certainly worth looking into.

Where's my towel
  • 561
  • 2
  • 12
0

Finally I found the answer with another package, I am gonna explain if someone need it.

library(pdftools)
library(magick)
fichero="Factura.pdf"
png= pdftools::pdf_convert(fichero, dpi = 600)
# And if someone want to read it
png2 = image_read(png)

This doesn´t save any file .png, which is a perfect solution for my situation.

GonzaloReig
  • 77
  • 1
  • 6