FitToPage.js: A 2KB JavaScript library that auto-fits HTML content to a single PDF page when you hit print.
Key features:
๐ Measures rendered content automatically
๐ฏ Injects custom page size through CSS
๐จ๏ธ Works with native Cmd+P browser print
๐ Preserves searchable text in output
โ๏ธ Configurable margins, padding, orientation
๐ Remeasure method for dynamic content
๐ชถ Zero dependencies, pure vanilla JS
Install via npm or CDN, call FitToPage.init(), and your print output fits perfectly on one page. Great for reports, dashboards, invoices, or any layout that needs clean single-page PDF export.
Check it out if you need reliable print-to-PDF without heavyweight libraries or server rendering.
๐ Blog Post
๐ [GitHub Repo](https://โฆ
FitToPage.js: A 2KB JavaScript library that auto-fits HTML content to a single PDF page when you hit print.
Key features:
๐ Measures rendered content automatically
๐ฏ Injects custom page size through CSS
๐จ๏ธ Works with native Cmd+P browser print
๐ Preserves searchable text in output
โ๏ธ Configurable margins, padding, orientation
๐ Remeasure method for dynamic content
๐ชถ Zero dependencies, pure vanilla JS
Install via npm or CDN, call FitToPage.init(), and your print output fits perfectly on one page. Great for reports, dashboards, invoices, or any layout that needs clean single-page PDF export.
Check it out if you need reliable print-to-PDF without heavyweight libraries or server rendering.
๐ Blog Post
๐ GitHub Repo
๐ Live Demo