Get the App
SLTechnology News&Howtos  ›  Development  › 

What does the pdf document open with

Shulou Source: shulou.com Published: 2022-06-03 10:59:59 11月15日 Update

This article will explain in detail what to open the pdf document with. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Pdf.js is an open source plug-in for reading and parsing pdf documents. It is said that it was born under html5 and is basically supported by mainstream browsers. The charm of the pdf.js framework is that browsers can support pdf.js without any local support for html5 (but for lower versions of IE, I'm sorry! ).

What does the pdf document open with

Pdf.js mainly contains two library files, one for pdf.js and one for pdf.worker.js, one for API parsing and one for core parsing.

What do pdf documents use to open pdf.js usage examples

First of all, take a look at a demo, this viewer, I think it is the final UI of PDF.js.

Reference code

1. The introduction of pdf.js,2. Parsing and reading pdf

FunctionshowPdf () {

PDFJS.workerSrc='../build/pdf.worker.js';// load Core Library

PDFJS.getDocument (url) .then (functiongetPdfHelloWorld (pdf) {

Pdf.getPage (1) .then (functiongetPageHelloWorld (page) {/ / get the first page of data

Varscale=1.5

Varviewport=page.getViewport (scale)

/ / PreparecanvasusingPDFpagedimensions

Varcanvas=document.getElementById ('the-canvas')

Varcontext=canvas.getContext ('2d')

Canvas.height=viewport.height

Canvas.width=viewport.width

/ / RenderPDFpageintocanvascontext

VarrenderContext= {

CanvasContext:context

Viewport:viewport

}

Page.render (renderContext)

})

})

}

3. Set the html label

Show pdf documents

Tags: Documentation support article official more core browser reference browsing good practical two mainstream events code content examples that is library files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL Shulou Tech Info MariaDB NVidia