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())
      on.exit(setwd(owd))
      
      saveWidget(mapa(), "temp.html", selfcontained = FALSE)
      webshot("temp.html", file = file, cliprect = "viewport", 
              zoom = 0.8, delay = 1)
    }
  )

Thanks

1 Like

Hello,
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.
Thierry

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 shinyapp.io.
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
Thierry

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

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