This example illustrates how you can add a watermark to the document. The main idea is to add a corresponding Floating Object (TextBox or Picture) to the header section (see SubDocument essentials - simple examples). Take special note of the TextRenderer.MeasureText Method, which is used to calculate the correct size of a textual watermark.
See Also:
SubDocument.InsertPicture Method
SubDocument.InsertTextBox Method
Question Comments
Added By: TRAINEAU SOIZIC at: 10/24/2012 3:42:24 AM
Don't work for me with the last build :
the text on the page (the real one : not the watermark text) disapears from left to right when zooming ... try to set the zoom at 200 %
in fact it seems that it is a horizontal scrollbar problem ... try to zoom and play with Hscrolling
Added By: Anders Wang at: 9/4/2014 11:57:01 PMBut, After you save as it to word, You can see the layout is corrupted by the watermark. So how to deal with it?
Added By: Elliot (DevExpress Support) at: 9/5/2014 6:32:17 AMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T147935: Corrupted document layout. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
Hi,
for text watermark with chinese font (Simhei), your following shapesize calculaition code caused clipped watermark. The text cannot be fully displayed. Could you please help us? Thanks.
Size sizeInPixels = TextRenderer.MeasureText(text, measureFont);
shape.Size = new SizeF(Units.PixelsToDocumentsF(sizeInPixels.Width, richEditControl.DpiX), Units.PixelsToDoc
Hello,
The issue occurs depends on the value returned by the standard System.Window.Forms.TextRenderer.MeasureText method and doesn't rely on our products.
To resolve the issue, increase a shape size as follows:
[C#]shape.TextBox.Document.EndUpdateCharacters(cp);shape.TextBox.HeightRule=TextBoxSizeRule.Auto;shape.RotationAngle=-45;SizesizeInPixels=TextRenderer.MeasureText(text,measureFont);shape.Size=newSizeF(Units.PixelsToDocumentsF(sizeInPixels.Width,richEditControl.DpiX)+ 10,Units.PixelsToDocumentsF(sizeInPixels.Height,richEditControl.DpiY));
Please try this solution and let me know your results.
Hi,
Really? Do you have check "Units.PixelsToDocumentsF"?
Hello,
I have researched the issue and came to the conclusion that the cause of the issue is rounding of the shape size on its rendering.
To resolve the issue, set the RichEditControl.LayoutUnit property to DocumentLayoutUnit.Document in the example's SetTextWatermark method without any other modifications.
Hi,
Set RichEditControl.LayoutUnit doesn't work for me. The Text Water mark (Simhei) are still clipped.
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T294138: The E4184 example doesn't work properly with the 'Simhei' font. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T350978: 'Specified document position or range belongs to other document or subdocument' error occurs on running the E4184 example. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.