| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | C# .NET |
| Version: | 1.0 |
| Released: | January 25, 2008 |
| Last modified: | January 28, 2008 |
| Requirements: | TX Text Control .NET with Visual Studio 2005 |
| Download code: | tx_sample_watermark.zip |

As of TX Text Control 14.0, it is possible to add graphics, text or anything else the GDI+ supports to a printed page during the printing process. This allows you to add watermarks to the page, such as the commonly known variations "CONFIDENTIAL" or "DRAFT".
TX Text Control's Print method allows you to print into a PrintDocument or the System.Drawing.Printing namespace. This object provides the PrintPage event that can be used to manipulate the Graphics object.
The following code shows how to create a PrintDocument, how to attach the event and how the document is printed into the PrintDocument:
PrintDocument printDoc = new PrintDocument(); printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); textControl1.PrintPreview(printDoc);
In this event, a string could be added to the Graphics object. This sample adds the string "DRAFT VERSION" to every every page that is printed or previewed by TX Text Control:
Graphics g = e.Graphics; g.TranslateTransform(200, 200); g.RotateTransform(e.PageSettings.Landscape ? 30 : 60); g.DrawString("DRAFT VERSION", new Font("Arial", 75, FontStyle.Bold), _ new SolidBrush(Color.FromArgb(64, Color.Black)), 0, 0);
Note that at least TX Text Control .NET 14.0 trial version and Visual Studio .NET 2005 are required to run this sample.