Category : pdf.js

I wanted to use pdf.js for a project of mine but I faced an issue of importing it, basically, the CDN doesn’t work Here is my code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/pdf.min.js"></script> </head> <body> <canvas id="my-canvas"></canvas> <script> pdfjsLib.getDocument(‘./ahmed.pdf’).then(doc => { console.log("this file has" + doc._pdfInfo.numPages); }); </script> </body> </html> and ..

Read more

I want to integrate pdf on my website with pdf.js from Mozilla GitHub : https://github.com/mozilla/pdf.js Demo : http://mozilla.github.io/pdf.js/web/viewer.html The problem is that there are some actions that I absolutely don’t want the user to do like print, upload a new document, or download the current document. When I directly delete the HTML code I have ..

Read more

I am trying to extract a jpg image from a pdf file. Please take a look at a reproducible example: https://codepen.io/thomas-kertsalis/pen/YzpYwYo?editors=1111 window.objs=[]; pdfjsLib.getDocument(sURL).promise .then(pdf => { for(var i=1;i<(pdf.numPages+1);i++){ pdf.getPage(i).then(function(page) { page.getOperatorList().then(function (ops) { for (var i=0; i < ops.fnArray.length; i++) { let currentElement=ops.argsArray[i]; if(ops.fnArray[i] == pdfjsLib.OPS.paintImageXObject) { window.objs.push(ops.argsArray[i][0]) let imageName=ops.argsArray[i][0]; page.objs.get(imageName, function(img) { const content ..

Read more

PDF.js getTextContent() is returning string values of multiple characters at times and I’m trying to discern why that is. I’ve been regularly crawling 90+ page pdfs getting text content with PDF.js with 99% of results being broken down into their individual characters (thank you Mozilla). let doc = await pdfjsLib.getDocument(name).promise; let numPages = doc.numPages; let ..

Read more

I’m trying to download the images of all pages of a PDF as soon as the user uploads it. I have the following code which allows uploading the picture and download starts when user manually clicks the download button, I want to automate it. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale ..

Read more