Reports for WinForms | ComponentOne
In This Topic
    Adding a Watermark Image
    In This Topic

    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:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Imports C1.C1Preview
      

      To write code in C#

      C#
      Copy Code
      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:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      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
      

      To write code in C#

      C#
      Copy Code
      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: