Carlos Cifuentes
AngularJS library migration · PDF viewing

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

OptionWhen to choose it
ngx-extended-pdf-viewerA 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 viewerOpen the PDF in a new tab or an iframe when no custom interface is needed.

How to migrate it

  1. Decide what users need: only viewing, or also search, printing, download and annotations.
  2. Load PDFs through HttpClient as a Blob or ArrayBuffer when the endpoint needs the authentication header.
  3. 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