Disoriented PDF Generation

Hello everyone,
I am facing some problem in generating pdf from the output. Lets have a look on my code.

pdfTitle<- as.character(format(Sys.Date(),"%A"))
  #Report generator
  output$export1 <- downloadHandler(
    #filename is a default argument of downloadHandler function. A string of the filename, including extension or a function that returns such a string..
    filename <- function() {
      paste("report-", Sys.Date(), ".pdf")
    },
    #content is a also default argument of downloadHandler function. A function that takes a single argument "file" that is a file path (string) of a nonexistent temp file, and writes the content to that file path. 
    content <- function(file) {
      tab <- tableGrob(mtcars)
      plot <- qplot(mtcars[1],mtcars[2])
      pdf(file, onefile = FALSE,title = pdfTitle,paper = "a4")
      #paste the saved reactive values as pdf grid. grid.arrange() function will manage the grids.
      grid.arrange(plot,tab)
      #Terminate the command
      dev.off()
    }
  )

This download handler should generate a pdf with a plot and a table. As I have mentioned onefile = False the pdf will generate two different pages for plot and and table. But it's not working. The pdf is looking like the photo below.

How can I solve the problem? Thanks in advance.

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