RStudio Connect Shiny downloadHandler works with HTML but not PDF

Hi all,

I'm running into an issue where my downloadHandler runs fine for both html and pdf outputs on my local server, and the html output works fine on my RStudio Connect Shiny app. But the PDF produces an error.

For reference here is my output, the params are unimportant I think but outputs include latex-friendly tables and ggplot based plots.

  output$report <- 
    downloadHandler(
      "results_from_shiny.pdf",
      content = 
        function(file)
        {
          rmarkdown::render(
            input = "report.Rmd",
            output_file = "report.pdf",
            params = list(DepthPlot = DepthPlot(),
                          RatePlot = RatePlot(),
                          CCFTbl = CCF(),
                          CCFPie = CCFPiePlot(),
                          AvgDepthRate = AvgDepthRate()),
            envir = new.env(parent = globalenv())
          ) 
          readBin(con = "report.pdf", 
                  what = "raw",
                  n = file.info("report.pdf")[, "size"]) %>%
            writeBin(con = file)
        }
    )

Here are the error messages I receive in the log:

image

And here is what the download shows in Google Chrome:
image

How can I circumnavigate this latex issue and allow users to download PDF reports?

Might be worth mentioning that the Shiny app itself works perfectly fine on Connect.

Thanks for any help or insight you can provide!

The problem is happening when trying to convert the LaTeX file into a PDF because the floatrow LaTeX package is missing. Chances are the server running the app is also missing other packages.

I'm not familiar with RStudio Connect. Hopefully somebody else or an RStudio rep can help with that.

Hi nwerth, thanks for the reply. On my local machine the PDF outputs fine. I imagine it has something to do with the available packages on the Connect server or an issue with PATH environments.

I'm unsure if this is the proper channel to ask about Connect-specific questions.

RStudio Connect makes sure that the R packages needed to run your content are available but does not make similar accommodations for TeX/LaTeX packages.

You will need to work with your systems administrator to configure LaTeX on the system running RStudio Connect. The floatrow package is usually contained in a distribution-specific package. Ubuntu has the texlive-latex-extra package. I don't have the Red Hat package handy.

Here is a related Community post discussing installing LaTeX on CentOS for use with RStudio Connect: Texlive distribution on centOS for RStudio Server and Connect

3 Likes

Hi Aron thank you for the advice, I have contacted my system admin and they have agreed to work on this in the meantime.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.