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

@konsys.co/print

v1.1.0

Published

Template to generate printable preview page html in variety size

Readme

Print Page Preview

A template module to generate printable HTML pages of varying sizes.

Usage

import { PageTemplate } from "@konsys.co/print"

const pages = [
  { content: "<h1>Cover Page</h1>", customConfig: { pageSize: 'A4' } },
  { content: "Page 2", customConfig: { pageSize: 'A4LSC' } },
  { content: "Page 3", customConfig: { pageSize: 'A4LSC' } },
]
const pageTemplate = new PageTemplate(pages)
const html = pageTemplate.generatePrintablePage()

The above will generate 3 HTML pages:

  • The first page will be A4 portrait.
  • The next two pages will be A4 landscape.

API Reference

new PageTemplate(pages, options?)

Create a new printable page template.

Arguments

  • pages (Array):
    List of page objects, each with:

    • content: (string) HTML string for that page.
    • customConfig (optional):
      {
        pageSize: 'A4' | 'A4LSC' | 'A5' | 'A5LSC' | 'CUSTOM' | string,
        width?: number, // mm (required for CUSTOM)
        height?: number // mm (required for CUSTOM)
      }
      If omitted, the default size (or the value you pass to generatePrintablePage) is used for that page.
  • options (Object, optional):

    • title: (string) Sets the <title> of the HTML page. Default: 'No Title'.
    • heads: (string) Inject raw HTML into <head>. Useful for extra meta tags or styles.
    • styles: (string) Additional CSS styles to add.
    • fontFamily: (string) Font for all pages (default: Arial, Helvetica, sans-serif).
    • enableAutoPrint: (boolean) Whether to auto-invoke the browser's print dialog on load (default: false).

generatePrintablePage(defaultConfig?)

Generate the full printable preview HTML for your pages.

  • defaultConfig (Object, optional):
    Fallback config used for pages missing customConfig. Same structure as above.

  • Returns: (string) The assembled HTML document (including head, CSS, and page content).


Extended Example

import { PageTemplate } from "@konsys.co/print"

const pages = [
  { content: "<h1>Cover Page (A5 landscape)</h1>", customConfig: { pageSize: 'A5LSC' } },
  { content: "<div>Second Page (A4 portrait)</div>", customConfig: { pageSize: 'A4' } },
  { content: "<div>Third Page (custom 200x300mm)</div>", customConfig: { pageSize: 'CUSTOM', width: 200, height: 300 } }
]

const options = {
  title: "Document Example",
  heads: '<meta name="author" content="Your Name">',
  styles: "body { background: #eee; }",
  fontFamily: "Times New Roman",
  enableAutoPrint: true
}

const pageTemplate = new PageTemplate(pages, options)
const html = pageTemplate.generatePrintablePage({ pageSize: 'A4' })

// html can be directly written to a file or served for printing.

Notes

  • Each page can have its own size; if not specified, the default is used.
  • CSS for print and preview is included (outlines, margins, shadows, etc. for clarity).
  • With CUSTOM size, both width and height are required (in millimeters).
  • Use the styles option to add custom CSS to all pages.
  • The output HTML is a full document suitable for printing or PDF export.