Shiny app doesn't render PDF file from GitHub page.

I'm currently writing an R package that includes a Shiny app. I'm trying to include a PDF resource in the app and I found code on how to do that using 'tags$iframe'.

shiny::mainPanel(
      shiny::tabsetPanel(type = 'tab',
             shiny::tabPanel('Examples', tags$iframe(style = 'height:400px; width:100%; scrolling=yes', src = 'https://lucidviews.github.io/repvisforODK/docs/example_plots_repvis.pdf')))

As you can see in the code snippet I'm defining the src parameter with a link to my GitHub page. I do this because it ensures that I'm fetching the raw version of the PDF file. If you use the URL in browser everything can be accessed perfectly. However, my app doesn't show the document.

To reproduce the issue:

  1. Download the package from GitHub using
# install.packages("devtools")
devtools::install_github("lucidviews/repvisforODK")

or

go to lucidviews/repvisforODK: Generic R package to analyse ODK data (github.com) and download the ui.R, server.R and run_app.R files.

  1. Run the function run_app()
    (If you went for the second option in 1. you need to run the functions in the ui and server file first and then you can execute the function in run_app.R)

  2. Go to the second tab panel called '2. Select Visualisations'. Here you see that the PDF file is not displayed.

I'm thankful for any help (-:

Hi!

Right now, I can't go through the the suggested steps to reproduce the problem. However, here are 2 quick thoughts that may be useful:

  • If running the app on RStudio, be sure to open the app in a browser tab (not the viewer within RStudio).
  • Maybe I misread, but are there any reasons not to add your .pdf as an asset in the www folder (and then just reference it by its filename example_plots_repvis.pdf in the iframe tag)?

HTH


This post was published by an Appsilon team member. Our company can help you get the most out of RShiny and Posit/RStudio products.

Check our open positions here.

Appsilon: Building impactful RShiny Dashboards and providing R coding services.
Appsilon_GIFsmall_whitebg

Hey agus,

Thanks your swift reply!

Just opening the app in browser did the job for me... I could have known :see_no_evil:!

1 Like

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