ftvuzw-pdf-creator
v1.0.5
Published
jsPDF wrapper – image-to-PDF with header, smart page splitting and signature fields
Readme
ftvuzw-pdf-creator
A premium jsPDF wrapper for generating high-quality PDFs from images. This library is designed for professional reports, featuring automated header generation, smart page splitting, and customizable signature blocks.
✨ Features
- Smart Page Splitting: Automatically detects white space or uniform backgrounds to split large images across multiple A4 pages without cutting through text or critical content.
- Professional Headers: Includes document titles, metadata, and branding icons (Base64).
- Signature Blocks: Supports 0–6 signature fields with calligraphic styling and optional QR code links.
- Responsive Layout: Handles both Portrait and Landscape orientations based on image aspect ratio.
- TypeScript Ready: Includes full type definitions for a better developer experience.
🚀 Installation
npm install ftvuzw-pdf-creator jspdf📖 Usage
import { generatePDF } from 'ftvuzw-pdf-creator';
const options = {
imageBase64: 'data:image/png;base64,...', // The large image to convert
title: 'Monthly Performance Report',
createdBy: 'Technical Dept',
creationDate: new Date(),
signatures: [
{
ontopOfLine: 'Alice Developer',
underLine: 'Lead Engineer',
link: 'https://verify.example.com/sig/123' // Optional QR link
},
{
ontopOfLine: 'Bob Manager',
underLine: 'Operations Director'
}
],
headerIconBase64: '...', // Optional 320x50 logo
linkIconBase64: '...', // Optional top-right icon
linkIconUrl: 'https://example.com'
};
// Generate the jsPDF instance
const doc = await generatePDF(options);
// Save or output the PDF
doc.save('Report.pdf');🛠 How to Publish to NPM
Follow these steps to publish updates or the initial version of this package to the NPM registry.
1. Account Setup
Ensure you have an active account on npmjs.com.
2. Build the Distribution Files
The package is written in ESM. You must run the build script to generate the minified dist/index.js and copy the type definitions.
npm run build3. Login to NPM
Run this command in your terminal and follow the prompts to authenticate:
npm login4. Update the Version
Before every publish, you must increment the version number in package.json. You can use the built-in NPM command:
npm version patch # For bug fixes (e.g., 1.0.2 -> 1.0.3)
npm version minor # For new features (e.g., 1.0.2 -> 1.1.0)
npm version major # For breaking changes (e.g., 1.0.2 -> 2.0.0)5. Publish
Finally, push the package to the registry. Since the name ftvuzw-pdf-creator is unique, you can publish it as a public package:
npm publish --access public6. Verification
Once finished, you can find your package at:
https://www.npmjs.com/package/ftvuzw-pdf-creator
License
MIT
