mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2024-12-21 19:08:24 +01:00
* Increase watermark coverage to fill page (#2049) * Increase watermark coverage to fill page with the new calculation (#2049)
This commit is contained in:
parent
7f566d5de8
commit
5cf53e39d0
@ -187,18 +187,32 @@ public class WatermarkController {
|
||||
float watermarkHeight = heightSpacer + fontSize * textLines.length;
|
||||
float pageWidth = page.getMediaBox().getWidth();
|
||||
float pageHeight = page.getMediaBox().getHeight();
|
||||
int watermarkRows = (int) (pageHeight / watermarkHeight + 1);
|
||||
int watermarkCols = (int) (pageWidth / watermarkWidth + 1);
|
||||
|
||||
|
||||
//Calculating the new width and height depending on the angle.
|
||||
float radians = (float) Math.toRadians(rotation);
|
||||
float newWatermarkWidth =
|
||||
(float)
|
||||
(Math.abs(watermarkWidth * Math.cos(radians))
|
||||
+ Math.abs(watermarkHeight * Math.sin(radians)));
|
||||
float newWatermarkHeight =
|
||||
(float)
|
||||
(Math.abs(watermarkWidth * Math.sin(radians))
|
||||
+ Math.abs(watermarkHeight * Math.cos(radians)));
|
||||
|
||||
//Calculating the number of rows and columns.
|
||||
int watermarkRows = (int) (pageHeight / newWatermarkHeight + 1);
|
||||
int watermarkCols = (int) (pageWidth / newWatermarkWidth + 1);
|
||||
|
||||
// Add the text watermark
|
||||
for (int i = 0; i < watermarkRows; i++) {
|
||||
for (int j = 0; j < watermarkCols; j++) {
|
||||
for (int i = 0; i <= watermarkRows; i++) {
|
||||
for (int j = 0; j <= watermarkCols; j++) {
|
||||
contentStream.beginText();
|
||||
contentStream.setTextMatrix(
|
||||
Matrix.getRotateInstance(
|
||||
(float) Math.toRadians(rotation),
|
||||
j * watermarkWidth,
|
||||
i * watermarkHeight));
|
||||
j * newWatermarkWidth,
|
||||
i * newWatermarkHeight));
|
||||
|
||||
for (int k = 0; k < textLines.length; ++k) {
|
||||
contentStream.showText(textLines[k]);
|
||||
|
Loading…
Reference in New Issue
Block a user