There are two commands that can be used to insert watermarks:
Show watermark is the older command in use with most clients. It relies on the use of a source document that contains nothing but a shape that can be used to customise the watermark as much as possibly allowed by Word. However, in certain scenarios this can be very slow, especially when there are many sections in a document and/or it is stored in an online location like one drive.
Insert watermark is the newer command. Instead of relying on a source document it leverages the default office Watermark functionality to insert an image only. This offers less options for customising the watermark through word, though some options are provided for through the command and most other customisations can be applied on creation of the image. This option is also significantly faster than Show watermark.
Insert watermark
As mentioned above, this feature leverages the native word functionality for inserting images as watermarks. When defining the command we refer to the file name of the picture to be used located here: ...\Content\BaseExtensions\Pictures
.
This feature is developed to be used in conjunction with our print feature in order to set a watermark before printing and then remove the watermark again.
The following command will insert the particular watermark in the active document.
CMD
<Cmd case="BaseExtensions:insert-watermark-document">
Parameters
InsertInSections
This parameter controls which which sections the watermark should be inserted into and accepts three values:
All
Will be inserted in all sections in document
First
Will only be inserted in first section of document. NOTE that for this to take effect, the second section header should NOT be set to link to previous.
Rest
Will be inserted in every section BUT the first. NOTE that for this to take effect, the second section header should NOT be set to link to previous.
Name
This is the name that the inserted watermark-shape object should have. This is especially important in identifying the shape when replacing/removing the watermark.
Path
The path to the picture that should be inserted as watermark. NOTE that this path is from the root of the BaseExtensions content folder.
Size
The size of the watermark relative to original picture size (1 is 100% and default). NOTE the value used should be formatted as a decimal here. For example:
0.5 for 50% of original size
0.25 for 25% of original size
1.25 for 125% of original size
RelativeVerticalPosition
Defines where the position of the watermark should be relative to. Currently accepts two values: wdRelativeVerticalPositionPage
and wdRelativeVerticalPositionMargin
.
VerticalAlignment
Used in conjunction with the above parameter. Accepts values as defined here.
RelativeHorizontalPosition
Defines where the position of the watermark should be relative to. Currently accepts two values: wdRelativeHorizontalPositionPage
and wdRelativeHorizontalPositionMargin
.
HorizontalAlignment
Used in conjunction with the above parameter. Accepts values as defined here.
Show watermark
This feature works as a show/hide toggle of watermarks in Word. We can define whether the type of watermark is text or a picture. When using text, we define the text that should be inserted as watermark directly in the module, e.g. "DRAFT". When using a picture, we refer to the file name of a picture located here: ...\Content\BaseExtensions\Pictures
. In both cases, we further refer to a source document that contains nothing but a shape that controls where the particular watermark should be inserted. This document must be located here: ...\Content\BaseExtensions
.
This feature is developed to be used in conjunction with our print feature in order to set a watermark before printing and then remove the watermark again.
The following command will show the particular watermark in the active document.
CMD
<Cmd case="BaseExtensions:show-watermark"/>
Parameters
SourceDocName
Define the name of the source document containing watermarks. As mentioned, the path is ...\Content\BaseExtensions
which enables to simply define the name of document, e.g. SourceDocName="WatermarkSource.docx"
.
AutoConfigure
This parameter controls the insertion of watermark and accepts four values:
None
Auto-configure is not used and it will use shapes existing in the document. In this case, the SourceDocName parameter is not needed.
All
Inserts watermark in all sections in the document.
First
Only inserts watermark in the first section of the document.
NotFirst
Inserts watermark in all sections but the first.
Name
Define the name of the shape in the source document.
Type
This parameter sets the type of watermark, which can be either Text
or Picture
.
Content
This parameter is depending on what has been defined in the Type parameter. If it is defined to Text
, this value should be a string which will be inserted into the watermark shape. If it is defined to Picture
, this value should be a file path for a picture located here: ...\Content\BaseExtensions\Pictures
, which will be inserted into the watermark shape.
Hide watermark
The following command will hide the particular watermark.
CMD
<Cmd case="BaseExtensions:hide-watermark"/>
Parameter
Name
Define the name of the shape in the source document.
Comments
0 comments
Article is closed for comments.