npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ng-pdf-renderer

v2.0.0

Published

A modern, zero-configuration PDF viewer for Angular applications with auto-fit, text selection, and responsive design

Readme

ng-pdf-renderer

A standalone Angular PDF viewer powered by PDF.js, with navigation, selectable text, search, thumbnails, bookmarks, fillable forms, and password prompts.

Installation

npm install ng-pdf-renderer

Version 2.0.0 requires Angular ^22.2.1 and RxJS ^7.8.2. For earlier Angular versions, use a compatible previous release. Rendering requires browser DOM and canvas APIs. SSR and hydration support have not been verified.

Usage

import { Component } from '@angular/core';
import { PdfViewerComponent, type PdfOptions } from 'ng-pdf-renderer';

@Component({
  selector: 'app-document',
  imports: [PdfViewerComponent],
  template: `
    <ng-pdf-viewer
      [src]="source"
      [options]="options"
      (documentLoadError)="onError($event)"
    />
  `,
})
export class DocumentComponent {
  source: string | Uint8Array = '/documents/example.pdf';
  options: PdfOptions = {
    height: '600px',
    showControls: true,
    showThumbnails: true,
    showOutline: true,
  };

  onError(error: unknown): void {
    console.error('Unable to display PDF:', error);
  }
}

Serve the PDF at the specified URL, or pass its bytes as a Uint8Array. Cross-origin URLs must allow CORS. Replacing src loads a new document; replace the options object when changing settings. Each viewer maintains independent document and navigation state.

Options

| Option | Default | Description | | --- | --- | --- | | height | 500px | Viewer height | | width | 100% | Viewer width | | autoFit | true | Fit the first page's width to the container | | initialZoom | — | Initial scale; 1 means 100%. Disables auto-fit when set. | | initialPage | 1 | Starting page, clamped to the document's range | | showControls | false | Show the toolbar | | showNavigation | true | Show page navigation in the toolbar | | showZoomControls | true | Show zoom controls in the toolbar | | showRotationControls | true | Show rotation controls in the toolbar | | showDownloadButton | true | Show the download action in the toolbar | | showPrintButton | true | Show the print action in the toolbar | | showSearchBar | true | Show search in the toolbar | | showThumbnails | false | Open the page preview panel | | showOutline | false | Open the bookmark panel | | renderTextLayer | true | Render the text layer | | enableTextSelection | true | Enable selection; requires the text layer | | renderAnnotationLayer | true | Render links and form annotations | | renderForms | true | Enable interactive AcroForms; requires annotations | | workerSrc | Version-matched CDN URL | Override the PDF.js worker location |

Manual zoom disables auto-fit until the source or options change. Zoom supports 10–500%; auto-fit supports 10–300%.

Events

| Event | Value | | --- | --- | | documentLoaded | Loaded PDF.js document proxy | | documentLoadError | Load, navigation, rendering, or action error | | pageChange | Current page number |

Worker configuration

By default, the viewer loads a version-matched PDF.js worker from unpkg. This requires network access and permission under your application's Content Security Policy. To serve the worker locally:

Add this entry to your application's build.options.assets in angular.json:

{
  "glob": "pdf.worker.mjs",
  "input": "node_modules/pdfjs-dist/build",
  "output": "assets/pdfjs"
}

Add the initializer below to your existing app.config.ts providers:

import { ApplicationConfig, inject, provideAppInitializer } from '@angular/core';
import { NgPdfRendererConfigService } from 'ng-pdf-renderer';

export const appConfig: ApplicationConfig = {
  providers: [provideAppInitializer(() => {
    inject(NgPdfRendererConfigService).setConfig({
      workerSrc: new URL('assets/pdfjs/pdf.worker.mjs', document.baseURI).href
    });
  })]
};

This example is for browser applications. The relative URL respects the application's base path. If serving assets elsewhere, use that URL instead. No global viewer stylesheet is needed; the component owns its rendering styles.

The worker must match the installed PDF.js version. Configuration applies globally to PDF.js; configure it before loading a document. You can also set options.workerSrc for the viewer. All viewers must use a compatible worker.

Forms and passwords

Text fields, multiline fields, checkboxes, radio buttons, and choice fields are supported. Edits survive zoom, rotation, and panel changes, and are included in downloads and printing. Thumbnails refresh after edits. Set renderForms: false for a static view. Loading a different source clears the previous document's edits.

Encrypted documents prompt for a password, with retry and cancellation. Passwords are cleared on submission and are not persisted by the viewer.

Limitations

  • Search matches text within individual PDF text items. Cross-item matches, result counts, and next/previous result navigation are not supported.
  • XFA, signature editing or verification, PDF JavaScript, push-button actions, and comment editing are not supported.
  • Custom HTTP headers and credentials are not exposed by the loading API.
  • Visited page canvases remain in memory, so very large documents may use substantial memory.
  • Printing depends on the browser's PDF support. Automated browser coverage currently targets Chrome; other browsers, tagged-PDF reading order, and screen-reader accessibility need further validation.

For source setup, tests, and contribution guidance, see the GitHub repository.

License

MIT © askinjohn