Spread Windows Forms 13.0 Product Documentation
Spread Windows Forms 13.0 Product Documentation / Developer's Guide / Managing Printing / Customizing the Appearance of the Printing / Adding a Watermark to a Printed Page
In This Topic
    Adding a Watermark to a Printed Page
    In This Topic

    You can print a background image or a watermark when the spreadsheet is printed.

    Set the PrintBackground event to fire when printing, and specify the graphic with the PrintBackground event, and the opacity with the PrintInfo.Opacity property, so the printing of the spreadsheet has no watermark if opacity is highest (transparency is lowest) and shows the watermark through the spreadsheet if the opacity is low (transparency is high).

    Using Code

    Use the PrintInfo object to specify the opacity for printing a watermark.

    Example

    This example shows how to print a watermark.

    C#
    Copy Code
    private void fpSpread1_PrintBackground(object sender, FarPoint.Win.Spread.PrintBackgroundEventArgs e)
    {
        FarPoint.Win.Picture pic = new FarPoint.Win.Picture(System.Drawing.Image.FromFile("D:\\Files\\cover.jpg"), FarPoint.Win.RenderStyle.Normal);
        pic.AlignHorz = FarPoint.Win.HorizontalAlignment.Left;
        pic.AlignVert = FarPoint.Win.VerticalAlignment.Top;
        pic.Paint(e.Graphics, e.SheetRectangle);
    }
        
    
    private void button1_Click(object sender, System.EventArgs e)
    {
        FarPoint.Win.Spread.PrintInfo pi = new FarPoint.Win.Spread.PrintInfo();
        pi.Opacity = 100;
        fpSpread1.ActiveSheet.PrintInfo = pi;
        fpSpread1.PrintSheet(0);
    }
    VB
    Copy Code
    Private Sub fpSpread1_PrintBackground(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.PrintBackgroundEventArgs) Handles FpSpread1.PrintBackground
        Dim pic As New FarPoint.Win.Picture(Image.FromFile("D:\Files\cover.jpg"), FarPoint.Win.RenderStyle.Normal)
        pic.AlignHorz = FarPoint.Win.HorizontalAlignment.Left
        pic.AlignVert = FarPoint.Win.VerticalAlignment.Top
        pic.Paint(e.Graphics, e.SheetRectangle)
    End Sub
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pi As New FarPoint.Win.Spread.PrintInfo()
        pi.Opacity = 100
        fpSpread1.ActiveSheet.PrintInfo = pi
        fpSpread1.PrintSheet(0)
    End Sub
    See Also