pdf.js

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

∥☆過路亽.° 提交于 2019-12-01 19:24:15
Since Firefox 19, there is an internal default PDF reader "pdf.js". How can I detect whether this is the reader by default? This might be what you are looking for... http://www.pinlady.net/PluginDetect/PDFjs/ 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 the browser ... // IE says PDFJS is there. It isn't. // Chrome hangs on the fiddle // Safari for Windows says

How can I get the current PDF page number from PDF.js iframe?

做~自己de王妃 提交于 2019-12-01 10:48:33
I have the viewer hosted on my local webserver and the iframe points and loads up the pdf. I then want to press a button that 'logs' the page number to a text file, I read this question and answer which seems to suggest you can use pdf.getPage to get the page number but how can i access the PDFJS when it is being ran from inside of the iframe? Thank you. var iFrame = document.getElementById('iframe_id'); if ( iFrame.contentDocument ) { currentPageNum= iFrame.contentDocument.getElementById('pageNumber').value; } alert(currentPageNum); This will access the iframe and then search the viewer.html

No PDFJS.workerSrc specified

僤鯓⒐⒋嵵緔 提交于 2019-12-01 02:31:08
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="900px" /> And now I'm trying to use the JavaScript API to display it. I'm trying to do: <!DOCTYPE html

how to correctly extract text from a pdf using pdf.js

这一生的挚爱 提交于 2019-11-30 14:44:38
I'm new to ES6 and Promise. I'm trying pdf.js to extract texts from all pages of a pdf file into a string array. And when extraction is done, I want to parse the array somehow. Say pdf file(passed via typedarray correctly) has 4 pages and my code is: let str = []; PDFJS.getDocument(typedarray).then(function(pdf) { for(let i = 1; i <= pdf.numPages; i++) { pdf.getPage(i).then(function(page) { page.getTextContent().then(function(textContent) { for(let j = 0; j < textContent.items.length; j++) { str.push(textContent.items[j].str); } parse(str); }); }); } }); It manages to work, but, of course, the

Highlight a section inside pdf using Pdf.js

被刻印的时光 ゝ 提交于 2019-11-30 13:34:43
问题 I'm currently using pdf.js for my project for rendering pdf Now there is this tricky task to highlight a section of pdf page given the co-ordinate example given a boundary section like [(31,35),(40,35),(40,40),(31,40)] I should highlight the given section with nay primary color of choice How to write a javascript to actually using pdf.js api to accomplish this task Is it possible or am I sounding over ambitions 回答1: One of the authors for PDF.js, cjones , has stated: No, and that’s

PDF downloading directly in Google Chrome — how to display in browser window instead? [closed]

我怕爱的太早我们不能终老 提交于 2019-11-30 13:10:44
I have been using Google Chrome and recently I have re-installed my browser. I found that whatever PDF links I open are directly downloading. However, I want them to be view on browser. How can I do this? Chrome is an updated version. For Chrome to open a PDF inline, in the browser window itself, several requirements have to be met, one for the browser itself, the other for the remote server offering the PDF: There must be a PDF viewer enabled for Chrome, either the external PDF.js one from Mozilla, or the native, builtin Chrome PDF viewer called pdfium (there are other plugins, such as the

How to render whole pdf document using pdf.js library?

纵饮孤独 提交于 2019-11-30 12:54:15
问题 I tried rendering PDF document using pdf.js library. I know only basics in javascript and I am new to promises, so at first I followed advice on this page: Render .pdf to single Canvas using pdf.js and ImageData (2. answer). But as a result, I rendered my document with all pages blank. All pictures and colors are fine, but not even a line of text. I also tried some other tutorials, but either I get the same result, or the document is completely missing. Right now, my code looks like this: (It

How to render whole pdf document using pdf.js library?

孤人 提交于 2019-11-30 04:02:50
I tried rendering PDF document using pdf.js library. I know only basics in javascript and I am new to promises, so at first I followed advice on this page: Render .pdf to single Canvas using pdf.js and ImageData (2. answer). But as a result, I rendered my document with all pages blank. All pictures and colors are fine, but not even a line of text. I also tried some other tutorials, but either I get the same result, or the document is completely missing. Right now, my code looks like this: (It's almost identical to the tutorial) function loadPDFJS(pid, pageUrl){ PDFJS.disableWorker = true;

PDF.js - Using search function on embedded PDF

亡梦爱人 提交于 2019-11-30 02:44:52
问题 I embedded a PDF using PDF.js with the iframe src=viewer.html?file=... tag. I'm using PDF.js and its viewer.html as it already provides a search function that I couldn't find in any other example. I would like the user to be able to click on a <td> and use the containing text to search the PDF and jump to the first occurence. JSFiddle: http://jsfiddle.net/agyetcsj/ HTML <div id="tableDiv"><table border="1" width="400px"><tr><td>6.5 Calling External Functions</td></tr></table></div> <iframe id

How to print pdf.js document?

柔情痞子 提交于 2019-11-29 21:41:21
问题 I've generated a document with pdf.js and it shows correctly. I'don't have print button. How to add the button to allow users to print it ? I was using Chrome. 回答1: Try using the javascript-function window.print(); , which opens the print-dialog. You will have to add an button to your html, which triggers the command - its not possible within the pdf. For this reason, you will need an iFrame, and use something like this: function printIt() { var wnd = window.open('http://your-pdf-url'); wnd