Headless, signal-based PDF viewer for Angular 21+, powered by pdfjs-dist — loaded from a CDN automatically, no separate install or wiring. No toolbar chrome, no NgModules — bring your own UI and get a fully typed, SSR-safe viewer API.
npm install @gavsby/ngx-pdf-viewerimport { Component } from '@angular/core';
import { PdfViewerComponent } from '@gavsby/ngx-pdf-viewer';
@Component({
selector: 'app-document-viewer',
standalone: true,
imports: [PdfViewerComponent],
template: ` <ngx-pdf-viewer [src]="src" (afterLoadComplete)="loaded($event)" (error)="failed($event)" /> `,
})
export class DocumentViewerComponent {
src = '/assets/document.pdf';
loaded(doc: unknown): void {}
failed(err: unknown): void {}
}- Lazy init via IntersectionObserver — pdf.js only loads when the viewer enters the viewport
- Fit modes —
page-width,page-height,page-fitplus manual zoom and original size - Rotation — rotate pages in 90° increments
- Text layer — selectable/searchable text
- Annotations & forms — configurable annotation display mode
- Password support — async
passwordProviderinput for encrypted documents - Search / print / download / outline APIs — programmatic control from the host component
- SSR-safe — the component no-ops on the server; safe for Angular Universal
Full guides and API reference: https://subedigaurav.github.io/ngx-pdf-viewer/
- Getting Started — install, host sizing, self-hosting pdf.js
- API Reference — every input, output and method
This is a pnpm workspace with two projects:
projects/ngx-pdf-viewer— the published library (@gavsby/ngx-pdf-viewer)projects/ngx-pdf-web— the demo + docs site, deployed to GitHub Pages
MIT