Strange browser behavior with downloadButton

I am working in shinydashboard with a downloadButton and an DownloadHandler function to process a Rnw file and download a PDF. When I click on the downloadButton, Chrome opens up a blank window while the program is processing the Rnw file. I can click back on the main Dashboard window and see that hings are running.
This strange behavior appears to happen when the downloadButton is clicked.

Why is Chrome opening up a new window? (also, this is a new development. If only occurred once I completed developing the Rnw file.)

My code:
downloadButton (in the sidebar of the dashboard):

                             #Action Button
                               actionButton("profile","View Profile"),
                               #   actionButton("comparison","View Comparison"),  Disabled in V1
                               actionButton("contact","Contact SDO",onclick ="'', '_blank')") ,
                               downloadButton("outputPDF", label="Download PDF Report",
                               style="color: black; background-color: gray90; border-color: black")

The downloafHandler function:

#Event to output PDF documents

output$outputPDF <- downloadHandler(
    filename <- function() {
         paste0(input$unit," Community Profile Report ",as.character(Sys.Date()),".pdf")
    content <- function(file) {
      withProgress(message = 'Generating Report', value = 0, {  # Initialize Progress bar

      tempPDF <-  "SDO_Report.pdf"
      tempTex <- "SDO_Report.tex"
      tempReport <- "SDO_Report.Rnw"

      # Set up parameters to pass to Rnw document
      outChk <- input$outChk
      olistID <- idList
      olevel <- input$level
      ocurACS <- curACS
      ocurYr <- curYr
      placelist <- PlaceList
      #knitting file and copy to final document
      file.rename(tempPDF, file) # move pdf to file for downloading
      }) # Progress Bar 
    } #Content
) #Download Handler

Thanks in Advance,

One additional issue:
Chrome opens up a window with this address:

(the "/download/outputPDF?w=' portion is repeated each time. Locally, this has been accompanied with the following message:
This site can’t be reached
The webpage at might be temporarily down or it may have moved permanently to a new web address.

Again, this behavior is new.
Any ideas?

Hi @adambickford,

usually the message "This site can't be reached" is shown when something went wrong while preparing the output.
I think the best option is to debug your downloadHandler content part to show if there anything goes wrong.

Best regards

PS: I didn't see the use of withProgress() in a downloadHandler yet, are you sure this is working properly?

Hi SebastianVock,

The withProgress() displays the progress bar. I read here: that this can be placed in the content function without an issue.

I'll disable this and see what happens.

1 Like

That's really nice. Thank's for this hint.

Chrome is opening up a new window because the onclick parameter in the actionButton explicitly tells it to. Remove the '_blank' parameter and it will open in the same window.

Thanks Jason,
However, the issue is not with the actionButton (which is working as intended) but with the downloadButton. I think what is happening is that Chrome is displaying a blank window during the processing time. I'll need to revise the Rnw file so that it runs faster.