Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the pdf document open with

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report