1234567891011121314151617181920212223242526272829303132333435 |
- <!DOCTYPE html>
- <html>
- <head>
- <script src="pdf.js"></script>
- </head>
- <body>
- <div id="pdfViewer"></div>
- <script>
- var pdfViewer = document.getElementById('pdfViewer');
- var pdfUrl = "E:\\pdf\\DM8_DIsql使用手册.pdf";
- PDFJS.getDocument(pdfUrl).then(function (pdfDoc) {
- var totalPages = pdfDoc.numPages;
- for (var i = 1; i <= totalPages; i++) {
- pdfDoc.getPage(i).then(function (page) {
- var canvas = document.createElement('canvas');
- pdfViewer.appendChild(canvas);
- var context = canvas.getContext('2d');
- var viewport = page.getViewport(canvas.width / page.getViewport(1.0).width);
- canvas.height = viewport.height;
- page.render({
- canvasContext: context,
- viewport: viewport
- });
- });
- }
- });
- </script>
- </body>
- </html>
|