Aspose.Pdf not able to add text watermark in existing pdf file

I am trying to add text watermark in existing pdf file but watermark is not getting added. Temporary License is using here as if we are getting success we are planing to purchase the product.
Here is the following C# dot net code I am using. Please provide correct code snipped

//open document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputFile);

                //create text stamp
                TextStamp textStamp = new TextStamp(watermark);
                //set whether stamp is background
                textStamp.Background = true;
                //set origin
                textStamp.XIndent = 100;
                textStamp.YIndent = 100;
                //rotate stamp
                textStamp.Rotate = Rotation.on90;
                //set text properties
                textStamp.TextState.Font = FontRepository.FindFont("Arial");
                textStamp.TextState.FontSize = 18.0F;
                textStamp.TextState.FontStyle = FontStyles.Bold;
                textStamp.TextState.FontStyle = FontStyles.Italic;
                textStamp.TextState.ForegroundColor = 
                //add stamp to particular page
                //save output document


Thanks for contacting support.

I have tested the scenario using the code snippet which you have shared, with Aspose.Pdf for .NET 17.8 and I was unable to notice any issue. The text stamp was added successfully in the existing PDF document. For your reference, I have attached sample Input/Output document as well.

Catalog_With_Watermark.pdf (81.5 KB)
Catalog.pdf (63.0 KB)

Furthermore, there is a possibility that text stamp is being added in your document and you are not able to see it, as you have set textStamp.Background = true; in your code. This way the text stamp will be layed lower the original content of the PDF document. If so is the case, please try again after removing that line and in case if you still face any issue, please share your document with us. We will test the scenario in our environment and address it accordingly.

Thanks for your quick response. Its working fine now


Thanks for the acknowledgement. We are glad to hear that your problem is resolved. Please continue using our APIs and in the event of any further query, please feel free to contact.

One more thing I am struggling now . I want watermark should be placed diagonally middle of the page. But not found any option. Could you please help on this? The Font size is 100.0f


Thanks for contacting support.

In order to achieve your requirement please use following properties along with their respective values.

textStamp.HorizontalAlignment = HorizontalAlignment.Center;
textStamp.VerticalAlignment = VerticalAlignment.Center;
//rotate stamp
textStamp.TextState.FontSize = 100.0F;
textStamp.RotateAngle = 45; 

For your reference, a sample document generated with above values is also attached. In case of any further assistance, please feel free to contact us.

Catalog_WithDiagonalWatermark.pdf (81.6 KB)

Thanks again for your quick support. Its works :slight_smile:


Thanks for your feedback.

Please keep using our API and in event of any further query, please feel free to contact us. We will be more than happy to extend our support.