pdf.js | PDF Reader in JavaScript | Document Editor library

 by   mozilla JavaScript Version: v3.7.107 License: Apache-2.0

kandi X-RAY | pdf.js Summary

kandi X-RAY | pdf.js Summary

pdf.js is a JavaScript library typically used in Editor, Document Editor, Nodejs applications. pdf.js has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can install using 'npm i pdfviewerjs' or download it from GitHub, npm.

PDF.js is a Portable Document Format (PDF) viewer that is built with HTML5. PDF.js is community-driven and supported by Mozilla. Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pdf.js has a medium active ecosystem.
              It has 42834 star(s) with 9427 fork(s). There are 1104 watchers for this library.
              There were 1 major release(s) in the last 12 months.
              There are 317 open issues and 8698 have been closed. On average issues are closed in 213 days. There are 19 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of pdf.js is v3.7.107

            kandi-Quality Quality

              pdf.js has 0 bugs and 0 code smells.

            kandi-Security Security

              pdf.js has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pdf.js code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pdf.js is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pdf.js releases are available to install and integrate.
              Deployable package is available in npm.
              Installation instructions are not available. Examples and code snippets are available.
              pdf.js saves you 1715 person hours of effort in developing the same functionality from scratch.
              It has 4117 lines of code, 0 functions and 352 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pdf.js and discovered the below as its top functions. This is intended to give you an instant insight into pdf.js implemented functionality, and help decide if they suit your requirements.
            • Calculate plural rules .
            • Compile a string to a program
            • Parse code .
            • Decode the scan data .
            • Create a bidi text
            • Read a CAM table .
            • Handle keydown event .
            • Computes the standard MD5 table .
            • Initalize the quad .
            • Returns a document from an arraybuffer .
            Get all kandi verified functions for this library.

            pdf.js Key Features

            No Key Features are available at this moment for pdf.js.

            pdf.js Examples and Code Snippets

            No Code Snippets are available at this moment for pdf.js.

            Community Discussions

            QUESTION

            Change the entry of the pdf file to pass the exact path to it by me
            Asked 2022-Apr-14 at 22:27

            I found this code which, you select a pdf file in an input, and it returns the number of pages it has. It turns out that with this way of reading pdfs is the only one I have found that reads absolutely all pdfs correctly.

            What I am trying to do is to isolate the code that reads the pdf file, so that I can pass it the path to the file instead of using the input. It is to then read all the files in a folder and display the total number of pages.

            But I can't figure out where exactly I would have to pass the path to the pdf file.

            ...

            ANSWER

            Answered 2022-Apr-14 at 20:32

            You can't.

            Browsers don't let you access local paths on a user's computer for security reasons.

            The browser doesn't get to know that the pdf is at /home/USERNAME/confidentialdocs/file.pdf, it just gets a data blob with a given filename.

            Source https://stackoverflow.com/questions/71877281

            QUESTION

            Using PDF.js to render to an offscreen canvas
            Asked 2022-Mar-23 at 19:45

            The goal is to render pages of a pdf to an offsrceen canvas to that I can copy portions of the page to a visible canvas. As a first step, the code below is intended to render the entire first page of a pdf. It renders to an offscreen canvas, then copies from offscreen to the visible canvas. Or that was my intention. Nothing appears.

            ...

            ANSWER

            Answered 2022-Mar-23 at 19:45

            The code below does what was intended. I am still uncertain why the original code fails to work. My best guess is that it's due to something being done asynchronously.There's very little that's different about the two implemenations aside from that.

            Source https://stackoverflow.com/questions/71578830

            QUESTION

            How to Display PDF File using Select Change Event with JQuery, Ajax and MVC
            Asked 2022-Mar-11 at 03:10

            I’m using a select dropdown to load pdf files from a folder in my ASP.Net MVC project which works without a hitch. What I’m trying to achieve now is to load a pdf file when a user clicks on a file from the dropdown and load it. I’m able to retrieve some of the needed data but am unsure on how to proceed to make it work using ajax. Any guidance would be much appreciated. Below is what I have done so far.

            ...

            ANSWER

            Answered 2022-Mar-11 at 03:10

            For rendering the updated html when ajax postback, you can use .html() in success function by default. You can see a simple example here. But in your scenario you use embed element, it can only be updated with src but cannot display the updated pdf by ajax. So I suggest use window.location.replace which can send a new request to backend and update the pdf.

            Source https://stackoverflow.com/questions/71430867

            QUESTION

            A-Frame + pdf.js: unable to update canvas texture twice, in VR mode only
            Asked 2022-Mar-05 at 14:51

            I am using A-Frame and pdf.js to create an application to view PDF files in VR. The application works as expected on desktop, including advancing to the next page of the PDF document and re-rendering to a canvas.

            When running in a browser in VR (tested with Quest 2), the first attempt renders as expected. However, when rendering a second document page to the canvas, the new image fails to appear unless exiting VR mode, at which point the new texture appears as expected.

            I have tried setting the associated material map.needsUpdate repeatedly (in an A-Frame component tick loop) to no effect. While experimenting, I also noticed that if you try to render a new PDF page a second time and then another page a third time (advancing by two pages while in VR mode), when exiting VR mode, only the texture from the second time appears; the data from the third render appears to be lost - I wonder if this is related to the primary issue.

            Code for a minimal example is below, and a live version is available at http://stemkoski.net/test/quest-pdf-min.html . When viewing the example in desktop mode, you can advance to the next page by opening the browser JavaScript console and entering testBook.nextPage(); and see that the image changes as expected. You can test in VR mode with a Quest headset; pressing the A button should advance to the next page.

            The question is: how can I render pages of a PDF document to the same canvas, multiple times, while in VR mode in A-Frame?

            ...

            ANSWER

            Answered 2022-Mar-05 at 14:51

            Found an answer here:

            requestAnimationFrame doesn't fire when WebXR is engaged

            Its quite relevant because pdf.js uses requestAnimationFrame by default when rendering the image onto the canvas.

            It can be toggled though - the pages render function has an option intent, which is later on used to determine whether to use requestAnimationFrame.

            The sources You use are slightly different (older?), but if you search for creating the InternalRenderTask in the render function of the ProxyPDFPage - it's all there:

            Source https://stackoverflow.com/questions/71344700

            QUESTION

            PDFJS: Get some unnecessary chunks with range request and make first page slow
            Asked 2022-Feb-21 at 02:38

            Configuration:

            • Web browser and its version: Chrome 97.0.4692.99
            • Operating system and its version: MacOS 10.15.5
            • PDF.js version: 2.12.313
            • Is a browser extension: no
            1. I use the range request to render pdf
            2. I get more chunks with this line of code await this.pdfManager.requestRange(ex.begin, ex.end);;
            3. These chunks are unnecessary when rendering first page;
            4. The program also seems to run fine when I comment this line of code, and I can get less chunks to make the first page faster;
            5. So what does this part of the code do?
            6. Is it possible not to execute it or not to use await?
            ...

            ANSWER

            Answered 2022-Feb-21 at 02:38

            In v2.12.313, PDFJS will check that the last page can be sucessfully loaded during document initialization, to ensure that numPages is correct, and fallback to walking the entire /Pages-tree. #14570

            Source https://stackoverflow.com/questions/70874224

            QUESTION

            Getting error while using pdf-viewer-reactjs module in Next.js
            Asked 2022-Jan-31 at 14:17

            I have used pdf-viewer-reactjs into my Next.js project. But getting following error.

            ...

            ANSWER

            Answered 2022-Jan-31 at 14:17

            I was able to run the following code successfully, however it requires additional steps

            1. Install the babel runtime - yarn add @babel/runtime - courtesy this post.
            2. Material UI icon gives an error, so similarly add the material UI dependencies

            Assuming this is what you want:

            Stackblitz - https://stackblitz.com/edit/nextjs-utkd32?file=pages%2Findex.js

            Source https://stackoverflow.com/questions/70923428

            QUESTION

            How to redirect to another page with passing data after submitting form in using react-router-dom v6?
            Asked 2022-Jan-25 at 12:11

            I'm trying to redirect to another page with passing data after submitting form in using react-router-dom v6. When I will click on submit, data will be submited and the application will take me to the "Download PDF" page, also the form data will pass registration page to the "Download PDF" page.

            Example Code:

            ConfirmRegistration.js

            ...

            ANSWER

            Answered 2022-Jan-25 at 11:53

            You can use useNavigate instead of using Navigate

            Source https://stackoverflow.com/questions/70848130

            QUESTION

            Build failing with cached npm after dependency updates
            Asked 2022-Jan-16 at 22:16

            I have a pipeline that does an npm install followed by angular build and recently I added a caching task to relieve installation which was working splendidly until the developer added a new private dependency of "runtime-config-loader": "^3.0.0".

            This may require npm re-install again, however, for some reason the caching task doesn't think it requires a re-install, and so it skips over the npm install and then fails at the angular build, most likely because npm did not re-install on the agent.

            I disabled the caching task and removed the custom condition eq(variables['CACHE_RESTORED'],False) from the npm install task, and the build is succeeding just fine.

            Why is the cache not recognizing the need to re-install dependencies again? and how do I delete the cache so that npm installs again? As a reminder, when I disable the cache task and npm re-installs again on the agent, the build succeeds - so this is certainly a caching problem.

            Here is the build YAML:

            ...

            ANSWER

            Answered 2021-Dec-11 at 12:12

            It doesn't work because the new dependency is obviously not in the cache. Also the npm install doesn't run. So that dependency is missing during build.

            To fix it, you need to always run the npm install, because you never know if there is a new dependency. Also, after install, if there were new dependencies installed, you should update the cache.

            Source https://stackoverflow.com/questions/70268726

            QUESTION

            pdfjs cannot use function 'getPageIterator'
            Asked 2021-Dec-18 at 01:54

            I am trying to follow the documentation for pdfjs found here https://www.pdftron.com/documentation/core/guides/features/manipulation/remove/ in an attempt to remove a page from a PDF I have uploaded to my html page. Here is my html code:

            ...

            ANSWER

            Answered 2021-Dec-16 at 02:56

            Mozilla led pdf.js is primarily a browser plugin pdf viewer, without editor functions.

            The function your calling doc.pageRemove(doc is for use with PDFTron webview / edit SDK and thus specific to that commercial JavaScript library.

            Source https://stackoverflow.com/questions/70372235

            QUESTION

            RewriteCond works on HTTP but not on HTTPS virtual host
            Asked 2021-Dec-06 at 16:01

            i want to rewrite all URLs with trailing ".pdf" to open the pdf-files in the mozilla.pdf.js and have successfully testet following RewriteRule and RewriteCond on my HTTP virtual host (I use apache2 on ubuntu server btw):

            example URL to rewrite:

            ...

            ANSWER

            Answered 2021-Dec-06 at 12:30

            example target URL after rewrite: http://example.com/libs/mozilla.pdf.js/web/viewer.html?file=/downloads/dir2/file5/test.pdf

            However, your directive does not currently do this. It redirects (not "rewrites") to http://example.com/libs/mozilla.pdf.js/web/viewer.html?file=downloads/dir2/file5/test - note the missing slash at the start of the file URL parameter value and the missing file extension.

            This might be working on one server and not the other if MultiViews is enabled on the former. (This effectively enables extensionless URLs to "work".)

            To correct the RewriteRule directive:

            Source https://stackoverflow.com/questions/70234441

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pdf.js

            You can install using 'npm i pdfviewerjs' or download it from GitHub, npm.

            Support

            PDF.js is an open source project and always looking for more contributors. To get involved, visit:. Feel free to stop by our Matrix room for questions or guidance.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/mozilla/pdf.js.git

          • CLI

            gh repo clone mozilla/pdf.js

          • sshUrl

            git@github.com:mozilla/pdf.js.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link