ngx-extended-pdf-viewer
Welcome to ngx-extended-pdf-viewer – a powerful, full-featured PDF viewer for Angular applications. Whether you're building enterprise tools or internal utilities, this library gives you the control and customization options you need, all while preserving a native-like viewing experience.
Built on Mozilla’s pdf.js and extended with dozens of enhancements, it's ideal for serious applications that demand more than just basic PDF display.

🚀 Getting Started
Prerequisites
⚠️ Versions 26 and later require Angular 19, 20, 21, or 22. If you're using Angular 17 or 18, please continue using version 25.6.4.
Why this breaking change? There are many reasons: Version 26 supports zone-less Angular and migrates to signals. And Angular 18 exited its Long-Term Support (LTS) phase, and security vulnerability CVE-2025-66035 will not be fixed in Angular 17 or 18. Updating to Angular 19 ensures your application continues to receive critical security patches.
In general, I aim to support the last four Angular versions (roughly two years of updates), but sometimes security requirements force me to raise the minimum version sooner.
📢 Version 32 is the last version to support Angular 19. Version 33 will require Angular 20 or newer. Angular 19 has reached its end of life, so security fixes for Angular, such as CVE-2026-69151 and CVE-2026-68945, aren't published for it anymore. Please plan your Angular update.
Is there a migration schematic? No - because migrating to ngx-extended-pdf-viewer shouldn't be a big deal. The library uses signals internally, but that hardly ever shows in your application, unless you're using @ViewChild to access properties of ngx-extended-pdf-viewer. Even then, solving the error messages should be easy. Adopting zone-less Angular was also surprisingly easy, at least in my showcase. I hope you'll experience a similarly smooth transition!
✅ Zoneless Angular Support (21 and 22)
ngx-extended-pdf-viewer fully supports zoneless change detection in Angular 21 and 22. The library works seamlessly in both zone.js and zoneless applications with zero configuration required.
Using Zoneless (the default in Angular 21 and 22):
Simply use the library as normal - it will automatically detect zoneless mode and trigger change detection appropriately. You'll have to use cdr.markForCheck() every once in a while, but I assume you're already familiar with that pattern.
Using Zone.js (Optional):
If you prefer to use zone.js in your Angular 21 or 22 application, add this to your app.config.ts:
import { provideZoneChangeDetection } from '@angular/core';
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
// ... other providers
],
};
Both modes are fully supported with the same API and features. See the changelog for details on the zoneless implementation.
Installation
Install via npm:
npm add ngx-extended-pdf-viewer
Peer dependencies:
| Package |
Version |
@angular/core |
>=19.0.0 <23.0.0 |
@angular/common |
>=19.0.0 <23.0.0 |
2. Usage in Your Angular Component
In your component HTML:
<ngx-extended-pdf-viewer [src]="'assets/example.pdf'"></ngx-extended-pdf-viewer>
For NgModule-based applications:
import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';
@NgModule({
imports: [NgxExtendedPdfViewerModule],
})
export class AppModule {}
For standalone components (Angular 19+):
import { Component } from '@angular/core';
import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';
@Component({
selector: 'app-pdf-viewer',
standalone: true,
imports: [NgxExtendedPdfViewerModule],
template: `<ngx-extended-pdf-viewer [src]="'assets/example.pdf'"></ngx-extended-pdf-viewer>`,
})
export class PdfViewerComponent {}
Or configure in main.ts for application-wide availability:
import { bootstrapApplication } from '@angular/platform-browser';
import { importProvidersFrom } from '@angular/core';
import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(NgxExtendedPdfViewerModule),
// other providers...
],
});
🧭 For hands-on examples and step-by-step guides, visit the showcase and the getting started page.
🔐 Security Notice
⚠️ Please use the latest 32.x, 31.x, 30.x or 29.x release (or the latest 28.x if you're staying on that line). Older versions are known to be vulnerable.
CVE-2026-16633 (high) - fixed in 28.1.1 and in 29.0.0-rc.3. A malicious PDF could run JavaScript in the context of your page. The flaw is in pdf.js 5.6.83 and newer, so every earlier 28.x release, and 29.0.0-rc.0 through rc.2, are affected - please update. Mozilla's fix landed in pdf.js 6.2.108; version 29 cherry-picked it, and since version 30 the bundled engine is 6.2.108, so it carries the fix natively.
This library ships enableScripting=false by default, unlike pdf.js itself, which limited the exposure - but not for the XFA part of the issue, so don't assume you were safe.
Since 28.1.2 the package also contains sbom.json (CycloneDX), vex.json and pdfjs-provenance.json. Because the patched engine keeps the version number of the pdf.js release it derives from, your dependency scanner would otherwise keep reporting this CVE; the VEX tells it the fix is already in.
CVE-2024-4367 (critical) - fixed in 20.0.2. Exploit via malicious PDF files. Thanks to GitHub users ScratchPDX and Deepak Shakya for reporting the issue promptly.
🧩 Core Features
- 🎨 Customizable toolbar and UI - Hide/show any button, customize layout
- 🔍 Advanced search capabilities - Find text, highlight all, multiple search terms, regex support
- 📝 Comprehensive form support - Standard and XFA forms with two-way data binding
- ✏️ PDF annotation and editing - Text, images, ink drawings, highlights, stamps, signatures
- 🔄 Page reordering - Drag and drop pages via thumbnails (v24.2+)
- 📊 Multiple viewing modes - Single page, book mode, infinite scroll, side-by-side
- 🎯 Zoom control - Programmatic zoom, fit-to-width/height, custom levels, pinch zoom
- 🗂️ Rich sidebar - Thumbnails, document outline, attachments, layers
- 🌍 Internationalization - Built-in support for dozens of languages
- 📱 Mobile optimization - Touch gestures, responsive design, mobile-friendly zoom
- 🖱️ Drag-and-drop support - Load PDFs by dropping files onto the viewer
- 🖥️ Fullscreen mode - Immersive viewing experience
- ♿ Accessibility - Keyboard navigation, screen reader support, focus indicators. Always a work in progress, never good enough, but a priority of mine!
- 🖼️ High-resolution rendering - Dynamically detects your browser's capabilities to unlock high zoom factors and crisp rendering of fine-grained PDF files
- 🎛️ Advanced JavaScript API - Popup positioning, custom find controllers, annotation events
- 🚀 Performance optimized - Canvas size detection, memory leak prevention, efficient rendering
- 🔗 Direct pdf.js API access - Full TypeScript support for low-level operations
- 🔒 Security features - CSP compatibility, XSS protection
Regarding security: I'm not perfect - it's always a best-effort approach without guarantees. I'm 100% committed, but I need your help, and even so, in the long run, errors are inevitable. The art is to close vulnerabilities before a hacker can exploit them - and that's a joint effort. Together, we'll manage. Don't hesitate to report bugs and vulnerabilities as soon as possible!
See the full list of features on the showcase site.
📦 Version Highlights
Version 32
Version 32 updates to pdf.js 6.5 in both bundles and lets you show several PDF viewers on the same page. It's the last version to support Angular 19.
New for end users:
- pdf.js 6.5: form scripts handle radio buttons and checkboxes correctly, multiline text fields no longer wrap text unnecessarily, encrypted PDF files with encrypted streams or metadata open correctly, and JPEG 2000 images decode faster.
- Smoother pinch zoom (#3069): the page follows the fingers without drifting, jumping or flashing, also in iOS Safari, and trackpad pinch zoom in Safari no longer zooms twice.
- Accessibility (#3304, #3310): screen readers announce the find result once and read the names of the dialogs, toggle buttons are visible in Windows high-contrast mode, book mode turns pages without animation when the operating system asks for reduced motion, and outline entries are big enough to tap.
- Dialogs and editor toolbars follow the viewer's theme instead of the operating system's dark mode, so they no longer show light text on a light background.
- Eraser: now it works on the whole page, on rotated pages and on restored drawings, too.
- Book mode fits into the viewer (#3316): with "page fit", the bottom edge of the book is no longer hidden behind a scrollbar, and a click on the corner of a page turns it reliably. The book is about 2% smaller than before. If you compare screenshots of book mode, update them.
New for developers:
- Several viewers on one page (#3306): each viewer shows its own document and keeps its own page, zoom, search, forms, editors and print job. Keyboard shortcuts and
window.print() act on the viewer the user clicked or focused last. pdfDefaultOptions apply to every viewer on the page, and all viewers share one theme.
[theme]="'auto'" (#3305) follows the operating system's dark mode and switches when the user changes it.
- Rendering in a background thread keeps the page responsive while a complex PDF renders. It's experimental and off by default; try it with
pdfDefaultOptions.disableWorkerRendering = false.
Deprecated:
- The iFrame work-around for several PDF files on one page. Use several
<ngx-extended-pdf-viewer> components instead.
IOSCanvasOptimizationService does nothing anymore.
Version 31
Version 31 updates to pdf.js 6.4 in both bundles.
New for end users:
- pdf.js 6.4: highlighting and drawing are built on Mozilla's reworked editors, a two-finger gesture pans the document while you pinch, large JPEG images need noticeably less memory, and PDF files with CMYK colors are rendered with color management.
- Eraser: erases parts of drawings and free-hand highlights. Contributed by legraina.
- Book mode: right-to-left books turn their pages from left to right, and zooming in keeps both pages side by side. Zoomed in beyond the page size, the viewer activates the hand tool, so a drag moves the page instead of turning it.
- Older browsers work again: browsers that need the legacy bundle now get the legacy worker and scripting sandbox, too (#3273).
- Accessibility: screen readers hear which editor is active and which panels and menu entries are switched on. Closing the find bar with Escape puts the focus back into the document.
New for developers:
[showEraserEditor], [disableEraserEditor] for the eraser, and [showUndoRedoButtons], [disableUndoRedoButtons] for undo and redo buttons, handy on tablets. Contributed by legraina. The undo and redo buttons are hidden by default (the 31.0.0 alphas showed them); [showUndoRedoButtons]="'xxxl'" shows them.
- Responsive visibility level
'xxxl': the button stays in the toolbar when it's at least 1000 pixels wide and moves to the secondary menu otherwise.
- Error card (#3241):
[showLoadingErrorMessage]="true" shows a translated error card when a PDF fails to load, and [loadingErrorMessage] replaces its headline. Contributed by Julian-B90. (pdfLoadingFailed) now fires once instead of twice.
iccUrl: the new default option pointing to the ICC color profile in the iccs folder of the assets (#3275). Thanks to 404mat!
NgxExtendedPdfViewerService.find() accepts a RegExp, [pageLabel] works on load, and deletePages() works again.
Bug fixes:
- Book mode opens at
[page] instead of on the cover, honors [enableFlipByDrag] and [showPageCorners] when they're set from the start, and the page layout buttons leave book mode again.
- Buttons disabled with
[disableZoomButtons], [disableSpreadButton] and the other [disable…] flags stay disabled after the document has loaded.
- XFA forms: check boxes and radio buttons are visible even with a CSS reset like
@tailwindcss/forms.
- The entries of the secondary menu are aligned again.
❗ Breaking changes: