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 🙏

© 2024 – Pkg Stats / Ryan Hefner

paginate-html-to-pdf

v1.1.5

Published

Render HTML to pdf with a nice pagination

Downloads

26

Readme

paginate-html-to-pdf

NPM version

Render an HTML page to pdf with a nice pagination:

  • header and footer generation
  • multiple page orientations and sizes in the same document
  • TOC generation from HTML headings (h1-h6)
  • smart page breaks (tries to keep related stuff in the same page)
  • custom CSS

TODO:

  • [ ] access to paginate options (max_overcut, force_cut_tag_names, ...)
  • [ ] access to TOC generation options
  • [ ] enhance TOC link precision from page to element

Getting started

Install:

npm install -g paginate-html-to-pdf

Run:

paginate-html-to-pdf my-document.html -o my-document.pdf

Run with custom CSS:

paginate-html-to-pdf my-document.html -o my-document.pdf -s my-document.css -s my-document-extra.css

Paper configuration, headers and footers

Headers and footers

By adding a <header /> and/or a <footer /> HTML element you set the current and next pages header and footer. You can change header and footer anywhere in your document.

You can refer to some variables:

  • {{ page }} is replaced by the current page number
  • {{ num_pages }} is replaced by the total number of pages

Example:

<header>
	<img src="top-logo.svg" />
</header>
<footer>
	{{ page }} / {{ num_pages }}
</footer>

Page orientation, size and numbering

Page orientation, size and numbering are controlled by adding the <header /> HTML element. You can change orientation, size and numbering as much as you want. Every occurence of a <header /> element implies a page break.

Example with default values:

<header page="1" paper="A4" paper-orientation="portrait" paper-margin="2cm">
</header>

The document defaults to:

  • paper: A4
  • paper-orientation: portrait
  • paper-margin: 2cm

Paper

paper can be one of:

  • A5
  • A4
  • A3
  • B5
  • B4
  • JIS-B5
  • JIS-B4
  • letter
  • legal
  • ledger

Or a custom size: width height.

Paper orientation

paper-orientation can be either portrait or landscape

Paper margin

paper-orientation can be either:

  • a single value: 2cm (2cm top, right, bottom and left)
  • a precise value: 1cm 2cm 3cm 25mm (1cm top, 2cm right, 3cm bottom and 2.5cm left)

Force page break

You can force a page break by adding a <hr/> element. Don't forget, every occurence of a <header /> element implies a page break.