Install using your preferred package manager:
npm install @encryptioner/html-to-pdf-generatorpnpm add @encryptioner/html-to-pdf-generatoryarn add @encryptioner/html-to-pdf-generatorNo additional dependencies required:
npm install @encryptioner/html-to-pdf-generatorimport { generatePDF } from '@encryptioner/html-to-pdf-generator';npm install @encryptioner/html-to-pdf-generatorimport { usePDFGenerator } from '@encryptioner/html-to-pdf-generator/react';The library supports React 18 and 19.
npm install @encryptioner/html-to-pdf-generator<script setup>
import { usePDFGenerator } from '@encryptioner/html-to-pdf-generator/vue';
</script>Requires Vue 3.0 or higher.
npm install @encryptioner/html-to-pdf-generator<script>
import { createPDFGenerator } from '@encryptioner/html-to-pdf-generator/svelte';
</script>Supports Svelte 4 and 5.
The library bundles its core dependencies:
- jsPDF (^2.5.2) - Bundled
- html2canvas-pro (^1.5.8) - Bundled with OKLCH support
No peer dependencies required for vanilla JavaScript usage.
For framework adapters:
{
"react": "^18.0.0 || ^19.0.0", // For React adapter
"react-dom": "^18.0.0 || ^19.0.0", // For React adapter
"vue": "^3.0.0", // For Vue adapter
"svelte": "^4.0.0 || ^5.0.0" // For Svelte adapter
}Verify installation:
import { generatePDF } from '@encryptioner/html-to-pdf-generator';
console.log('Package installed successfully!');The package includes TypeScript definitions out of the box.
Ensure your tsconfig.json includes:
{
"compilerOptions": {
"moduleResolution": "bundler", // or "node16"
"types": ["@encryptioner/html-to-pdf-generator"]
}
}No additional configuration needed:
// vite.config.js
export default {
// Works out of the box
};No additional configuration needed:
// webpack.config.js
module.exports = {
// Works out of the box
};For Next.js App Router:
// next.config.js
module.exports = {
// Mark as client-side only if needed
};Then in your component:
'use client';
import { usePDFGenerator } from '@encryptioner/html-to-pdf-generator/react';For Nuxt 3:
<script setup>
import { usePDFGenerator } from '@encryptioner/html-to-pdf-generator/vue';
</script>For quick prototyping, use via CDN:
<!DOCTYPE html>
<html>
<head>
<script type="module">
import { generatePDF } from 'https://cdn.jsdelivr.net/npm/@encryptioner/html-to-pdf-generator/+esm';
window.generatePDF = generatePDF;
</script>
</head>
<body>
<div id="content">
<h1>Hello PDF</h1>
</div>
<button onclick="generatePDF(document.getElementById('content'), 'doc.pdf')">
Download
</button>
</body>
</html>If you see "Module not found" errors:
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm installIf TypeScript doesn't recognize types:
# Restart TypeScript server
# VS Code: Cmd/Ctrl + Shift + P → "TypeScript: Restart TS Server"If you see peer dependency warnings for frameworks you're not using, you can safely ignore them. The library only requires peer dependencies for the specific adapter you're using.
npm list @encryptioner/html-to-pdf-generator- Getting Started - Create your first PDF
- React Guide - React integration
- Vue Guide - Vue integration
- Svelte Guide - Svelte integration