First off, thank you for considering contributing to PDFStudio! 🎉
It's people like you that make PDFStudio such a great tool for the Node.js community.
- Code of Conduct
- How Can I Contribute?
- Getting Started
- Development Workflow
- Coding Guidelines
- Testing
- Submitting Changes
- Reporting Bugs
- Suggesting Enhancements
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
- Be respectful and inclusive
- Welcome newcomers and help them get started
- Focus on what is best for the community
- Show empathy towards other community members
There are many ways to contribute to PDFStudio:
Found a bug? Please report it! See Reporting Bugs below.
Have an idea for a new feature? We'd love to hear it! See Suggesting Enhancements.
Fix bugs, implement features, or improve performance.
Fix typos, clarify explanations, or add examples.
Add test coverage for existing features or new functionality.
Help review and test pull requests from other contributors.
- Node.js >= 14.0.0
- npm or yarn
- Git
- TypeScript knowledge (helpful but not required)
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/pdfstudio.git
cd pdfstudio- Add the upstream repository:
git remote add upstream https://github.com/ORIGINAL_OWNER/pdfstudio.gitnpm installnpm run buildnpm test# Run a single example
npm run example
# Run all examples
npm run examplesgit checkout -b feature/your-feature-name
# or
git checkout -b fix/bug-descriptionBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation changestest/- Test additions/changesrefactor/- Code refactoringperf/- Performance improvements
- Write clean, readable code
- Follow the coding guidelines (see below)
- Add tests for new functionality
- Update documentation as needed
- Keep commits atomic and well-described
# Run all tests
npm test
# Run tests in watch mode
npm test -- --watch
# Run specific test file
npm test -- ImageManager.test.ts
# Check test coverage
npm test -- --coverageWrite clear, concise commit messages:
git add .
git commit -m "feat: add support for rounded rectangles"Commit message format:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Test additions/changesrefactor:- Code refactoringperf:- Performance improvementschore:- Maintenance tasks
git fetch upstream
git rebase upstream/maingit push origin feature/your-feature-nameGo to GitHub and create a Pull Request from your fork to the main repository.
- Use TypeScript for all new code
- Provide proper type annotations
- Avoid
anytypes when possible - Use interfaces for object shapes
// ✅ Good
interface ChartOptions {
title: string
data: ChartData[]
colors?: string[]
}
// ❌ Avoid
function drawChart(options: any) { ... }- Indentation: 2 spaces (no tabs)
- Line length: Max 100 characters (soft limit)
- Quotes: Single quotes for strings
- Semicolons: Use semicolons
- Naming:
camelCasefor variables and functionsPascalCasefor classes and interfacesUPPER_SNAKE_CASEfor constants
// ✅ Good
const MAX_PAGE_SIZE = 1000
class PDFDocument { ... }
function drawBarChart() { ... }
// ❌ Avoid
const max_page_size = 1000
class pdfDocument { ... }
function DrawBarChart() { ... }- Keep functions small and focused
- One function = one responsibility
- Use descriptive names
- Add JSDoc comments for public APIs
/**
* Draws a bar chart on the current page
* @param options - Chart configuration options
* @returns The PDFDocument instance for chaining
*/
drawBarChart(options: BarChartOptions): PDFDocument {
// Implementation
}- Use custom error classes (PDFStudioError, ValidationError, etc.)
- Provide helpful error messages
- Validate input parameters
// ✅ Good
if (fontSize <= 0) {
throw new ValidationError(
'Font size must be positive',
'fontSize',
fontSize
)
}
// ❌ Avoid
if (fontSize <= 0) {
throw new Error('Invalid font size')
}- Write tests for all new functionality
- Use descriptive test names
- Follow the AAA pattern (Arrange, Act, Assert)
- Test edge cases and error conditions
describe('BarChart', () => {
describe('drawBarChart', () => {
it('should throw error for empty data array', () => {
const doc = new PDFDocument()
expect(() => {
doc.barChart({ data: [], x: 0, y: 0, width: 100, height: 100 })
}).toThrow(ValidationError)
})
it('should draw bars with correct heights', () => {
const doc = new PDFDocument()
const data = [
{ label: 'A', value: 50 },
{ label: 'B', value: 100 }
]
doc.barChart({ data, x: 0, y: 0, width: 400, height: 300 })
// Assertions
expect(doc.getPageCount()).toBe(1)
})
})
})- Aim for >80% code coverage
- Focus on testing public APIs
- Test error paths as well as happy paths
-
Update Documentation
- Update README if adding features
- Add JSDoc comments
- Update CHANGELOG.md
-
Ensure Tests Pass
npm test npm run build -
Write a Good PR Description
- What does this PR do?
- Why is this change needed?
- How has it been tested?
- Screenshots (if applicable)
-
PR Title Format
feat: add rounded rectangle support fix: correct margin calculation for A4 pages docs: improve chart API documentation -
Link Related Issues
- Reference issue numbers:
Fixes #123 - Explain how the PR addresses the issue
- Reference issue numbers:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests added/updated
- [ ] All tests passing
- [ ] Manual testing performed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings generated
- [ ] CHANGELOG.md updated- Check existing issues - Your bug may already be reported
- Update to latest version - Bug may already be fixed
- Test in isolation - Ensure it's not an issue with your code
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Create document with...
2. Call method...
3. See error
**Expected behavior**
What you expected to happen.
**Actual behavior**
What actually happened.
**Code Example**
```javascript
const doc = new PDFDocument()
// Minimal code to reproduceEnvironment
- PDFStudio version: [e.g., 1.0.0]
- Node.js version: [e.g., 18.0.0]
- OS: [e.g., Windows 11, macOS 13, Ubuntu 22.04]
Additional context Any other relevant information.
## 💡 Suggesting Enhancements
### Enhancement Template
```markdown
**Feature Description**
Clear description of the proposed feature.
**Use Case**
Why is this feature needed? What problem does it solve?
**Proposed API**
```javascript
doc.newFeature({
option1: value1,
option2: value2
})
Alternatives Considered Other ways to solve this problem.
Additional Context Screenshots, mockups, or references to similar features.
## 🎯 Priority Areas
We especially welcome contributions in these areas:
### High Priority
- [ ] SVG path parsing
- [ ] Font subsetting implementation
- [ ] Performance optimizations
- [ ] Additional chart types (scatter, radar)
- [ ] More comprehensive examples
### Medium Priority
- [ ] Rounded rectangles
- [ ] Line cap/join styles
- [ ] Blend modes
- [ ] CID font support
- [ ] WOFF/WOFF2 fonts
### Documentation
- [ ] More code examples
- [ ] Video tutorials
- [ ] Migration guides
- [ ] API reference improvements
## 📚 Resources
- [TypeScript Handbook](https://www.typescriptlang.org/docs/)
- [PDF Reference 1.4](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf)
- [Jest Documentation](https://jestjs.io/docs/getting-started)
- [Git Best Practices](https://www.git-scm.com/book/en/v2)
## 🙏 Recognition
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Credited in documentation
## 💬 Questions?
- Open a [Discussion](https://github.com/USERNAME/pdfstudio/discussions)
- Ask in [Issues](https://github.com/USERNAME/pdfstudio/issues)
- Email: support@pdfstudio.dev
## 📄 License
By contributing, you agree that your contributions will be licensed under the MIT License.
---
**Thank you for contributing to PDFStudio!** 🙌
Together we're building the best PDF generation library for Node.js.