A toolkit to change the background color of PDF files without altering any other content. Useful for updating the background of scanned documents, forms, or any PDF while preserving all text, images, and formatting.
This project provides both a command-line interface (CLI) and a web-based interface.
This is a monorepo containing:
packages/lib- Shared library with core PDF processing functionalitypackages/cli- Command-line interface for batch processingpackages/frontend- Web interface for in-browser PDF processing
- Bun (version 1.0 or higher recommended)
Clone the repository and install dependencies:
bun installRun the CLI with the following parameters:
bun run start <input.pdf> <output.pdf> <backgroundColor>- input.pdf: Path to the source PDF file.
- output.pdf: Path for the output PDF with the new background.
- backgroundColor: Background color in hex format (e.g.,
#B8C7AE).
bun run start fileName.pdf fileName-bg.pdf "#B8C7AE"This command will create fileName-bg.pdf with the specified background color.
Show usage and options:
bun run start -h
bun run start --helpTo start the web server:
bun run dev:frontendThe web interface provides a user-friendly way to:
- Upload multiple PDF files
- Choose a background color from presets or a custom color picker
- Process PDFs in your browser (no server upload required)
- Download the modified PDFs with new backgrounds
To build both CLI and web interface:
bun run build- Privacy-focused: All PDF processing happens locally, no files are uploaded to any server
- Bulk processing: Process multiple files at once via the web interface
- Color presets: Quickly choose from popular background colors
- Preservation: Only the background color is changed; all PDF content remains intact
The tool uses pdf-lib to:
- Load the PDF document
- Add a colored rectangle to each page as the bottom-most layer
- Save the modified PDF without changing any other content
bun run build:lib- Build the shared librarybun run build:cli- Build the CLIbun run build:frontend- Build the web interfacebun run build- Build everythingbun run dev:frontend- Start frontend in development mode