This issue only happens for Docx files, it does not happen for PDFs.
Here is a code snippet that I used to test this issue, I used the AddATextWatermark class from the GroupDocs Git repository and did a few changes to it, and I update the watermark lib to 21.3 because the project was using an older version.
public static void run() {
// Constants.InDocumentPdf is an absolute or relative path to your document. Ex: "C:\\Docs\\document.pdf"
Watermarker watermarker = new Watermarker(Constants.InDocumentDocx);
TextWatermark watermark = new TextWatermark("top secret", new Font("Arial", 36));
watermark.setForegroundColor(Color.getRed());
watermark.setHorizontalAlignment(HorizontalAlignment.Center);
watermark.setVerticalAlignment(VerticalAlignment.Center);
watermark.setRotateAngle(45);
watermark.setBackground(false);
watermarker.add(watermark);
watermarker.save(Constants.OutDocumentDocx);
watermarker.close();
}
SO: Windows 11
Java version: RedHat OpenJDK 11.0.15
GroupDocs.Watermark version: 21.3
Git Project: GitHub - groupdocs-watermark/GroupDocs.Watermark-for-Java: GroupDocs.Watermark for Java examples, plugins and showcase projects
Git Revision: fed5e7f
@john.mcqueide
Could you please also share a problematic and the output files?
Yes, sure. It is the same document used in the snippet from the sample application.
document.docx (36.0 KB)
Sorry, I forgot to upload the output file.
output-document.docx (32.1 KB)
1 Like
@john.mcqueide
We are investigating this scenario. Your investigation ticket ID is WATERMARKJAVA-109.
Just to complete this topic, I saw the opposite happening with Spreadsheet, no matter the value of the background property the watermarks always leave above the content.
public class AddATextWatermark {
public static void run() {
// Constants.InDocumentPdf is an absolute or relative path to your document. Ex: "C:\\Docs\\document.pdf"
Watermarker watermarker = new Watermarker(Constants.InDocumentXlsx);
TextWatermark watermark = new TextWatermark("top secret", new Font("Arial", 96));
watermark.setForegroundColor(Color.getRed());
watermark.setHorizontalAlignment(HorizontalAlignment.Center);
watermark.setVerticalAlignment(VerticalAlignment.Center);
watermark.setRotateAngle(45);
watermark.setBackground(true);
watermarker.add(watermark);
watermarker.save(Constants.OutDocumentXlsx);
watermarker.close();
}
}
Files: files.zip (3.1 MB)
1 Like
@john.mcqueide
We are investigating this behavior as well. Your investigation ticket ID is WATERMARKJAVA-110.