Class RenderingWatermark

RenderingWatermark class

Watermark for rendering.

public class RenderingWatermark

Constructors

NameDescription
RenderingWatermark(byte[])Creates instance of image watermark.
RenderingWatermark(string, RenderingFont)Creates instance of text watermark.

Properties

NameDescription
Font { get; }Gets font of the watermark.
HAlignment { get; set; }Gets or sets horizontal alignment of the watermark to the page.
Image { get; }Gets image of the watermark.
IsBackground { get; set; }Indicates whether the watermark is placed behind page contents.
OffsetX { get; set; }Gets or sets offset value to HAlignment
OffsetY { get; set; }Gets or sets offset value to VAlignment
Opacity { get; set; }Gets or sets opacity of the watermark in range [0, 1].
Rotation { get; set; }Gets or sets roation of the watermark in degrees.
ScaleToPagePercent { get; set; }Gets or sets scale relative to target page in percent.
Text { get; }Gets text of the watermark.
VAlignment { get; set; }Gets or sets vertical alignment of the watermark to the page.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using Aspose.Cells.Rendering;
    using System;
    using System.Drawing;

    public class RenderingWatermarkDemo
    {
        public static void RenderingWatermarkExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Cells["A1"].PutValue("This is a sample worksheet.");

            // Create a font for the watermark
            RenderingFont font = new RenderingFont("Calibri", 68);
            font.Italic = true;
            font.Bold = true;
            font.Color = Color.Blue;

            // Create a watermark from text and the specified font
            RenderingWatermark watermark = new RenderingWatermark("Watermark", font);

            // Set properties for the watermark
            watermark.HAlignment = TextAlignmentType.Center;
            watermark.VAlignment = TextAlignmentType.Center;
            watermark.Rotation = 30;
            watermark.Opacity = 0.6f;
            watermark.ScaleToPagePercent = 50;
            watermark.IsBackground = true;

            // Specify watermark for rendering to PDF
            PdfSaveOptions options = new PdfSaveOptions();
            options.Watermark = watermark;

            // Save the workbook as a PDF with the watermark
            workbook.Save("output_watermark.pdf", options);
        }
    }
}

See Also