Thank you for contributing to PDF-Lite! This guide will help you understand the project structure and maintain consistency.
packages/pdf-lite/
├── src/
│ ├── core/ # PDF primitives (objects, parser, tokenizer, streams)
│ ├── pdf/ # High-level PDF document handling
│ ├── crypto/ # Encryption algorithms (RC4, AES)
│ ├── security/ # Security handlers
│ ├── signing/ # Digital signature support
│ ├── filters/ # Compression filters (Flate, LZW, etc.)
│ └── utils/ # Utility functions
├── test/
│ ├── unit/ # Unit tests
│ └── acceptance/ # Acceptance tests
examples/ # Numbered example scripts (001-create-pdf.ts, etc.)
pnpm installpnpm test # Run all tests
pnpm compile # Compile TypeScript
pnpm format # Format code with Prettier- Create a branch:
git checkout -b feature/your-feature-name - Make your changes
- Ensure tests pass:
pnpm test - Format code:
pnpm format - Check for TypeScript errors:
pnpm compile - Submit a pull request
This project uses Conventional Commits:
feat: add support for XYZ PDF feature
fix: correct parsing of encrypted streams
docs: update encryption examples
test: add tests for compression algorithms
refactor: simplify stream processing logicOther valid types: ci, chore, bump, perf, security, release, revert, style
Use kebab-case for all files: pdf-dictionary.ts, pdf-stream.ts
Use JSDoc comments for public APIs:
/**
* Encrypts a PDF stream using the specified algorithm.
*
* @param stream - The stream to encrypt
* @param algorithm - The encryption algorithm to use
* @returns The encrypted stream
*/
export function encryptStream(stream: PdfStream, algorithm: string): PdfStream {
// Implementation
}Tests are located in packages/pdf-lite/test/:
unit/- Unit tests for individual componentsacceptance/- Integration tests with real PDFs
Use Vitest for testing:
import { describe, it, expect } from 'vitest'
describe('Component', () => {
it('should do something', () => {
expect(result).toBe(expected)
})
})- Issues: Open an issue for bugs or feature requests
- Examples: Check the
examples/folder for reference implementations
Thank you for contributing! 🎉