pdf.js

Troubles with pdf.js promises

和自甴很熟 提交于 2019-12-21 20:57:26
问题 I'm trying to implement a pdf word count in Javascript. I came across pdf.js which uses promises. Is there a way to wait till the script is done before returning the count? I know that this goes against the idea of promises, but the other js pdf readers out there either sometimes produce a bunch of gibberish or return nothing. In its current form the function always return a word count of 0. function countWords(pdfUrl){ var pdf = PDFJS.getDocument(pdfUrl); var count = 0; pdf.then(function(pdf

Displaying PDF on website using pdf.js

瘦欲@ 提交于 2019-12-21 17:22:24
问题 I want to put a file sample.pdf on my website, and want it to be displayed using pdf.js. What I want is to display my own file like the demo, with a toolbar, zooming in/out, etc. So far I can't do that yet. I did check out the helloworld example, but it simply shows the file like an image, without toolbar, zooming in/out, etc. When I put another file with many pages instead of helloworld.pdf , it just shows the first page. 回答1: I am not quite sure what you are looking for but I was able to

pdf.js failing on getDocument

霸气de小男生 提交于 2019-12-21 11:46:53
问题 browser: Chrome environment: grails app localhost I'm running a grails app on local host (which i know there's an issue with pdf.js and local file system) and instead of using a file: url which i know would fail i'm passing in a typed javascript array and it's still failing. To be correct it's not telling me anything but "Warning: Setting up fake worker." and then it does nothing. this.base64ToBinary = function(dataURI) { var BASE64_MARKER = ';base64,'; var base64Index = dataURI.indexOf

pdf.js failing on getDocument

房东的猫 提交于 2019-12-21 11:46:18
问题 browser: Chrome environment: grails app localhost I'm running a grails app on local host (which i know there's an issue with pdf.js and local file system) and instead of using a file: url which i know would fail i'm passing in a typed javascript array and it's still failing. To be correct it's not telling me anything but "Warning: Setting up fake worker." and then it does nothing. this.base64ToBinary = function(dataURI) { var BASE64_MARKER = ';base64,'; var base64Index = dataURI.indexOf

Links, Hyperlinks into a canvas using PDF.js

夙愿已清 提交于 2019-12-21 04:54:09
问题 I'm using PDF.js library to render a pdf into the canvas. That pdf has hyperlinks in there, The PDF.js library is drawing the pdf into the canvas but the hyperlinks doesn't work. Any Idea if it possible that hyperlinks works into the canvas? Thanks 回答1: Here is a fiddle that shows you how to enable annotations (including hyperlinks) in PDF files. The original PDF file used in the fiddle is here. I used viewer code (web/page_view.js,web/viewer.css) as refrence to write this fiddle. HTML: <

Is there a way to combine PDFs in pdf.js?

强颜欢笑 提交于 2019-12-21 04:12:46
问题 Well I want to combine existing pdf files in html5 using pdf.js and generate a single pdf out of them Is this possible and how can I do this? 回答1: Combining multiple documents and merely displaying them as one with pdf.js is easily possible - i just hacked the following example based on the simple prev/next viewer example that mozilla provides in their repository. // If absolute URL from the remote server is provided, configure the CORS // header on that server. // var urls = [ 'http:/

How to detect if pdf.js is *default* reader in firefox

旧街凉风 提交于 2019-12-19 20:48:23
问题 Since Firefox 19, there is an internal default PDF reader "pdf.js". How can I detect whether this is the reader by default? 回答1: This might be what you are looking for... http://www.pinlady.net/PluginDetect/PDFjs/ 回答2: This will test for it. I can't get to the other link due to corporate firewall. Dunno what it says. Maybe its the same. FIDDLE HERE <iframe src="some.pdf" id="iframe" name="iframe"></iframe> . // FireFox test for PDFJS to display PDFs. Works in 20 & 21. // If you don't test for

Open pdf.js with a data URL in IE11

痴心易碎 提交于 2019-12-19 09:27:24
问题 I'm trying to use pdf.js for showing a document in a data URL on IE10. That is, something like this. It works well with Firefox or Chrome, but in Internet Explorer 10 and 11, the interface is shown, but stays empty, and the document never loads. I checked, compatibility.js is included in the renderer page (viewer.html), so IE support should be present. EDIT: actually it's a security issue, as IE doesn't let to run a request of this type. Thanks in advance, 回答1: Ok, if someone runs to the same

How to improve display quality in pdf.js

≯℡__Kan透↙ 提交于 2019-12-19 02:17:06
问题 I'm using open source library for PDF documents from mozilla(pdf.JS). When i'm trying to open pdf documents with bad quality, viewer displays it with VERY BAD quality. But if I open it in reader, or in browser (drag/drop into new window), whis document displays well Is it possible to change? Here is this library on github mozilla pdf.js 回答1: Maybe it's an issue related with pixel ratio, it used to happen to me when device pixel ratio is bigger than 1 (for example iPhone, iPad, etc.. you can

PDF.js Inserting Images

蓝咒 提交于 2019-12-18 09:12:17
问题 I've started using PDF.js, an excelent work, by the way. But now I want to insert an image (from a canvas element) on the pdf page. Here's my code: var image = myCanvas.getContext('2d').getImageData(0,0,400,300), doc = new pdf(); doc.setProperties({ title: fileName, author: 'VirtuaLab®', creator: 'pdf.js' }); doc.addPage(); data = doc.output(); But I haven't found anything about inserting images on PDF.js pages. Maybe doc.image() or doc.addImage ? 回答1: Disclaimer: I work for Bytescout