Articles in this section
Category / Section

How to add WaterMark to SfDataGrid while printing?

1 min read

SfDataGrid control allows you to print the data displayed in the DataGrid. You can refer here to know more about printing.

You can show WaterMark in SfDataGrid while printing, with the help of PrintPageHeaderTemplate. You can display the WaterMark in various alignments by customizing the PrintPageHeaderTemplate.

You can refer to the following code example to customize the PrintPageHeaderTemplate which shows PrintPageHeaderTemplate like WaterMark.

XAML

<DataTemplate x:Key="watermark">
<TextBlock Text="Syncfusion Software" Foreground="Blue" FontSize="40" Opacity="0.40" Height="70" Width="1070" Padding="220,0,0,0"
TextAlignment="Left"  MaxWidth="1070" MaxHeight="150" VerticalAlignment="Center">
<!--Rotated the Header into 45 degree-->
<TextBlock.RenderTransform>
<RotateTransform Angle="45"/>
</TextBlock.RenderTransform>
</TextBlock>
</DataTemplate>

By using rotate transformation, you can rotate the watermark text. Here, text is rotated at 45 degree. In the following code example, customized datatemplate is assigned to PrintPageHeaderTemplate.

C#

// customized datatemplate "watermark" assigned to PrintPageHeaderTemplate
datagrid.PrintSettings.PrintPageHeaderTemplate = this.Resources["watermark"] as DataTemplate;

C:\Users\ApoorvahR\Desktop\Note.png Note: When you are using the watermark, then the default header template cannot be customized in SfDataGrid.

The following screenshot displays the watermark in SfDataGrid.

Figure 1: Print Preview of SfDataGrid with WithMark

 

Sample Links:

WPF

WRT

UWP

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment