leading-to-change-pdf-generator
v1.0.3
Published
A TypeScript library for generating professional PDF reports with modular architecture
Maintainers
Readme
Leading to Change PDF Generator
A TypeScript library for generating professional PDF reports with a modular architecture, designed specifically for organizational change management reporting.
Features
- 🏗️ Modular Architecture: Component-based system for reusable PDF elements
- 📊 Rich Content: Tables, charts, headers, footers, and formatted text
- 🎨 Professional Styling: Consistent color schemes and typography
- 📱 Responsive Layout: Automatic page breaks and content flow
- 🔧 TypeScript Support: Full type safety and IntelliSense
- 📄 Multiple Output Formats: File save or ArrayBuffer return
- 🎯 Extensible: Easy to add new sections and components
Installation
npm install leading-to-change-pdf-generatorQuick Start
import generatePDF from "leading-to-change-pdf-generator";
import { IChangeReport } from "leading-to-change-pdf-generator/models/types";
const reportData: IChangeReport = {
reportId: "CHG-2025-001",
organizationId: "ORG-ABC123",
reportVersion: 1,
reportType: "Quarterly Change Report",
createdDate: "2025-01-15T10:30:00Z",
title: "Q4 2024 Change Management Report",
organizationName: "Acme Corporation",
// ... more data
};
// Generate PDF file
generatePDF(reportData);
// Or get as buffer for web applications
const pdfBuffer = generatePDF(reportData, true);Development
Prerequisites
- Node.js 16+
- npm or yarn
Setup
# Clone and install dependencies
git clone <repository-url>
cd leading-to-change-pdf-generator
npm installDevelopment Scripts
# Run development with sample data
npm run dev
# Run tests
npm run test
# Build for production
npm run build
# Test built package
npm run built-test
# Clean build artifacts
npm run cleanProject Structure
src/
├── components/ # Reusable PDF drawing components
│ ├── drawHeadingText.ts
│ ├── drawParagraph.ts
│ ├── drawTable.ts
│ ├── drawHeader.ts
│ └── drawFooter.ts
├── content/ # Content generation modules
│ ├── overview.content.ts
│ └── initiatives.content.ts
├── helpers/ # Utility functions
│ └── general.helpers.ts
├── models/ # TypeScript interfaces
│ └── types.ts
├── resources/ # Static resources
│ └── colors.ts
├── setup/ # PDF document setup
│ ├── addFonts.ts
│ └── addPage.ts
└── index.ts # Main entry pointArchitecture
Components
Drawing components are reusable functions that render specific PDF elements:
drawHeadingText: Styled headings (h1-h4)drawParagraph: Text with wrapping and alignmentdrawTable: Structured data tablesdrawHeader/Footer: Page headers and footers
Content Modules
Content modules generate complete report sections:
overview.content.ts: Organization info and executive summaryinitiatives.content.ts: Change initiative details- Add more modules for stakeholders, assessments, metrics, etc.
Helpers
Utility functions for common operations:
- Page management and layout
- Text wrapping and measurement
- Color and styling utilities
- Date/number formatting
Data Model
Comprehensive TypeScript interfaces define the expected data structure for change management reports.
Customization
Adding New Sections
- Create a new content module in
src/content/ - Import and call it in
src/index.ts - Add corresponding data interfaces in
src/models/types.ts
Styling
Modify colors and styling in src/resources/colors.ts:
export const colors = {
primary: "#2E86AB",
secondary: "#F18F01",
// ... customize colors
};Custom Components
Create new drawing components following the pattern:
const drawCustomComponent = (doc: jsPDF, x: number, y: number, data: any, options: ICustomOptions = {}): number => {
// Implementation
return heightConsumed;
};Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
For questions and support, please open an issue on GitHub.
