Skip to content

Conversation

@antonarhipov
Copy link

  • Grid layout and random positioning of watermarks per page
  • Random orientation
  • Per watermark font randomization of color and size
  • Text watermark per-letter randomization of font, color, size, and orientation
  • Sharing
  • Random mirroring of image watermarks
  • Add WatermarkRandomizer utility and enhance watermark request handling with new validations and randomization features

Description of Changes


Checklist

General

Documentation

UI Changes (if applicable)

  • Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR)
Screenshot 2025-10-29 at 13 13 17 Screenshot 2025-10-29 at 13 12 29

Testing (if applicable)

  • I have tested my changes locally. Refer to the Testing Guide for more details.

- Grid layout and random positioning of watermarks per page
- Random orientation
- Per watermark font randomization of color and size
- Text watermark per-letter randomization of font, color, size, and orientation
- Sharing
- Random mirroring of image watermarks
- Add `WatermarkRandomizer` utility and enhance watermark request handling with new validations and randomization features
Copilot AI review requested due to automatic review settings October 29, 2025 11:15
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines ignoring generated files. enhancement New feature or request labels Oct 29, 2025
@stirlingbot stirlingbot bot added Java Pull requests that update Java code Front End Issues or pull requests related to front-end development Back End Issues related to back-end development API API-related issues or pull requests Test Testing-related issues or pull requests and removed enhancement New feature or request labels Oct 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive watermark validation and randomization capabilities to the PDF watermarking feature. The changes introduce extensive input validation, advanced watermark customization options (random positioning, rotation ranges, per-letter variations, mirroring, etc.), and deterministic randomness for testing purposes.

Key Changes:

  • Added request validation with detailed error messages for watermark parameters
  • Introduced WatermarkRandomizer utility class for deterministic random watermark attributes
  • Extended watermark request model with 20+ new configuration fields for advanced customization
  • Enhanced HTML template with collapsible advanced options and client-side validation

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
WatermarkController.java Added comprehensive validation logic and refactored watermark rendering to support advanced features
AddWatermarkRequest.java Extended model with validation annotations and new fields for enhanced watermark control
WatermarkRandomizer.java New utility class providing deterministic randomization for watermark attributes
add-watermark.html Enhanced UI with advanced options panel and client-side validation
WatermarkValidationTest.java New test suite validating watermark parameter constraints
WatermarkControllerIntegrationTest.java New integration tests covering various watermark scenarios
WatermarkRandomizerTest.java Comprehensive unit tests for randomizer utility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ecurity/WatermarkController.java


remove unused variable

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@balazs-szucs balazs-szucs added the Priority: Medium Issues or pull requests with medium priority label Oct 29, 2025
antonarhipov and others added 5 commits October 29, 2025 13:32
…ecurity/WatermarkController.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ecurity/WatermarkController.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ecurity/WatermarkController.java


save handling of bound parameters

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ecurity/WatermarkController.java


safe handling of bounds

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Ludy87
Copy link
Collaborator

Ludy87 commented Oct 29, 2025

/prdeploy

@Ludy87 Ludy87 linked an issue Oct 29, 2025 that may be closed by this pull request
1 task
@stirlingbot stirlingbot bot added the pr-deployed Pull request has been deployed to a test environment label Oct 29, 2025
@stirlingbot
Copy link
Contributor

stirlingbot bot commented Oct 29, 2025

🚀 PR Test Deployment

Your PR has been deployed for testing!

🔗 Test URL: http://185.252.234.121:4758
Security Disabled

This deployment will be automatically cleaned up when the PR is closed.

Copy link
Collaborator

@balazs-szucs balazs-szucs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I took quick look, made some suggestions.

Copy link
Collaborator

@balazs-szucs balazs-szucs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more suggestions.

- Introduced support for translations in watermark advanced options.
- Simplified random position generation by removing `margin` and `bounds` parameters.
- Updated `WatermarkRandomizer` to avoid use of obsolete constraints.
- Refactored tests to validate new approach while ensuring watermarks stay within page boundaries.
- Adjusted UI and localization files to remove unused margin and bounds options.
…transformations

- Enhanced text watermark rendering to calculate accurate dimensions for center-point rotation.
- Added precise positioning and rotation for individual characters in per-letter variations.
- Updated baseline transformations to ensure proper alignment and spacing of characters and lines.
- Introduced `generateRandomPositions` with collision detection and spacing constraints in `WatermarkRandomizer`.
- Updated `WatermarkController` to use new method for generating random positions.
- Added extensive test coverage for collision detection scenarios in `WatermarkRandomizerTest`.
- Implemented `PDFormXObject` to cache and reuse watermarks across PDF pages.
- Adjusted `WatermarkController` to create appearance streams and handle transparency within cached objects.
- Improved rendering efficiency by minimizing repetitive operations for each page.
- Moved hardcoded color palette to a static constant `PALETTE`.
- Updated methods to use `PALETTE` for consistency and maintainability.
@stirlingbot
Copy link
Contributor

stirlingbot bot commented Nov 2, 2025

🚀 Translation Verification Summary

🔄 Reference Branch: pr-branch-messages_en_GB.properties

📃 File Check: messages_en_GB.properties

  1. Test Status:Passed
  2. Test Status:Passed
  3. Test Status:Passed

📃 File Check: messages_en_US.properties

  1. Test Status:Passed
  2. Test Status:Passed
  3. Test Status:Passed

✅ Overall Check Status: Success

Thanks @antonarhipov for your help in keeping the translations up to date.

@reecebrowne
Copy link
Contributor

reecebrowne commented Nov 2, 2025

/prdeploy

@Frooodle
Copy link
Member

Frooodle commented Nov 2, 2025

@antonarhipov Is this PR ready? Just looking through the suggested comments from @balazs-szucs and its hard to see which you have addressed as they not been closed/commented on

@stirlingbot
Copy link
Contributor

stirlingbot bot commented Nov 2, 2025

🚀 PR Test Deployment

Your PR has been deployed for testing!

🔗 Test URL: http://185.252.234.121:4758
Security Disabled

This deployment will be automatically cleaned up when the PR is closed.

@antonarhipov
Copy link
Author

@Frooodle, the PR is ready. I'm in doubt about the readability of the WatermarkController logic, though. Let me know if you'd like to refactor it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API API-related issues or pull requests Back End Issues related to back-end development Front End Issues or pull requests related to front-end development Java Pull requests that update Java code pr-deployed Pull request has been deployed to a test environment Priority: Medium Issues or pull requests with medium priority size:XXL This PR changes 1000+ lines ignoring generated files. Test Testing-related issues or pull requests Translation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Extended option for Watermark fonction

5 participants