This sample project shows how to create and insert a watermark image on all pages dynamically. Image objects have the Name property to store additional string information with an image. This property is used to tag the inserted watermark images in order to find them in the ImageCollection.
In a first step, all watermark images are removed. In order to remove the specific images, all tagged images are collected in a List and finally removed from the ImageCollection:
After that, on each page, a new watermark image is inserted at a fixed position, vertically and horizontally centered. The Name property is set to "Watermark" and the image won't be sizable and moveable.
On the TextControl Changed event, a simple condition checks whether the current number of pages has been increased. If yes, a new watermark is inserted:
To complete the code description: The method CreateDraftImage returns a Bitmap with the gray text "DRAFT" that is used as a watermark image.
The following screenshot shows the watermarks in the TX Text Control .NET for Windows Forms:
Download the sample from GitHub and test it on your own.
Download and Fork This Sample on GitHub
We proudly host our sample code on github.com/TextControl.
Please fork and contribute.
Requirements for This Sample
- Visual Studio 2012 or better
- TX Text Control .NET for Windows Forms (trial sufficient)