Shiny display pdf file

2018/04/30

Categories: shiny Tags: html github JS

使用pdf.js来使用在web页面中阅读PDF文件,同时禁止下载、打水印的功能

PDF.JS

参考 PDF.js 在线pdf阅读插件(禁止打印,下载,每页水印)修改对应代码(JS/HTML)

shiny web

└── www
    └── pdfView
        └── generic
            ├── build
            └── web
                ├── cmaps
                ├── images
                └── locale
library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(
   
   # Application title
   titlePanel("pdf view"),
   
   # Sidebar with a slider input for number of bins 
   uiOutput("iframe_source")
)

server <- function(input, output) {
  output$iframe_source <- renderUI({
  iframe_source = tags$iframe(
    src=sprintf("pdfView/generic/web/viewer.html?file=../../0b781915c086876a5eac6b1b30ba0d18.pdf"),
                              height=800, width='90%')
  iframe_source
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

image-20180430085439710


项目git仓库地址