Add Watermark to Documents in SharePoint

In this guide you’ll learn how to apply watermarks to documents using the standard SharePoint user interface. This allows watermarks to be applied to Documents and List Item attachments, and even supports the application of custom, user-specific watermarks when a document is opened, something that cannot be achieved by any other means.

Note: By default, the MS SharePoint screens associated with this watermarking feature are disabled. They can be activated by enabling the Muhimbi Document Converter - Automatic Document Processing User Interface Feature at either the Web Application or Site Collection level (but not both).

Configuring predefined watermarks at the Site Collection level

To allow the same watermarks to be shared between multiple lists and libraries, the system allows default watermarks to be specified at the Site Collection level using the Site Actions \Watermarking Settings screen.

Note: Specifying ‘default watermarks’ on the Site Collection level does not automatically enable watermarking on a specific Library, It must be enabled separately in a Library.

default watermarks

A different default watermark can be specified for Insert, Update, and Open watermarking events. It is even possible to lock down the look and feel of the watermarks to prevent them from being changed at the list or library level.

Configuring Automatic Watermarking at the List or Library Level

Even though default watermarks can be configured at the Site Collection level, the actual automatic watermarking must be enabled at the individual List or Library level. The relevant screen, Watermarking settings, can be opened from the List or Library’s settings screen.

watermark settings

The Settings screen allows automatic watermarking to be enabled for Insert, Update, and Open events. Each event type can use a separate watermark and selection filter. Different watermark types can be selected, including Text, RTF, Image, PDF, and Composite.

settings screen

Note: Due to limitations in MS SharePoint 2007, automatic watermarking for Insert and Update events is not supported on Document Libraries. They are supported on Lists and in MS SharePoint 2010. You can use Workflows as an alternative.

Merging Dynamic Data into Watermarks

The watermarking framework provided by the Document Converter for SharePoint comes with a powerful set of merge codes that allow dynamic data to be ‘merged in’ at run-time. For example, using merge codes, you can create a dynamic watermark like this:

PDF Opened by ‘{REMOTE_USER}’ on ‘{LONG_DATE}’ from IP ‘{REMOTE_ADDR}’

This results in the following watermark:

merging dynamic data into watermarks

Merge codes are not exclusive to the ‘watermark on open’ functionality. There are several other ways that watermarks can be applied, for example, using workflows or using web services.

The field codes however are not always available for a particular interface as, for example, the web service has no knowledge about anything that happens in MS SharePoint, and workflows are not always associated with an HTTP Context. For a full overview of the available merge codes please contact our friendly support team.

Specifying Filtering Criteria when Automatically Applying Watermarks

Similar to the way MS SharePoint views can be filtered to only display certain list items, Muhimbi’s automatic watermarking facility allows filters to be created that determine which documents should be watermarked automatically, and which should not. The possibilities are endless, but some obvious examples are as follows:

  • Apply watermarks to draft documents, but not to approved documents.

  • Always apply watermarks to a document created by a user from a particular domain or authentication provider (e.g. FBA)

  • Watermark a document, based on the current date, for embargoed documents.

  • Enable watermarks on all documents with ‘Confidential’ in the Title.

  • Apply watermarks to minor versions (e.g. 1.3) of a document, but not
    to major versions (e.g 2.0).

  • Only apply watermarks to certain content types.

specifying filter criteria

Fortunately, this powerful functionality is very easy to use. Each watermarking section comes with a separate Filter that contains the following fields:

  • Apply Filter: A simple check box that allows filtering to be toggled. When disabled, watermarks are automatically added to all documents.

  • Field List: A list of fields that can be used to apply filters on e.g. Title, Author, Content Type, etc. This is a ‘sanitized’ list similar to the one displayed in SharePoint’s own View filter. Non-sensible ‘for internal use only’ fields are automatically stripped out.

  • Comparison Type: Specify the kind of comparison to use, e.g. ‘is equal to’, ‘is greater than’, ‘contains’, ‘begins with’ etc.

  • Comparison Value: The value(s) to compare the selected field with. Full details are provided below. It is in the Comparison Value field where things become interesting as all comparisons take the underlying type of the column into account. All common data types are supported, specifically:

  • Boolean: True: True, Yes, -1, 1 and False, No, 0 as False.

  • Currency: Allows currency comparisons. Please use numbers only, do
    not specify the currency symbol.

    currency comparisons

  • DateTime: Allows date and time fields to be compared. Enter [Today] (including the square brackets) to compare a date field to the current date, e.g. to apply watermarks to documents modified today. Similarly [Now] can be used to compare a field with the current date and time.

  • Lookup: Compare lookup fields, including lookups that may contain multiple values.

  • User: Compares fields that contain a reference to a user account, e.g. the Modified By field. Filters of this type expect a value recognized by the underlying Authentication Provider. This will usually be in the ‘domain\ user_name’ format, but could also be ‘fbaprovidername:username’.

    Note: Enter [me] (including the square brackets) to evaluate the field against the current user. This allows, for example, watermarks to be added to all documents not created by the current user.

  • Single and Multiple choice fields: Allows single and multiple values to be matched, particularly useful with the ‘contains’ comparison type. Examples and details are provided below.

  • Numerical fields: Carries out numerical comparisons.

  • URL: Can compare fields of type URL.

  • Text: Any text field or custom field type that uses a text-based representation.

Some additional notes of interest:

  • All comparisons are case-insensitive.

  • The filter for the ‘Version’ field accepts the ‘[MajorVersion]’ and ‘[MinorVersion]’ values to distinguish between major (1.0, 2.0) and minor (1.1, 1.2, 2.2) versions. It also allows a specific version number to be specified.

  • When filtering multiple-choice / multi-select fields you can specify multiple values. For example:

    • “Brett;Ben” Contains “Ben” = True

    • “Brett;Jeroen;Ben” Contains “Brett;Ben” = True

    • “Brett;Jeroen” Contains “Brett;Ben” = False

    • “Brett;Jeroen” is equal to “Jeroen;Brett” = True (The sequence in which values are specified does not matter)

  • If a field is deleted from a list after it has been specified in a filter then the filter will always equate to false resulting in the watermark not being applied.

  • It is not possible to specify a Filter for Insert events on a Document Library as the fields do not contain any values at this time. This is not a problem for inserting documents attached to a list.

  • When comparing fields that contain both Date and Time elements (e.g. the Modified Date) against such values as [Today] then please take into account that the value represented by [Today] does not include a time element. Therefore ‘Created Date = [Today]’ will never evaluate to true unless it is midnight. Instead, use ‘Created Date >= [Today]’. For Date fields that don’t include the Time element, e.g. a birthday, this will not be a problem.

Filtering out System Users (e.g. Search indexer)

When using the Watermark On Open facility on a list or library, watermarks are applied every time a file is opened, which is exactly what is expected. However, these watermarks are also applied when the SharePoint Search Indexer opens these files. This places an excessive load on the system (bulk indexing results in bulk watermarking), so it is recommended to exclude certain accounts from the automatic watermarking.

Starting with version 8.4 of the Muhimbi Document Converter, a PDF real-time settings screen is available from the Site Actions menu. Enter a list of accounts to exclude, the System account is excluded by default.

filtering out system users

Dealing with Watermark Errors

Automatically watermarking documents works great, but in the real-world scenario, there might be some errors generated. In some situations watermarks cannot be applied, either because the document is encrypted, or corrupt, or an unexpected error occurs, e.g. a temporary network error.

Depending on your exact requirements, you need to define how the system should behave under exceptional circumstances like whether the user still needs to be given access to the document, even if watermarks are not able to be added, or if their access to the document be blocked.

Starting with version 10.0 of the Muhimbi Document Converter, a Real-time settings screen is available from the Site Actions menu. Use this screen to specify if access to the document should be blocked in case of an error, or if the unprocessed (pre-watermarked) document should be passed to the user.

watermark errors

Additional Resources

Knowledge Base Articles

Videos

Blog articles

In this guide you’ll learn how to add watermarks to documents using SharePoint Designer Workflows. These workflow actions allow elements such as text, rectangles, images, PDF files, QR Codes, barcodes as well as other shapes to be added to a wide variety of documents either in front of or behind the document’s content.

Each separate watermark workflow action is applied to the document separately. If multiple watermarks need to be applied in one go, you can do this using the Composite Watermark feature.

You can also add barcodes to MS Word, MS Excel, MS PowerPoint and PDF via MS SharePoint Designer workflows. We support most common barcode types including Codabar, Code11, Code32, Code39, Code39Extended, Code128, Code128A, Code128B, Code128C, GS1Code128, Code93 and Code93Extended.

Although there are many good reasons to automatically add barcodes to documents, the most common uses of this feature that we see with our customers is for document management. At some stage, documents will make their way outside of the document management system they are created and stored in. Barcodes can play an important role in ensuring and tracking these documents along with the auditing information using watermarks.

The individual workflow actions are self describing, but the following elements require special attention:

  1. this document: The document to apply the watermark to. For most workflows, selecting Current Item will suffice, but some scenarios require the lookup of a different item. You may also want to check that the file type of the document is a supported format (pdf, docx, xlsx, pptx).

  2. this file: The name and location of the watermarked file. Leave this field empty to overwrite the source file with the watermarked copy. Enter a path, including the Document Library and any folder names, if you want to write the watermarked file to a separate location. E.g. “shared documents/watermarked files/confidential.pdf”.

  3. List ID: The ID of the list the watermarked file was written to. This can later in the workflow be used to perform additional tasks on the file such as a check-in or out.

  4. Item ID: The ID of the watermarked file. Can be used with the List ID.

Text Watermark

This workflow action can be used to apply text to the foreground or background of one or more pages in the document with full control over the font, style, size and color.

The SharePoint Designer workflow action is named ‘Add Text watermark to Document’ and the parameters are as follows:

The text stored in the content field may contain embedded field codes such as the date or current page number. MS SharePoint Designer lookup variables are also supported, which makes it possible for dynamic information stored in workflow variables, or in the Item’s columns, to be embedded in the watermark.

RTF Watermark

The RTF watermark allows simple RTF encoded text to be added as a watermark. This allows more control over the look and feel of individual words in the watermark at the cost of added complexity.

An example of valid RTF is as follows:

{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard

This is some {\b bold} text.\par

}

The MS SharePoint Designer workflow action is named ‘Add RTF watermark to Document’ and the parameters are as follows:

Note: Unlike the Text Watermark, the RTF Watermark does not support embedded field codes. However, MS SharePoint Designer lookup variables are fully supported to make it possible for dynamic information stored in workflow variables, or in the item’s columns, to be embedded in the watermark. RTF Watermarks are displayed as plain text when applied to MS PowerPoint files.

Image Watermark

Use the Image Watermark to add common image types (BMP, JPG, GIF, PNG, TIFF, WMF, EMF / EMF+) as a watermark to a document.

The MS SharePoint Designer workflow action is named ‘Add Image watermark to Document’ and the parameters are as follows:

The image at this path parameter expects the full path of the image relative to the current site, e.g. ‘shared documents/images/company_logo.gif’.

PDF Watermark

Existing PDF files can also be used as a watermark. This could be a dynamic file that is generated from, for example MS Word, and then converted to PDF using the Muhimbi Document Converter. Alternatively, this could be a static PDF file that has been generated manually.

The MS SharePoint Designer workflow action is named ‘Add PDF watermark to Document’ and the parameters are as follows:

The pdf file path parameter expects the full path of the PDF name relative to the current site, e.g. ‘shared documents/static watermarks/company_logo.pdf’.

Note: PDF based watermarks can only be applied to other PDF documents. It is not possible to apply a PDF Watermark to Office file formats.

Rectangle Watermark

A simple rectangle can be added as a watermark using the ‘Add Rectangle to Document’ workflow action. The parameters are as follows:

Line Watermark

A line can be added as a watermark using the ‘Add Line to Document’ workflow action. The parameters are as follows:

Ellipse Watermark

A circle or ellipse can be added as a watermark using the ‘Add Ellipse to Document’ workflow action. The parameters are as follows:

QR Code Watermark

A QR Code can be added as a watermark using the ‘Add QR Code Watermark to Document’ workflow action.

The fields are as follows:

Content: The content to embed in the QR code. This will need to match the specified input mode.

Version: Over the years many different QR versions have been introduced. Select the one appropriate to your needs, either Auto or Version01 – Version40.

Input mode: Specify the appropriate mode for your content:

  • Binary: Any value including text, URLs etc.

  • AlphaNumeric: Numbers, (Upper case) characters and SPACE, $, %, *, +, -, ., /, :

  • Numeric: Numbers only

Error correction level: Select the appropriate level for your needs: Low, Medium, Quartile, High

Barcode Watermark

A number of different barcode types can be added as a watermark using the ‘Add Linear Barcode’ workflow action.

The fields, specific to this watermark type, are as follows:

  • Type: The barcode type including Codabar, Code 11, Code 32, Code 39,
    Code 93, Code 128 (A/B/C), GS1-128.

  • Content: For the barcode content, please ensure that the specified content is compatible with the data that may be stored in the selected barcode type.

  • Check digit: If relevant to the barcode type, calculate and encode the check digit into the barcode.

Applying Composite Watermarks using MS SharePoint Designer Workflow

The individual watermarking workflow actions described in the previous section are relatively easy to use. The disadvantage however is that if you wish to combine multiple different shapes, e.g. a Circle, an Image and some dynamic text, then a separate watermarking cycle is carried out internally for each shape. This works well and will be fast enough for most occasions, but it is not the most efficient way to do it.

The separate ‘Add Composite Watermark to Document workflow’ action allows multiple watermarks to be applied in one go with each watermark made up of one or more individual shapes.

The workflow parameters are as follows:

The real power comes as part of the watermark.xml field that stores the XML that describes the multiple watermarks and elements.

The XML for each individual shape is described below, but before we go into more details let’s start with an example.

The following sample code describes three watermarks.

  • The first adds an image of the company logo (in the foreground) to the top right of each page in the document.

  • The second adds the login id of the user who created / changed the document to a random location in the background in a semi-transparent way.

  • The third adds an automatically generated page number to the bottom right of each page.

<watermarks>

      <!-- ** First watermark contains a single image element with the logo -->
      <watermark
            hPosition="right"
            vPosition="top"
            width="200"
            height="73"
            zOrder="1"
            opacity="100"
            pageOrientation="both">
            <image
                  width="200"
                  height="73"
                  scaleMode="maintainaspectratio"
                  imageFilePath="watermarking/muhimbi-logo.gif" />

      </watermark>

      <!-- ** Second watermark places the user's name in the background -->
      <watermark
            hPosition="random"
            vPosition="random"
            width="300"
            height="200"
            zOrder="-1"
            rotation="-30"
            opacity="15"
            pageOrientation="both">
            <text
                  width="200"
                  height="200"
                  fillColor="#000000"
                  content="Insert 'modified by' field using SharePoint Designer"
                  fontFamilyName="Times New Roman"
                  fontSize="24"
                  fontStyle="bold|italic"
                  wordWrap="word"
            />

      </watermark>

      <!-- ** Third watermark adds page numbering -->
      <watermark
            hPosition="right"
            vPosition="bottom"
            width="100"
            height="40"
            zOrder="1"
            pageOrientation="both">
            <text
                  hPosition="left"
                  vPosition="top"
                  width="100"
                  height="40"
                  content="Page {PAGE} of {NUMPAGES}"
                  fontFamilyName="Arial"
                  fontSize="11"
                  hAlign="left"
                  vAlign="top"
            />

      </watermark>
</watermarks>

Text Element

This watermark can be used to apply text to the foreground or background of one or more pages in the target document, with full control over the font, style, size and color.

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<text
      hPosition="optional (absolute, random, left, center, right)" vPosition="optional (absolute, random, top, middle, bottom)" x="optional"
      y="optional"
      width="required"
      height="required"
      zOrder="optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)" scaleX="optional"
      scaleY="optional"
      rotation="optional"
      opacity="optional"
      lineColor="optional"
      lineWidth="optional"
      fillColor="optional"
      content="required"
      fontFamilyName="optional"
      fontSize="optional"
      fontStyle="optional (regular, bold, italic, strikeout, underline)" wordWrap="optional (none, character, word, wordonly)" hAlign="optional (left, center, right, justify)"
      vAlign="optional (top, middle, bottom)" />

The text stored in the content attribute may contain embedded field codes such as the date or current page number.

When a lot of content is anticipated then you may want to remove the content attribute and instead place it inside the text element, for example:

<text
      hPosition="optional (absolute, random, left, center, right)"
      ... rest omitted
>
      Your content goes here, use a CDATA section if needed.
</text>

SharePoint Designer lookup variables are also supported, which makes it possible for dynamic information stored in workflow variables, or in the Item’s columns, to be embedded in the watermark.

RTF Element

The RTF watermark allows simple RTF encoded text to be added as a watermark. This allows more control over the look and feel of individual words in the watermark at the cost of added complexity.

An example of valid RTF is as follows:

{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard

This is some {\b bold} text.\par

}

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<rtf
      hPosition="optional (absolute, random, left, center, right)"
      vPosition="optional (absolute, random, top, middle, bottom)"
      x="optional"
      y="optional"
      width="required"
      height="required"
      zOrder="optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)"
      scaleX="optional"
      scaleY="optional"
      rotation="optional"
      opacity="optional"
      lineColor="optional"
      lineWidth="optional"
      fillColor="optional"
      rtfData="required"/>

When a lot of content is anticipated, then you can remove the rtfData attribute and instead place it inside the <*rtf\> element, for example:

<rtf
      hPosition="optional (absolute, random, left, center, right)"
      ... rest omitted
      >
       Your content goes here, use a CDATA section if needed.
</rtf>

Note: Unlike the Text Watermark, the RTF Watermark does not support embedded field codes. However, SharePoint Designer lookup variables are fully supported to make it possible for dynamic information stored in workflow variables, or in the Item’s columns, to be embedded in the watermark. RTF Watermarks are displayed as plain text when applied to MS PowerPoint files.

Image Element

You can use the Image Watermark to add common image types (BMP, JPG, GIF, PNG, TIFF, WMF, EMF / EMF+) as a watermark to a document.

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<image
      hPosition="optional (absolute, random, left, center, right)"
      vPosition="optional (absolute, random, top, middle, bottom)"
      x="optional"
      y="optional"
      width="optional"
      height="optional"
      zOrder="optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)"
      scaleX="optional"
      scaleY="optional"
      rotation="optional"
      opacity="optional"
      lineColor="optional"
      lineWidth="optional"
      fillColor="optional"
      imageFilePath="required"/>

The image at this path parameter expects the full path of the image relative to the current site, e.g. ‘shared documents/images/company_logo.gif’.

QRCode Element

A range of different QR Codes can be added to documents using watermarks, ideal for embedding the document ID, or any kind of other SharePoint metadata.

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<qrcode
      hPosition="optional (absolute, random, left, center, right)"
      vPosition="optional (absolute, random, top, middle, bottom)"
      x="optional"
      y="optional"
      width="optional"
      height="optional"
      zOrder="optional"
      rotation="optional"
      opacity="optional"
      fillColor="#optional"
      lineColor="#optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)"
      scaleX="optional"
      scaleY="optional"
      text="required"
      errorCorrectionLevel="optional (Low, Medium, Quartile, High)"
      inputMode="required (Binary, AlphaNumeric, Numeric)"
      version="optional (Auto, Version01, Version02, Version03
                  ... Version40)" />

Linear Barcode Element

A range of different barcodes can be added to documents, ideal for embedding tracking numbers, and other metadata.

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<linearBarcode
      hPosition="optional (absolute, random, left, center, right)"
      vPosition="optional (absolute, random, top, middle, bottom)"
      x="optional"
      y="optional"
      width="optional"
      height="optional"
      zOrder="optional"
      rotation="optional"
      opacity="optional"
      fillColor="#optional"
      lineColor="#optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)"
      scaleX="optional"
      scaleY="optional"
      text="required"
      barcodeType="required (Codabar, Code11, Code32, Code39, Code39Extended, Code93, Code93Extended, Code128, Code128A, Code128B, Code128C, GS1Code128)"
      omitStartStopSymbols="optional"
      disableCheckDigit="optional"
      showCheckDigit="optional"
      textLocation="optional (Bottom, None, Top)"
      barcodeToTextGapHeight="optional"
      fontFamilyName="optional"
      fontSize="optional"
      fontStyle="optional (regular, bold, italic, strikeout, underline)"
      textAlignment="optional (Default, Center, Justify, Left, Right)"
      margin="optional" />

PDF Element

Existing PDF files can also be used as a watermark. This could be a dynamic file that is generated from, for example from a MS Word document, and then converted to PDF using the Muhimbi Document Converter. Alternatively, this could be a static PDF file that has been generated manually.

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<pdf
      hPosition="optional (absolute, random, left, center, right)"
      vPosition="optional (absolute, random, top, middle, bottom)"
      x="optional"
      y="optional"
      width="optional"
      height="optional"
      zOrder="optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)"
      scaleX="optional"
      scaleY="optional"
      rotation="optional"
      opacity="optional"
      lineColor="optional"
      lineWidth="optional"
      fillColor="optional"
      pdfFilePath="required" />

The PDF file path parameter expects the full path of the PDF name relative to the current site, e.g. ‘shared documents/static watermarks/company_logo.pdf’.

Note: PDF based watermarks can only be applied to other PDF documents. It is not possible to apply a PDF Watermark to MS Office file formats.

Rectangle Element

A simple rectangle can be added as a watermark.

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<rectangle
      hPosition="optional (absolute, random, left, center, right)"
      vPosition="optional (absolute, random, top, middle, bottom)"
      x="optional"
      y="optional"
      width="required"
      height="required"
      zOrder="optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)"
      scaleX="optional"
      scaleY="optional"
      rotation="optional"
      opacity="optional"
      lineColor="optional"
      lineWidth="optional"
      fillColor="optional" />

Line Element

A line can be added as a watermark.

The XML looks as follows. You can omit any attributes marked as optional from your code when they are not needed. Leaving them in with the ‘optional’ text will cause an error:

<line
      hPosition="optional (absolute, random, left, center, right)"
      vPosition="optional (absolute, random, top, middle, bottom)"
      x="required"
      y="required"
      endX="required"
      endY="required"
      zOrder="optional"
      scaleMode="optional (absolute, exactFit, maintainaspectratio)"
      scaleX="optional"
      scaleY="optional"
      rotation="optional"
      opacity="optional"
      lineColor="optional"
      lineWidth="optional" />

Caveats

Different file formats have their own peculiarities and so it is important to be aware of the limitations and potential issues that may arise using them.

PDF is the ideal format when it comes to watermarking. You can place content anywhere on a page with pixel perfect precision, and each individual page can be targeted exactly. Unfortunately, that is not the case for all file formats.

  1. Modern Office formats only: Watermarking is only supported in modern Office formats (DOCX, XLSX, PPTX). The legacy formats (DOC, XLS, PPT) are not supported. If this causes issues, then use Muhimbi Document Converter to convert old style documents to their modern equivalents, and then perform watermarking.

  2. Layering / z-order: This is true for PDF as well, but make sure you don’t hide your watermarks behind your document’s content. For example, placing your watermark in the background of a non-transparent document such as a scan, will hide the watermark. Note: For MS Excel and MS Word, watermarks are always located behind the document’s main content.

  3. Targeting individual pages: PDF and MS PowerPoint files allow individual pages to be targeted. For example, add the watermark only on the third or last page of the presentation. Unfortunately, this is not possible with MS Word and MS Excel.

In MS Word, watermarks are applied to an entire section. So, it is not possible to target a watermark to a specific page unless that page has its own section. In MS Excel, it is not possible to target individual pages either, and all pages in a worksheet automatically get the same watermark.

It is possible to apply different watermarks to different sheets in the workbook though. If configured accordingly in MS Excel and MS Word, the first page can have a different watermark compared to other pages.

  1. Mandatory MS Word Headers: Watermarks are added in MS Word via page headers. When applying watermarks to MS Word files, it is therefore essential that the headers have not been removed from sections. Our software cannot add watermarks to sections without headers.

  2. Real-time watermarking in MS SharePoint (on premise): The interaction between MS Office and different MS SharePoint on premise versions is extremely complex. To keep things manageable, our software disables co-authoring (multiple people editing the same document at the same time) on libraries that have real-time watermarking enabled and where ‘Apply when editing’ setting is enabled.
    Due to the way Office files are fetched, for the more modern MS SharePoint versions, it is recommended to enable the ‘Apply when editing’ setting to make sure watermarks are consistently applied. This only applies to real-time watermarking, applying watermarks via workflows does not suffer from this limitation.

  3. Office Web Apps: When using real-time watermarking and Internet Explorer is used in combination with Office Web Apps, we recommend setting the ’Default open behavior’ to ‘Open in the client application’ and not to ‘Open in the Browser’ (’Advanced Library Settings’ for the relevant Lists and Libraries).

  4. Real-time Watermarking on Read-Only Files Recommendation: Before implementation, it is recommended that a detailed planning is done on how your documents will be used. For example, let’s say automatic watermarking is enabled every time a document is opened. A user opens the document for editing purposes (which applies a watermark automatically). The document is then saved including the new watermark. When the document is then opened again, a watermark is applied again and again it is opened. It is for this reason that we recommend using either a filter to only apply real-time watermarks for certain situations, or to only enable real-time watermarking on read-only documents or folders specially created and maintained for sharing these watermarked documents.

  5. RTF Watermarks in MS PowerPoint: We support many watermark types including one that allows rich text to be inserted via RTF. Unfortunately RTF is ignored in MS PowerPoint, and it only displays the textual content embedded in the RTF without formatting.

  6. MS Excel Watermarks Require one free Header / Footer Slot Without Image: In MS Excel, watermarks are added via headers and footers. MS Excel has six slots, three in the header and three in the footer. Muhimbi’s software requires at least one slot to have no image present or it will not be able to apply the watermark.

Information

We recently released the Muhimbi Document Converter Xtension for Nintex Automation Cloud. You can download it here or learn more about available Muhimbi deployments for Nintex on our product page.

In this guide you’ll learn how to add watermarks to documents using Nintex Workflows. These workflow actions allow elements such as text, rectangles, images, PDF files, QR Codes, barcodes as well as other shapes to be added as a watermark to a wide variety of documents.

This article covers the watermarking of documents using Nintex Workflows and Nintex Workflow for O365.

Using Nintex Workflows for O365 for Watermarking

Prerequisites

Before you begin, please make sure the following prerequisites are in place:

Please note that this article is for the MS SharePoint Online version of Nintex Workflow.

Building the Workflow

It is strongly recommended to follow the tutorial below, but the workflow is available for download as well. Import it in Nintex Workflow for Office 365, SET THE API KEY, publish it and you are ready to go.

  1. Navigate to a site collection and document library of your choice. You can choose the option to create a new Nintex Workflow. In this example, we use the standard Document Library that is available on most site collections.

  2. Create the following workflow variables as we need them later:

  • JSON (Text): Contains the JSON, JavaScript Object Notation, the command that will be sent to the conversion service.

  • API_KEY (Text): A unique ID that will be used to look up your Muhimbi subscription details.

  • ResponseText (Text): The status message returned by the Conversion Service.

  • ResponseCode (Integer): The status code returned by the Conversion Service.

    workflow variables

  1. You can then insert a Set Workflow Status action, edit it and set it to ‘Started’. As MS SharePoint Online does not show a separate status, adding this action will show us the status that the workflow has actually triggered and it will also give us something to click on to inspect the current status of the workflow.

    set workflow status

  2. You can then add a Build String action and set the Output to the JSON workflow variable. In the String field enter the following:

[
  "sharepoint_file": [
    "site_url": "{Workflow Context:Current site URL}",
    "source_file_url": "{Current Item:Server Relative URL}",
    "destination_file_url": "{Current Item:Server Relative URL}.pdf"
  ],
  "output_format": "PDF",
  "fail_on_error": true
]

build string action

You need to pay attention to the following:

JSON Notation: Please note that we have replaced the curly braces - { } - with square brackets [ ] due to a bug in Nintex Workflow for Office 365. If you have any concerns using square brackets, (as they are also used for Array types) you can replace them with anything else, as we will fix this in a follow-up step.

Copy & Paste: When copying and pasting the JSON code, ensure you paste it in Notepad (and copy back) to strip out non-standard characters and formatting being copied.

References: The text displayed in red are Nintex Workflow references. After copy pasting the code fragment, you need to replace each Nintex reference using the Advanced Lookup facility located below the field.

Output file name: In this basic example, we just add ‘.pdf’ to the end of the output path and file name. This is not particularly pretty, but in order to keep things simple we are not including the Nintex Workflow actions to strip off the old extension and add the new one. You can use whatever you like here as long as it is a valid output path and file name.

  1. In an earlier step, as we have used square brackets in JSON, we need to replace them with curly braces again. You can do this by using Replace Substring in String action and by configuring it as follows:

  • Search String: Enter the opening square bracket [.

  • Replace String: Enter the opening curly brace {.

  • String: Insert a reference to the workflow variable named JSON.

  • Output: Pick the JSON workflow variable to store the results in.

Click Save button.

  1. You can now copy the workflow action using the action’s menu, and by pasting it as the next action. You can configure the newly pasted workflow action and replace the opening bracket with the closing bracket ‘]’.

You can do the same for the curly brace and replace ‘{’ with ‘}’, and click Save button to save the action. You now have valid JSON that you can send to the Conversion Service.

  1. As the next step, we need to set the API_KEY. Insert a Set Workflow Variable action and configure it to set the API_KEY workflow variable to the API Key you received by email when signing up for the Muhimbi Document Converter Services Online. e.g.:

decafbad-baad-baad-baad-decafbaaaaad

Do not try to use this particular key, as it will not work. Ensure you do not put curly braces around the key. Click Save button to save the action.

  1. Next, insert a Web Request action and configure it as follows:

URL: https://api.muhimbi.com/api/v1/operations/convert

Method: POST

Content type: application/json

Add header: Click Add header, specify API_KEY as the Header name and insert a reference to the API_KEY workflow variable for the Header value.

Body: Select the Content option, add a reference to the JSON workflow variable in the Data field.

Store response content in: ResponseText.

Click Save button to save the action.

  1. Finally, insert another Set Workflow Status action and configure it with the text ‘Completed’. This should indicate when the workflow instance has completed its run. Your workflow should look something like the following: Nintex-O365-ConvertBasic-Part1 Nintex-O365-ConvertBasic-Part2

  2. Save and Publish the workflow by giving it a suitable name and set the Start Options to a value of your choice.

  3. Once published, open the document library the workflow is associated with, make sure a file of the supported type is present, and manually start the workflow. After a few seconds, the PDF file will show up next to the file the workflow was started on.

Troubleshooting

Although both Nintex Workflow for Office 365 and the Muhimbi Document Converter work very well together, there are a lot of moving parts in the workflow like custom generated JSON, customer-specific API keys, paths to the document libraries, etc. So, there are chances that you may encounter some issues when deploying the workflow. Some common issues and troubleshooting tips are provided below for your reference:

  • Check prerequisites: Double-check that the prerequisites listed in the beginning of this section are in place.

  • Log to History List: If it is not clear what is going wrong, log critical parts such as the JSON workflow variable (after the replace operation) as well as the ResponseText workflow variable (after the web request) using the Log To History List workflow action. You can see the contents of this list by clicking on the Workflow Status column for the List Item the workflow is running on.

  • Send email: The amount of text that can be logged to the History List is limited (roughly 250 characters). For larger messages, use the Send an Email action instead to send an email with debug content in the body of the email to yourself.

  • Copy & Paste: When copying the JSON fragment into your workflow, paste it into Notepad first to clean it, and then copy it from Notepad and paste it into your workflow. This is because browsers tend to insert hidden characters that are not filtered out by the Nintex Workflow editor.

  • Nintex References: Make sure that the Nintex Workflow references in the JSON provided are replaced by actual Nintex Workflow references. You can double-check if the references are active by logging the JSON workflow variable to the History List. You should see the actual paths and not {Current Item:Server Relative URL}.

  • Muhimbi Support: After double checking all prerequisites and going over all troubleshooting steps in this section, if you are still stuck, please contact our friendly support desk, who are here to help.

Fine-tuning

The workflow created in the previous section was to give a quick idea of how to use the Converter. However, it would benefit from error handling and a solution for a possible recursion problem where the workflow will be triggered for PDF files that it has created by itself.

We have created a version of the workflow that is more production ready. Full details on the same are beyond the scope of this article. You can download the full workflow here and customize this as per your requirements.

After customization, you can import it into Nintex Workflow for Office 365, and set the API KEY, and then publish it for your use.

nintex workflow

nintex for office 365

set api key

Other Operations

This section demonstrated how to invoke the Convert action on Muhimbi’s REST interface. Full examples are beyond the scope of this article, but you can find examples in the SharePoint section of our GitHub repository.

Using Nintex Workflows for Watermarking

Support for SharePoint Designer, a Web Services API as well as a host of other watermarking functionality has been available for a while, but since version 5.1 we have added support for Nintex Workflows as well. In addition to the new PDF Watermarking Nintex Workflow Activity, we are also adding activities for PDF Security, PDF Merging as well as HTML to PDF Conversion.

Similar to all other Nintex Activities provided by Muhimbi, the Watermark PDF activity integrates with Nintex Workflow at a deep level. It supports SharePoint 2007, 2010, 2013 & 2019, allows errors to be handled and even supports integration with Nintex’ iterators to deal with multiple items and loops.

For a comprehensive example and details about how to enable the Nintex Workflow integration see the blog post that discusses our generic Nintex PDF Conversion activity.

workflow activity

watermark document watermark document watermark document

The fields supported by this Workflow Activity are as follows:

  • Destination Path: Enter the path to write the watermarked file to, either:

    • Leave it empty to use the same filename (and path) as the file that triggered the workflow.

    • A file name, without the full path, to write a differently named file to the same location as the source file.

    • A relative path to a subsite / document library / folder, e.g. Shared Documents/Some Folder/Some File.pdf.

    • An absolute path to a different site collection, e.g. /sites/Finance/Shared Documents/Some Folder/Some File.pdf. Please make sure the path does not include the host name, e.g. ‘http://your site/…’..

  • Watermark type: A number of different watermark types are supported. Unlike our individualSharePoint Designer workflow activities, all watermark types have been rolled up into a single Nintex Activity. The functionality is largely the same. The following watermark types are supported.

    • Text: Add a text based watermark with full control over the font type, size, style, rotation and field codes such as {PAGE}.

    • PDF: Add the first page of another PDF file as the watermark.(Not supported in Office file types)

    • QR Code: Add a QR Code as the watermark.

    • Linear Barcode: Add a barcode watermark.

    • Image: Use a BMP, JPG, GIF, PNG, TIFF, WMF or EMF / EMF+ file as a watermark.

    • RTF: Use RTF based text as a watermark

    • Ellipse: Add an ellipse based watermark.

    • Line: Add a line based watermark.

    • Composite: For complex watermarks, or watermarks consisting of multiple elements such as line AND text AND images, use the Composite Watermark in combination with ourXML based watermarking syntax.

  • Display: Either display the watermark Always, or only When Printing. (When supported by target file format)

  • Output List ID: If you wish to carry out further actions on the watermarked file, e.g. send it by email or perform a check-in, then you can optionally write the ID of the List the file was written to in a workflow variable of type String.

  • Output List Item ID: Similarly to PDF List ID, the Item ID of the watermarked file can optionally be written to a workflow variable of type Item ID (in SharePoint 2007) or Integer (in SharePoint 2010 and later versions).

  • Source List ID & List Item: The item that triggered the workflow is watermarked by default. You can optionally specify the ID of a different List and List Item using workflow variables. Please use the same data types as used by Output List ID and Output List Item ID.

  • Error Handling: Similar to the way some of Nintex’ own Workflow Activities allow errors to be captured and evaluated by subsequent actions, all of Muhimbi’s Workflow Activities also allow the same. By default, this facility is disabled meaning that any error terminates the workflow.

Additional Resources