Skip to content

Commit

Permalink
Increase watermark coverage to fill page (Stirling-Tools#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisrenan committed Nov 12, 2024
1 parent 0dd4456 commit 593bf59
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,14 @@ private void addTextWatermark(
int watermarkRows = (int) (pageHeight / watermarkHeight + 1);
int watermarkCols = (int) (pageWidth / watermarkWidth + 1);

// Calculating the effective line length according to the angle used
float effectiveHeight = watermarkHeight / (float) Math.cos(Math.toRadians(rotation));
int watermarkRowsRotation = (int) (pageHeight / effectiveHeight + 1);

// Add the text watermark
for (int i = 0; i < watermarkRows; i++) {
/* In the 'for' loop, is do (watermarkRowsRotation - watermarkRows) so that the watermark starts at the bottom of the page.
This compensate for the rotation by adjusting the starting point for inserting the watermark. */
for (int i = (watermarkRowsRotation - watermarkRows); i < watermarkRows; i++) {
for (int j = 0; j < watermarkCols; j++) {
contentStream.beginText();
contentStream.setTextMatrix(
Expand Down

0 comments on commit 593bf59

Please sign in to comment.