How to use Download Button in shiny with python reticulate?

HI everyone,

I'm building a shiny app and I have a "download button" ! I'm also using python from reticulate because I have a script that generate a PDF for me according to the generated charts in the app. The package I'm using to create the pdf is FPDF

Here is my function in R from python that create my pdf

 makePdf <- function(path){
     source_python("plots/create_pdf.py")
       pdf <- PDF()
       pdf$alias_nb_pages()
       pdf$add_page()
       pdf$plot_charts_field('farmer', 'region', 'produto')
       pdf$output(path + 'report/report.pdf', 'F')
   }

and here is my download button output

output$download <- downloadHandler('report.pdf', function() {
     makePdf(path)
   })

When I call the function the function "makePdf" I need to pass in the argument the path where the pdf will download and the user will choose the directory, but I don't know how to do that. Is it possible to do that? How could I do it?

1 Like

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