Stirling-PDF icon indicating copy to clipboard operation
Stirling-PDF copied to clipboard

Increase watermark coverage to fill page (#2049)

Open thisisrenan opened this issue 1 year ago • 0 comments

Description

Correcting the watermark functionality and adding "Increase watermark coverage to fill page.".

Issue: When adding the text watermark, it was positioned starting from the bottom of the page. However, with the rotation applied, empty space was left because the watermark insertion started from the tip of the text, causing misalignment.

Solution: : The following file was modified:

  • modified: src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java

FIle: WatermarkController.java

  • The addTextWatermark() function was modified so that the watermark is correctly positioned, taking into account the text rotation. The effective height of the watermark was calculated using the cosine of the angle, and the starting point was adjusted to prevent the empty space that occurred in the original insertion.

addTextWatermark

Before: Before

After: After

Closes #2049

Checklist

  • [x] I have read the Contribution Guidelines
  • [x] I have performed a self-review of my own code
  • [ ] I have attached images of the change if it is UI based
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings
  • [ ] I have read the section Add New Translation Tags (for new translation tags only)

thisisrenan avatar Nov 12 '24 20:11 thisisrenan