Adding repeated watermarks

Rrepeated watermark

Enhance the visual appeal and branding of your documents with the power of repeated or tiled watermarks. This innovative feature allows you to seamlessly integrate patterns of text or images across your pages, creating a professional and cohesive look. Whether you’re aiming for subtle branding, artistic expression, or document security, the ability to configure the spacing, rotation, and style of these watermarks provides unparalleled customization. Explore the possibilities and make your documents stand out with the elegance of tiled watermarks.

Text repeated watermark

The provided code snippet demonstrates how to add a tiled watermark to a document. To configure tiling settings, we can utilize the dedicated class TileOptions. In this example, we set the LineSpacing property, determining the spacing between parallel tiles, to 12 percent of the page size. Additionally, we define the WatermarkSpacing property, which sets the spacing between watermarks in the line, to be 10 percent of the page size. Next image helps to understand the purpose of LineSpacing and WatermarkSpacing settings: adding-repeated-watermarks

Furthermore, we apply a watermark rotation of 30 degrees for added customization.

    using (Watermarker watermarker = new Watermarker(Constants.InDocumentPdf))
    {
        // Initialize the font to be used for watermark
        Font font = new Font("Arial", 19, FontStyle.Bold | FontStyle.Italic);

        // Create the watermark object
        var watermark = new TextWatermark("Test watermark", font);

        // Configure tile options
        watermark.TileOptions = new TileOptions()
        {
            LineSpacing = new MeasureValue()
            {
                MeasureType = TileMeasureType.Percent,
                Value = 12
            },
            WatermarkSpacing = new MeasureValue()
            {
                MeasureType = TileMeasureType.Percent,
                Value = 10
            },
        };

        // Set watermark properties
        watermark.Opacity = 0.3;
        watermark.RotateAngle = -30;

        // Add watermark
        watermarker.Add(watermark);

        watermarker.Save(Constants.OutDocumentPdf);
    }        

The output of the aforementioned code is represented below, showcasing repeated text watermarks: text repeated watermarks

Additionally, the class TileOptions includes a TileType property, providing the ability to configure the tile view. The default value is Straight mode, but we can change it. For instance, in the previous example, if we add the setting

   watermark.TileOptions.TileType = TileType.Offset

it enables the offset style. In the context of watermarks and tiling, the “offset style” refers to a specific arrangement where each tile is positioned with a shift or offset from the previous one. Instead of aligning tiles in a straightforward, parallel manner, the offset style introduces a displacement, creating a more dynamic and visually interesting pattern. This shift can occur horizontally, vertically, or both, depending on the specific settings applied. In this case, the output will exhibit the following effect: adding-repeated-watermarks

Image repeated watermark

The repeated watermark feature also supports image watermarks. The following C# code demonstrates how to add repeated image watermarks to a PDF document with rotation.

    using (Watermarker watermarker = new Watermarker(Constants.InDocumentPdf))
    {
        // Initialize the font to be used for watermark
        Font font = new Font("Arial", 19, FontStyle.Bold | FontStyle.Italic);

        // Create the image watermark object
        var watermark = new ImageWatermark(imagePath);

        // Configure tile options
        watermark.TileOptions = new TileOptions()
        {
            LineSpacing = new MeasureValue()
            {
                MeasureType = TileMeasureType.Percent,
                Value = 12
            },
            WatermarkSpacing = new MeasureValue()
            {
                MeasureType = TileMeasureType.Percent,
                Value = 10
            },
        };

        // Set watermark properties
        watermark.Opacity = 0.3;
        watermark.RotateAngle = -30;

        // Add watermark
        watermarker.Add(watermark);

        watermarker.Save(Constants.OutDocumentPdf);
    }        

This is the resulting appearance of the document after applying tiled image watermarks: adding-repeated-watermarks