mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-11 22:19:24 +00:00

# Description of Changes **What was changed** - **API & backend** - Added optional `fontColor` (hex, e.g. `#FF0000`) to `AddPageNumbersRequest` with OpenAPI docs, default `#000000`. - Decode hex color with safe fallback to black; apply via `setNonStrokingColor`. - Switched multiple `switch` statements to concise switch expressions and used `Locale.ROOT` for case operations. - Clamped `position` to `1..9` and reworked alignment using proper font metrics (`ascent`/`descent`) for top/middle/bottom positioning. - Centralized filename base extraction; reduced repeated calls. - Used try-with-resources for `PDPageContentStream`. - **UI & i18n** - Added `addPageNumbers.fontColor` label (en_GB). - Introduced `<input type="color" id="fontColor" ...>` with live background preview in the Add Page Numbers form. **Why the change was made** - Enable users to render page numbers in a chosen color (not just black). - Produce visually correct placement by accounting for font metrics (baseline vs. optical middle). - Improve resilience (locale-safe parsing, bounds checking) and code clarity. Closes #3839 [after.pdf](https://github.com/user-attachments/files/22064425/after.pdf) [before.pdf](https://github.com/user-attachments/files/22064426/before.pdf) --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.