Download Back To CSSScript.Com
Automatically fit HTML content to a single PDF page
1. Press Cmd+P (Mac) or Ctrl+P (Windows/Linux)
2. Select "Save as PDF" as the destination
3. Notice everything fits on ONE page!
Works seamlessly with Cmd+P / Ctrl+P. No custom PDF generation needed.
Automatically calculates content dimensions and sets optimal page size.
Unlike image-based solutions, text remains selectable and searchable.
Pure vanilla JavaScript. No jQuery, no frameworks, no bloat.
Only ~2KB minified. Won't slow down your page load.
Just call FitToPage.init() and you're done. Simple API.
<script src="fit-to-page.js"></script>
<script>
FitToPage.init({
selector: '.container',
margin: 10,
padding: 5,
orientation: 'auto',
debug: true
});
</script>