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-document-reader

v0.3.4

Published

A standalone Angular component for rendering printable A4 documents with zoom, layout switch, custom header actions, and embedded font support.

Readme

NgDocumentReader

This project was generated using Angular CLI version 19.2.0. Here's how to do it:

Absolutely! Here's the updated README.md with the note that the component can receive custom Angular components like <app-btn> using the header-action slot:


# 📘 Ng Document Reader

**NgDocumentReader** is a standalone Angular component for rendering and printing styled HTML content as A4 documents (portrait or landscape). It includes zoom controls, layout switching, and print capabilities—perfect for dynamic, printable content like invoices, certificates, or formatted reports.

---

## 📦 Installation

Install via npm:

```bash
npm install ng-document-reader@latest

🧩 Usage

1. Import the Component

For standalone components:

import { NgDocumentReaderComponent } from 'ng-document-reader';

@Component({
  standalone: true,
  imports: [NgDocumentReaderComponent],
  templateUrl: './your-component.html',
})
export class YourComponent {}

2. Basic Example

<lib-ng-document-reader orientation="portrait">
  <div>
    <h1>Document Title</h1>
    <p>This is a paragraph inside the PDF-ready document.</p>
  </div>
</lib-ng-document-reader>

🔧 Input Properties

| Property | Type | Default | Description | |----------------|-------------------------------------|-------------|-----------------------------------------------------------| | orientation | 'portrait' | 'landscape' | 'portrait'| Page layout mode (A4 Portrait or Landscape) | | Zoom | number | 1 | Initial zoom level (from 0.1 to 2.0) |


🎯 Features

  • ✅ Zoom in/out the document
  • ✅ Set initial zoom level via input (Zoom)
  • ✅ Switch between portrait and landscape layouts
  • ✅ Print output with accurate colors (print-color-adjust: exact)
  • ✅ Inject custom controls using header-action slot
  • ✅ Supports Angular components in header-action (e.g. <app-btn header-action>)

🖨️ Print Styling

The component clones and prints the content with injected styles for accurate preview-to-paper matching.


💡 Custom Header Actions

You can pass in native HTML elements or Angular components using the header-action attribute:

<lib-ng-document-reader orientation="landscape" [Zoom]="1.2">
  <app-btn header-action></app-btn>

  <div>
    <h2>Document with Angular Button</h2>
    <p>This document includes a reusable button component in the header.</p>
  </div>
</lib-ng-document-reader>

You can also use native elements:

<lib-ng-document-reader orientation="portrait">
  <div header-action>
    <button (click)="exportToPDF()" class="btn btn-primary">Export</button>
  </div>

  <div>
    <h1>Report</h1>
    <p>Ready to print or export.</p>
  </div>
</lib-ng-document-reader>

🎨 Layout and Styling

  • A4 page sizes:
    • Portrait: 210mm width
    • Landscape: 297mm width
  • Content scales responsively using CSS transform: scale(...)
  • Zoomable from 0.1 to 2.0

🧪 Full Example

<lib-ng-document-reader orientation="landscape" [Zoom]="0.9">
  <app-btn header-action></app-btn>

  <div style="text-align: center">
    <h1 style="color: navy;">Invoice</h1>
    <p>Generated on {{ today }}</p>
    <table style="width: 100%; border: 1px solid #ccc;">
      <tr><th>Item</th><th>Price</th></tr>
      <tr><td>Angular Course</td><td>$50</td></tr>
    </table>
  </div>
</lib-ng-document-reader>

🛠️ Development

This component was built using Angular CLI version 19.2.0 and supports standalone components and typed Angular templates.


🧾© [tmBekzod]