Migrating angular-pdf / pdf.js directives to modern Angular
angular-pdf rendered a PDF page on a canvas through the ng-pdf directive on top of pdf.js, with simple controls for page and zoom. It is tied to AngularJS.
What replaces it
| Option | When to choose it |
|---|---|
| ngx-extended-pdf-viewer | A full viewer with toolbar, search, thumbnails and printing, built on pdf.js. |
| pdf.js directly (pdfjs-dist) | When you only render pages to a canvas with your own controls, as angular-pdf did. |
| The browser's built-in viewer | Open the PDF in a new tab or an iframe when no custom interface is needed. |
How to migrate it
- Decide what users need: only viewing, or also search, printing, download and annotations.
- Load PDFs through HttpClient as a Blob or ArrayBuffer when the endpoint needs the authentication header.
- Lazy-load the viewer, so only users who open a PDF download pdf.js.
Watch out. pdf.js parses documents in a worker file that must match the library version exactly. Copy the worker as a build asset, set its path, and check it again after every upgrade.
Other libraries
Planning a migration or a micro-frontend platform?
In a 20-minute call you describe your situation and I tell you how I'd approach it. If it isn't worth doing yet, I'll say so.
Message me on LinkedIn