2

I'm trying to deploy a Shiny app that allows the user to upload a pdf document and extract a table from a selected page. For this I'm using the package tabulizer. A basic reproducible example:

library(shiny)
library(tabulizer)

ui <- fluidPage(
  fileInput("report", NULL,buttonLabel = "Upload report"),
  numericInput("page","Specify page number",value = 1),
  actionButton("extract","Extract"),
  verbatimTextOutput("data")
)

server <- function(input, output, session) {
  generate_data <- reactive({
    req(input$report)
    # This locate_area function calls runApp() from the tabulizer package
    area <- locate_areas(file = input$report$datapath,
                         pages = input$page, 
                         widget = "reduced")  
    table <- extract_tables(file = input$report$datapath,
                            pages = input$page,
                            area = area)
    return(table)
  })%>% bindCache(input$page) %>% bindEvent(input$extract)
  
  output$data <- renderPrint({
    # Just for the sake of this example to show it works
    generate_data()
  })
}

shinyApp(ui = ui, server = server)

If I run this locally, the locate_area() will make the pdf page pop-up on my viewer in RStudio and all is well. However, if I publish the app it doesn't run after clicking the action button. I know the problem comes from the locate_area() as it essentially calls another runApp within the shiny app. I have tried using different widgets for locate_area() to no avail. Does anybody know a way to circumvent this issue?

1 Answers1

2

Judging by the relevant issues - issue 15 and issue 53 - it appears that your best way to go is really to copy the functionality from the original tabulizer function into your own app, as currently the package does not provide an easy integration with other Shiny apps.

giocomai
  • 3,043
  • 21
  • 24