We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding watermark to each page does not work at Cent OS using Java

We are trying to add watermark to first paragraph of the page. This is working as expected when we run the code in MAC but when we run the same code in Cent OS we are seeing watermark of one page is getting overlapped in another page.

Attached the sample files and outputs from MAC and CentOS.

Our code will be some thing like as below

for (Section section : doc.getSections()) {
NodeCollection paragraphs = section.getBody().getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph para : paragraphs) {
if (collector.getStartPageIndex(para) == pageIndex && para.getAncestor(NodeType.TABLE) == null) {

                 // watermark object creation code here.
                // we set below properties
              if (newNode) {

Files.zip (3.2 MB)

SampleTestMultiplePage_CentOS.docx has 2 watermarks in second page but no watermark in 3rd page. We need to drag second page watermark to side to other watermark visible .
Similar thing for the 6th page has 2 watermarks but no watermark on 10th page. Where as MAC has the watermark in expected way.

SampleTestPage1.docx has two watermarks on first page. But we could see watermark on all pages as well. MAC does not have this issue.

All the output files and sample files are attached
Overlapped watermark when moved is visible shown in below screenshot
Screen Shot 2020-04-11 at 5.07.43 PM.png (276.7 KB)


Your issue is related to fonts. You need to install fonts used in your document on the Linux machine to get the desired output.

If you still face problem, please attach the following resources here for testing:

  • Fonts used in your document.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

If this was the FONT issue then it should happen for all the documents and all the pages of the document. Isn’t it ?

I changed the font name to “Courier” also but same problem is observed.
I attached the code in the below zip file.
Code.zip (20.6 KB)


We are investigating this issue and will get back to you soon.


We have tested the scenario using the latest version of Aspose.Words for Java 20.3 and have not found the shared issue. So, please use Aspose.Words for Java 20.3.

If you still face problem, please convert your final document to PDF at Linux and Mac systems and attach them here for our reference. We will then provide you more information about this issue.

I tried with 20.3. The problem still persists.

Do you suggest any code to convert to pdf ? or jus exporting the doc as pdf using some other software ?


Please use the same code that you are using. You just need to call Document.Save method to save final document to PDF instead of Word document. Thanks for your cooperation.

Please find the attachments with pdf files from MAC and CentOS.
One difference i observed is in MAC it looped as 9 Pages where as it looped as 10 pages. Hope this may give some clue.

PDF with 19.1 attache here
PDFsWithDOcxFiles.zip (443.3 KB)

PDF with 20.3 are attached below
PDFWith20.3.zip (244.9 KB)


We have not observed the watermark issue in output PDF files. So, please use the latest version of Aspose.Words for Java 20.3.

This issue is related to missing fonts at CentOS. Please install the font used in your document to fix this issue. You can check the fonts of PDF file in ‘Document Properties’ dialog under ‘Font’ tab. Please check the attached image for font’s detail.

font used in PDF.png (86.8 KB)

Do you mean the font used for the watermark or the text which is present the doc already?


You need to install all fonts used in your document. The font of text and watermark in your document.

We suggest you please read the following article:
Using TrueType Fonts

I did not try with New version and fonts installed yet but i have one follow up question.

When a watermark is dragged to different place.

I was not able to remove it using its name

NodeCollection paraList = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph para : paraList) {
NodeCollection shapeList = para.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : shapeList) {
if (shape.getName().equals(“myName”)) {

This is just removing watermark on first page. Not on all the pages.

I tried by directly getting childNodes of type SHAPE also. It did not work.


Please make sure that you have set the unique name of each shape in your document. We suggest you please set the alternative text of shape while creating your document and use it to remove the watermark.

If you still face problem, please ZIP and attach your input Word document and simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end. We will investigate the issue and provide you more information on it.

This worked with unique name