We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Watermark is only getting added to the pdf and the original content is missing

Hi Team,

Below is the code I am using to create watermark in a pdf document. It is creating watermark but the actual content in the pdf is missing.

private static void InsertWatermarkText(Document doc, string watermarkText)

            // Create a watermark shape. This will be a WordArt shape. 
            // You are free to try other shape types as watermarks.
            Shape watermark = new Shape(doc, Aspose.Words.Drawing.ShapeType.TextPlainText);
            watermark.Name = "WaterMark";
            // Set up the text of the watermark.
            watermark.TextPath.Text = watermarkText;
            watermark.TextPath.FontFamily = "Arial";
            watermark.Width = 50;
            watermark.Height = 50;
            // Text will be directed from the bottom-left to the top-right corner.
            watermark.Rotation = 90;
            // Remove the following two lines if you need a solid black text.
            watermark.Fill.Color = Color.Gray; // Try LightGray to get more Word-style watermark
            watermark.StrokeColor = Color.Gray; // Try LightGray to get more Word-style watermark
            watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Margin;
            watermark.RelativeVerticalPosition = RelativeVerticalPosition.Margin;
            watermark.WrapType = WrapType.None;
            //watermark.VerticalAlignment = VerticalAlignment.Center;
            //watermark.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;

            // Create a new paragraph and append the watermark to this paragraph.
            Paragraph watermarkPara = new Paragraph(doc);

            // Insert the watermark into all headers of each document section.
            foreach (Section sect in doc.Sections)
                // There could be up to three different headers in each section, since we want
                // The watermark to appear on all pages, insert into all headers.
                InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);
                InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);
                InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);

        private static void InsertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, HeaderFooterType headerType)
            HeaderFooter header = sect.HeadersFooters[headerType];

            if (header == null)
                // There is no header of the specified type in the current section, create it.
                header = new HeaderFooter(sect.Document, headerType);

            // Insert a clone of the watermark into the header.

Could you please advise?


Thank you for contacting support.

We have noticed that you are working with some outdated version of the API. Please upgrade to Aspose.PDF for .NET 18.9.1 because it includes more features and bug fixes. Also the support is provided based on latest available version. You may add a watermark to any document as explained in Adding Text Stamp in the PDF File.

If you still face any problem, then please share your code snippet along with source and generated files so that we may investigate further to help you out.