ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Printing and Previewing Task-Based Help > Formatting Tables > Adding a Watermark Image

Adding a Watermark Image

To set the page size for the document, use the Watermark property.

1.   From the Toolbox, add the C1PrintPreviewControl and C1PrintDocument components to your project.

2.   Click C1PrintPreviewControl1 to select it, and in the Properties window set its Document property to C1PrintDocument1.

3.   Switch to Code view and add the following namespace declaration:

      Visual Basic

Imports C1.C1Preview

      C#

using C1.C1Preview;

4.   Add the following Form_Load event, which uses the Watermark property to add a watermark to the page, and replace c1logo.png with your image's name and location:

      Visual Basic

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    ' Create watermark and layout.

    Dim waterMark As New RenderImage

    Dim pl As New C1.C1Preview.PageLayout()

   

    ' Set the watermark image; replace c1logo.png with your image's name.

    waterMark.Image = Image.FromFile("c:\c1logo.png")

    waterMark.Y = New Unit(2, UnitTypeEnum.Inch)

    pl.Watermark = waterMark

    Me.C1PrintDocument1.PageLayout = pl

 

    ' Generate the document.

    Me.C1PrintDocument1.Generate()

End Sub

      C#

private void Form1_Load(object sender, EventArgs e)

{

    // Create watermark and layout.

    RenderImage waterMark = new RenderImage();

    C1.C1Preview.PageLayout pl = new C1.C1Preview.PageLayout();

   

    // Set the watermark image; replace c1logo.png with your image's name.

    waterMark.Image = Image.FromFile("c:\\c1logo.png");

    waterMark.Y = new Unit(2, UnitTypeEnum.Inch);

    pl.Watermark = waterMark;

    this.c1PrintDocument1.PageLayout = pl;

   

    // Generate the document.

    this.C1PrintDocument1.Generate();

}

 What You've Accomplished

A watermark is added to the page:

 


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.