Watermarks
A Word watermark is the faint DRAFT or CONFIDENTIAL behind a page's text. It is not part of the body: it is WordArt in
the page's header, centred on the margins, sent behind the text. SetWatermark, RemoveWatermarks and
ReadWatermark add, remove and read one the way Word's Design > Watermark does, each as one undoable edit.
using DocWright.Core.Primitives;
using DocWright.Dom;
using DocWright.Dom.Editing;
DocumentPosition at = DocumentPosition.StartOf(paragraph);
var watermark = new Watermark
{
Text = "CONFIDENTIAL",
Width = Emu.FromPoints(527.85), // the box the text is stretched to
Height = Emu.FromPoints(131.95),
}; // silver, semitransparent, diagonal: Word's defaults
DocumentEdit edit = document.SetWatermark(at, document.Sections[0], HeaderFooterType.Default, watermark);
Watermark? there = document.ReadWatermark(); // the one the document has, or null
document.RemoveWatermarks(at); // every one
Which pages show it
A watermark goes into the header in effect for the section and the kind of page you name: the section's own header
of that kind, or the one it links to from an earlier section. When the section has none, one is added. Word does the
same with the header of the page the caret is on, so a section with a different first page needs
HeaderFooterType.First for its first page.
A document has one watermark, as in Word: setting another replaces it, wherever it was.
The box and the size
With no FontSize (Word's "Auto"), the text is stretched to fill the box you give. With a size, Word's own box is the
text at that size; give that box to match it. Word's Auto proportions follow no rule DocWright has found, so the box is
always the caller's.
What is written
Word's own markup: a Watermarks building-block content control around a Header paragraph holding a VML WordArt shape
named PowerPlusWaterMarkObject…, behind the text and centred on the margins. Word opens it and treats it as its own
watermark.
Note
A picture watermark is not available yet.