pdf.js

Display embedded PDF in Internet Explorer 11 from binary string or base64

倖福魔咒の 提交于 2019-12-18 08:47:13
问题 There is a 3rd party service which sends me a PDF file in either binary string or base64 encoded. Is there any possibility to display the PDF embedded in IE 11 using either binary string or base64 encoded. From SO and other forums, I concluded that IE 11 supports data uri only for images and not PDF (I might be wrong) which rules out base64. So the only option left is to display from binary string. I am using it in a Node App but I do not have the option to first save the retrieved file to

Display embedded PDF in Internet Explorer 11 from binary string or base64

社会主义新天地 提交于 2019-12-18 08:47:04
问题 There is a 3rd party service which sends me a PDF file in either binary string or base64 encoded. Is there any possibility to display the PDF embedded in IE 11 using either binary string or base64 encoded. From SO and other forums, I concluded that IE 11 supports data uri only for images and not PDF (I might be wrong) which rules out base64. So the only option left is to display from binary string. I am using it in a Node App but I do not have the option to first save the retrieved file to

Use PDF.js offline

帅比萌擦擦* 提交于 2019-12-18 04:23:08
问题 Is it possible to use PDF.js without having the website online? I'm trying to do a simple offline website that reads pdf using pdf.js but it won't work without being online. Anyone could help? 回答1: Yes absolutely you can use it offline. Download the latest version here. Now extract the zip file and put it on a server(use xampp/wamp/lamp or any other localhost) because the worker is not enabled for file:// urls. To show the pdf files traverse to web/viewer.html from the localhost and it should

Cannot read property 'getContext' of null

夙愿已清 提交于 2019-12-14 02:18:25
问题 I have a button which on click executes this function.This code is to draw a line on canvas element on which PDF file gets rendered on a webpage by using PDF.JS. But i get an error "Uncaught TypeError: Cannot read property 'getContext' of null". What should i do. function abc() { alert("msg"); var c=document.getElementById("canvas1"); alert(c); var ctx= c.getContext('2d'); alert(ctx); ctx.beginPath(); ctx.moveTo(0,0); ctx.lineTo(300,150); ctx.stroke(); } 回答1: Firstly, you should check for

Importing PDFJS breaks TS application

房东的猫 提交于 2019-12-13 14:15:21
问题 So I'm creating an Angular 2 - typescript application and I want to be able to explore PDFs using Mozilla's PDFJS library. I have installed the depenedencies like so: npm install pdfjs-dist @types/pdfjs-dist --save Then in my app.modules.ts I attempt to import it like so: import { PDFJS } from "pdfjs-dist"; And I'm met with the following error when trying to run tsc I get the following output: src-ng/csm/app/app.module.ts(27,10): error TS2305: Module '"pdfjs-dist"' has no exported member

firefox hangs when displaying a pdf via data url

被刻印的时光 ゝ 提交于 2019-12-13 07:36:06
问题 I have an app which creates pdf in the browser using jspdf. I want to show this pdf in another tab/window. function open_data_uri_window(url) { var html = '<html>' + '<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style>' + '<body>' + '<p>new viewer</p>' + '<iframe type="application/pdf" src="' + url + '"></iframe>' + '</body></html>'; var a = window.open("about:blank", "Zupfnoter"); a.document.write(html); a.document.close(); } It works fine in

How to use full PDF.js viewer with toolbar in webpack and Vuejs?

痞子三分冷 提交于 2019-12-12 18:12:50
问题 I'm using a vue.js spa and webpack trying to show a PDF with mozilla's PDF.js. I got the examples working pretty easily but i struggle to get the full viewer with the toolbar working. I am requiring PDFjs with require('pdfjs-dist/webpack') so it doesn't send the "a fake worker has been set up" warning. I can't really find an SO question/guide or video that explains how to use the full viewer with webpack. The Documentation of this project is nearly non-existent either and i think i tried

Implementing pdf.js in android to read from sd card

孤者浪人 提交于 2019-12-12 15:27:49
问题 I'm trying to implement a pdf viewer for my android app which displays different pdf files which are present in the SD card. I am thinking of using the pdf.js library.I used the code sample as posted here: https://bitbucket.org/butelo/pdfviewer/ However, the library takes the pdf url in the javascript file which is relative address to the folder to which it belongs (/assets/pdfviewer). <script type="text/javascript"> var url = '../compressed.tracemonkey-pldi-09.pdf'; </script> How can I

Using pdf.js to display pdf from raw data

为君一笑 提交于 2019-12-12 07:43:17
问题 I am just getting started with pdf.js and I am trying to load a pdf file from the raw pdf data. I have seen the code: PDFJS.getPdf('cwpdf.pdf', function getPdfHelloWorld(data) { ... } But I am wondering if there is any way to load a pdf from the raw pdf data instead of from the filename. Is this possible? 回答1: I put together some complete code and was able to find the problem with the solution below: var int8View = new Uint8Array(...); //populate int8View with the raw pdf data PDFJS

No PDFJS.workerSrc specified

荒凉一梦 提交于 2019-12-12 07:26:27
问题 Trying to use PDF JS in a local Apache server and receiving the following error in console: Uncaught Error: No PDFJS.workerSrc specified This is very weird, because I'm following all that the examples specifies here http://mozilla.github.io/pdf.js/examples/. I have, in my main folder, a sample file called file.pdf and I'm just trying to display it. I did it by using a iframe with a file parameter: <iframe src="./web/viewer.html?file=http://localhost:99/PDF/arquivo.pdf" width="1800px" height=