Unable to download HTML file with images in R shiny app

I have an R shiny app which creates html output from R script code and displays the code in the browser. I have added functionality to download this html output file, and I am able to download the html using the downloadHandler however the downloaded file does not contain the image output.

Below is the R shiny app file

library(shiny)
library(shinydashboard)
library(prettyR)
library(R2HTML)
library(shinyAce)

ui <- fluidPage(
    dashboardPage(
        dashboardHeader(title = "App Demo"),
    dashboardSidebar(),
    dashboardBody(
            
            fluidRow(
                
                column(12, ####  Ui HTML Output  ----
                       htmlOutput('htmlOutput_1'), 
                       br(),
                       downloadButton(outputId = "downloadData",
                                      label ="Download Output",
                                      icon = shiny::icon("download"))
                        
                )
            )
            
        )
    )            
    
)



server <- function(input, output, session) {
    
    # Code to convert R code file to html output file
    R2html("code.R", "www/out_html.html",
           browse = FALSE, 
           title = " ",
           bgcolor="#FFFFFF", 
           split = FALSE)

    # To generate html output for browser 
    output$htmlOutput_1 <- renderUI({
        tags$iframe(
            seamless="seamless",
            src="out_html_list.html",
            height=600, width=635)
    })
    
    ## Download button Output ----

    output$downloadData <- downloadHandler(
        filename <- function() {
            paste("output", "html", sep=".")
        },
        
        content <- function(file) {
            file.copy("www/out_html_list.html", file)
        },
        contentType = "application/html"
    )
}

# Run the application 
shinyApp(ui = ui, server = server)

and below is the code.R in the same folder location

print("R Code")
print(head(pressure))
plot(pressure)#--FIG--

Can you suggest a way to download the html file including plot image output as well.

Thank you for your time.

Question on StackOverflow

Unable to download HTML file with images in R shiny app

This topic was automatically closed 54 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.