前端利用pdfobject.js處理pdf文件

插件說明

插件pdfobject.js官方連接:https://pdfobject.com/瀏覽器

插件引入

a、建立盒子,能夠對個盒子example1經過style添加樣式dom

<style>
.pdfobject-container {
    height: 30rem;
    border: 1rem solid rgba(0,0,0,.1);
}
</style>
<div id="example1"></div>

b、引入插件url

<script src="js/pdfobject.min.js"></script>
<script>
    PDFObject.embed(
        "/pdf/sample-3pp.pdf",
        "#example1"
     );
</script>

初始化配置

PDFObject.embed(url [string], target [mixed], options [object]).net

a、url [string]即爲pdf的連接;
b、target [mixed] 指定dom節點;
c、options [object]初始化配置選項插件

  • page(初始化的時候跳轉到第幾頁)
  • id(給嵌入元素一個id值)
  • width(嵌入元素的寬度)
  • height(嵌入元素的高度)
  • fallbackLink(回調連接,在瀏覽器不支持的狀況下,給與一段提示文字和文件下載連接)
  • pdfOpenParams(容許使用adobe開放參數)
開放接口view:
基本參數: Fit
            FitH
            FitH, top
            FitV
            FitV, left
            FitB
            FitBH
            FitBH, top
            FitBV
            FitBV, left
  至此不在一一介紹:請查看文檔https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
  • PDFJS_URL(pdf.js的展現頁面連接)
  • forcePDFJS(是否容許整合pdf.js,true爲容許)

參考連接:
一、https://pdfobject.com/
二、pdf官方開放接口: https://www.adobe.com/content...
三、https://blog.csdn.net/badgirl...code

相關文章
相關標籤/搜索