Phantom JS path for Shiny server

The code below works fine in my RStudio viewer but it doesn't work on my shiny server, and I think that is because the installation of phantomjs, which is required to use webshot package in R. How can I set the path to install that? I tried this webshot::install_phantomjs(), but it did not work. It was installed in shiny server, but i think it was installed in the wrong path.

  output$savemapa <- downloadHandler(
    filename = 'mymap.png',
    content = function(file) {
      owd <- setwd(tempdir())
      saveWidget(mapa(), "temp.html", selfcontained = FALSE)
      webshot("temp.html", file = file, cliprect = "viewport", 
              zoom = 0.8, delay = 1)


1 Like

I am new in this community. I met the same problem you got 2 years ago about the phantomjs installation.
Did you find a solution ?
Thanks for your answer.

Hello, @thierry.zorn.

Unfortunately not. I gave up on downloading the map. :confused:

Hi, during this time, I got a solution, via my a platform administrator who contacted
Visit Add phantomjs for the webshot package · Issue #102 · rstudio/shinyapps-package-dependencies · GitHub...
From this, I wrote this small code which works (sorry, it's in french :slight_smile: ) :
May it help you

### vérification de l'installation de phantomJS
phantomjs_path <- webshot:::find_phantom()
if (is.null(phantomjs_path)){
    FlgJS <- F
} else{
    FlgJS <- T
phantomjs_path2 <- webshot:::find_phantom()
(FlgJS2 <- !(is.null(phantomjs_path2)))

EtatInstallationJS <- ifelse(isTRUE(FlgJS),
                            "1-PhJS déja installé",
                                   "2-PhJS vient d'être installé",
                                   "3-PhJS n'a pas été installé"))
1 Like