# Adding a Watermark to PDF Files Using RadPdfProcessing

## Environment

| Version    | Product          | Author                                                                          |
| ---------- | ---------------- | ------------------------------------------------------------------------------- |
| 2024.2.426 | RadPdfProcessing | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

This article shows how to add a text watermark across all pages of a PDF document using RadPdfProcessing.

## Solution

To add a watermark to PDF pages using RadPdfProcessing, follow these steps:

1. Import the PDF document using [PdfFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider/pdfformatprovider).
2. Iterate through each page of the document.
3. Use [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor) to add a watermark text block to each page.
4. Customize the watermark text properties, color, and position.
5. [Export](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider/pdfformatprovider#export) the document with watermarks back to a PDF file.

The following example shows these steps:

```csharp
        static void Main(string[] args)
        {
            string fileName = "sample.pdf";
            PdfFormatProvider provider = new PdfFormatProvider();
            RadFixedDocument document = provider.Import(File.ReadAllBytes(fileName));

            foreach (RadFixedPage page in document.Pages)
            {
                AddWatermarkText(page, "Watermark text!", 100);
            }

            string exportFileName = "testWatermarks.pdf";
            File.Delete(exportFileName);

            File.WriteAllBytes(exportFileName, new PdfFormatProvider().Export(document));
            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName = exportFileName,
                UseShellExecute = true
            };
            Process.Start(psi);
        }

        private static void AddWatermarkText(RadFixedPage page, string text, byte transparency)
        {
            FixedContentEditor editor = new FixedContentEditor(page);

            Block block = new Block();
            block.TextProperties.FontSize = 80;
            block.TextProperties.TrySetFont(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold);
            block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
            block.GraphicProperties.FillColor = new RgbColor(transparency, 255, 0, 0);
            block.InsertText(text);

            double angle = -45;
            editor.Position.Rotate(angle);
            editor.Position.Translate(0, page.Size.Width);
            editor.DrawBlock(block, new Size(page.Size.Width / Math.Abs(Math.Sin(angle)), double.MaxValue));
        }
```

![Pdf Watermark](https://www.telerik.com/document-processing-libraries/documentation/assets/5185e3b0e713e0ccfe4c809852d2735d/pdf-watermark.png)

## See Also

* [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor)
* [SDK Example: Add Watermark](https://github.com/telerik/document-processing-sdk/blob/master/PdfProcessing/AddWatermark/Program.cs)
