can't able to download pdf with knitr in shiny in R

I can't able to generate PDF report, By default it saving as HTML even after changing the format in .Rmd. I have given the code below which I used, Kindly help me to solve this.

I'm quite new to markdown and R in general.
I am posting here because google searches did not yield any solution regarding this.

Thanks in advance!

Server.R

shinyServer(function(input, output) {
 output$report = downloadHandler(
    filename ='my_report.pdf',
    
    content = function(file) {
      tempReport <- file.path(tempdir(), "test.Rmd")
      file.copy("test.Rmd", tempReport, overwrite = TRUE)
      
      library(rmarkdown)
      
      rmarkdown::render(tempReport, output_file = file,
                        params = input,
                        envir = new.env(parent = globalenv())
      )
    }
  )
 })

Ui.R

library(shiny)

shinyUI(basicPage(
 downloadButton('report')
))


test.Rmd

---
title: "Dynamic report"
output: pdf_document
params:
  n: NA
---

```{r}
# The `params` object is available in the document.
input$farmer_id

Hi, please can you format your post correctly ?

Thank you !

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