When the document has multiple pages, the watermark cannot be displayed on each page of the document

Do you want to: Suggest a feature / Report a bug / Ask a how-to question
For feature suggestions, describe the result you would like to achieve in detail.
For bug reports, provide the steps to reproduce and if possible a minimal demo of the problem.
Document Server version: latest ver
Type of installation of the Document Server (docker, deb/rpm, exe):docker
OS: mac sonoma
Browser version: chrom 118

My document has over 200 pages and I found that adding a watermark doesn’t show up on all 200 pages. as shown in the following figure:

Why are you doing this? If there are no other special circumstances to determine that this is a bug, I will try to submit PR

Can someone explain it to me? :weary:

The following code calls realculate and then GetSectionHdrFtr when calculating the watermark on each page

	CDocumentPrintView.prototype.GetSectionHdrFtr = function(nPageAbs, isFirst, isEven)
	{
		let oLogicDocument = this.LogicDocument;

		let nSectionIndex = this.SectionsInfo.Get_Index(oLogicDocument.GetPage(nPageAbs).GetStartPos());
		let oSectPr       = this.SectionsInfo.Get_SectPr2(nSectionIndex).SectPr;
		let startSectPr   = oSectPr;

		isEven  = isEven && oSectPr.IsEvenAndOdd();
		isFirst = isFirst && oSectPr.IsTitlePage();

		let oHeader = null;
		let oFooter = null;
		while (nSectionIndex >= 0)
		{
			oSectPr = this.SectionsInfo.Get_SectPr2(nSectionIndex--).SectPr;

			if (!oHeader)
				oHeader = oSectPr.GetHdrFtr(true, isFirst, isEven);

			if (!oFooter)
				oFooter = oSectPr.GetHdrFtr(false, isFirst, isEven);

			if (oHeader && oFooter)
				break;
		}

		return {
			Header : oHeader,
			Footer : oFooter,
			SectPr : startSectPr
		};
	};

Why does a docx document have more than one SectPr?
The resulting phenomenon is: A document set watermark will be divided into several sections, for example, I set watermark on the first page (the first page corresponds to == oSectPr subscript 0), may get GetSectionHdrFtr() on the fifth page, resulting in the oSectPr obtained by the watermark article is “”, As a result, there is no watermark behind the fifth page.

Why does it look in realculate() for FooterDefault based on the oSectPr of the current page, which may find other FooterDefault that is not empty, what is really needed in the element array (oSectPr array) may be the oSectPr with index 0, There is no watermark on subsequent pages

// It is possible to find an oHeader that is not empty, but it is not the watermarked text we need
oSectPr = this.SectionsInfo.Get_SectPr2(nSectionIndex--).SectPr;
if (!oHeader)
	oHeader = oSectPr.GetHdrFtr(true, isFirst, isEven);

Looking forward to your reply :pray:

function CDocumentSectionsInfoElement(SectPr, Index)
{
    this.SectPr = SectPr;
    this.Index  = Index;
}

Hi, @hufei :handshake:
I probably won’t be able to explain the actual code. Do you have a scenario I can follow to reproduce a similar issue?

hi @Nikolas , thank you for your reply :handshake:
Download this file and add watermark you will find that watermark cannot be displayed on every page.

The reason is that there are many SectPr inside the document, and the watermark found in the loop process is an empty string, resulting in no watermark in the subsequent part.

I have solved it, that is, to use the first SectPr as a follow-up watermark, but I think my method is not good, and I am looking forward to your repair (the internal code is too complicated, I think I may not consider it thoroughly). :smirk_cat:

受弯预制构件1.docx (430.0 KB)

1 Like

@hufei
Thank you for the file and the work you’ve done!
You’re awesome :upside_down_face:

We are checking the situation. :handshake:
I will let you know when I get something.

hey @hufei

We reproduced these problems and added the bug to our internal tracking system.

Thank you for the detailed description of the issue! :slightly_smiling_face:
We’re glad that you are interested in improving the product.

1 Like