Open
Description
Summary
This enhancement should add support for setting a full-page background color in jsPDF, allowing users to create PDFs with colored backgrounds instead of the default white background.
Motivation
Currently, jsPDF only supports white page backgrounds. Many use cases require colored backgrounds for:
- Branded documents with company colors
- Dark mode PDF generation
- Design templates with specific color schemes
- Print materials requiring non-white backgrounds
- Accessibility improvements with high-contrast backgrounds
Implementation Details
Constructor Option
Users should be able to set a page background color when creating a new jsPDF instance:
// Using hex color
const doc = new jsPDF({
pageBackgroundColor: '#ffcccc'
});
// Using RGB array
const doc = new jsPDF({
pageBackgroundColor: [255, 204, 204]
});
// Using named colors
const doc = new jsPDF({
pageBackgroundColor: 'lightblue'
});
New API Methods
Two new methods should be added to the jsPDF API:
// Set background color for future pages
doc.setPageBackgroundColor('#ccffcc');
// Get current background color setting
const currentColor = doc.getPageBackgroundColor();
Metadata
Metadata
Assignees
Labels
No labels