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

vue-pdf-lite

v0.1.0

Published

Lightweight Vue 3 composable for exporting HTML to high-quality PDFs with smart pagination.

Readme

vue-pdf-lite

Lightweight Vue 3 composable for generating high-quality PDFs from HTML content with intelligent page breaks, customizable styling, and responsive design support.

Features

  • Smart Page Breaks: Intelligent pagination that respects content structure and prevents orphaned content
  • Customizable PDF Options: Control margins, font size, quality, and page orientation
  • Vue 3 Composition API: Clean, modern API using Vue 3 composables
  • Content Grouping: Automatic content sectioning for better page break handling
  • Multiple Output Options: Download PDFs or trigger print dialogs
  • High Performance: Optimized rendering with configurable quality settings
  • TypeScript Support: Full TypeScript support with comprehensive type definitions

Installation

# npm
npm install vue-pdf-lite

# yarn
yarn add vue-pdf-lite

# pnpm
pnpm add vue-pdf-lite

Don't forget to follow me on GitHub!

Basic Usage

<script setup lang="ts">
import { usePdfExport } from 'vue-pdf-lite'

const { handleExportPdf, loading, pdfSection } = usePdfExport()

const exportToPdf = async () => {
	await handleExportPdf({
		fileName: 'my-document',
		download: true,
		print: false, // Whether to open browser print dialog
		margins: [20, 20], // [marginY, marginX]
		fontSize: 16,
		fontFamily: "'Roboto', Arial, sans-serif",
		quality: 'balanced', // 'high' | 'balanced' | 'compressed'
	})
}
</script>

<template>
	<div>
		<button
			@click="exportToPdf"
			:disabled="loading"
			class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
			{{ loading ? 'Generating...' : 'Export PDF' }}
		</button>

		<!-- Content to be exported -->
		<div
			ref="pdfSection"
			class="pdf-content">
			<h1>My Document</h1>
			<p>
				This content will be converted to PDF with intelligent page
				breaks.
			</p>

			<h2>Features</h2>
			<ul>
				<li>Smart pagination</li>
				<li>Custom styling</li>
				<li>Responsive design</li>
			</ul>

			<table>
				<thead>
					<tr>
						<th>Feature</th>
						<th>Status</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>PDF Export</td>
						<td>✅ Available</td>
					</tr>
					<tr>
						<td>Print Support</td>
						<td>✅ Available</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</template>

Advanced Usage

Custom Export Options

<script setup lang="ts">
import { usePdfExport } from 'vue-pdf-lite'

const { handleExportPdf, loading, pdfSection } = usePdfExport()

const exportWithCustomOptions = async () => {
	await handleExportPdf({
		fileName: 'custom-document',
		download: true,
		print: false,
		margins: [30, 25], // [marginY, marginX]
		fontSize: 14,
		quality: 'balanced', // 'high' | 'balanced' | 'compressed'
		onSuccess: (blob) => {
			console.log('PDF generated successfully!', blob)
			// Handle the blob (e.g., upload to server)
		},
	}){}
}
</script>

Print-Only Mode

<script setup lang="ts">
const printDocument = async () => {
	await handleExportPdf({
		fileName: 'document',
		download: false,
		print: true, // Opens print dialog
	})
}
</script>

Using Custom PDF Section

<script setup lang="ts">
import { ref } from 'vue'
import { usePdfExport } from 'vue-pdf-lite'

const customPdfRef = ref<HTMLElement>()
const { handleExportPdf, loading } = usePdfExport()

const exportCustomSection = async () => {
	await handleExportPdf({
		fileName: 'custom-section',
		download: true,
		pdfSection: customPdfRef.value, // Use custom element
	})
}
</script>

<template>
	<div>
		<button @click="exportCustomSection">Export Custom Section</button>

		<div ref="customPdfRef">
			<!-- This specific content will be exported -->
			<h2>Custom Content</h2>
			<p>Only this section will be included in the PDF.</p>
		</div>

		<div>
			<!-- This content will NOT be exported -->
			<p>This content is outside the custom section.</p>
		</div>
	</div>
</template>

Page Break Intelligence

The library includes sophisticated page break logic:

  • Smart Heading Placement: H1 elements avoid being placed in the bottom 35% of pages
  • Widow/Orphan Prevention: H2-H5 elements avoid the last 15% of pages
  • Content Sectioning: Related content is grouped and kept together when possible
  • Table Handling: Large tables are split intelligently or moved to new pages
  • List Management: Lists are broken appropriately while maintaining structure

License

MIT License - see LICENSE file for details.

Author

safdar-azeem