I'm generating a powerpoint presentation in R using officer
, and then converting this to a PDF so a user can preview slides inside the shiny golem app. But after referencing this thread and this SO answer to a similar question I'm still not quite sure how to accomplish this. I am able to display external PDFs located in inst/app/www inside an iframe, but not sure how to do this for PDFs generated inside the app itself.
Here is the relevant code snippet from my app_server.R file:
output$preview <- renderUI({
# Creates rpptx object with one slide
preview_rpptx <- add_title_slide(x = NULL, title = input_list[["title"]])
# Creates www/ directory if it doesn't exist
if (!dir_exists("www")) dir_create("www")
# Generates .pptx file
pptx_file_path <- file_temp("preview", tmp_dir = "www", ext = ".pptx")
print(preview_rpptx, pptx_file_path)
# Converts .pptx to .pdf
pdf_file_path <- file_temp("preview", tmp_dir = "www", ext = ".pdf")
convert_to_pdf(path = pptx_file_path, pdf_file = pdf_file_path)
tags$iframe(style = "height:600px; width:100%", src = str_sub(pdf_file_path, 5))
}
Running the app, I get a "Not Found" error inside the iframe. But I can see that the PDF file was generated properly in the www/ directory.