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

Free Support Forum - aspose.com

Center rotated watermark Text in PDF


Using the demo project it's easy to put a watermark from a text in a PDF file.

What it's not easy is to alway draw the stamp (watermark) in the PDF page center when the there is a rotation. Since it's not possible to know the width and height of FormattedText object after a rotation or the size of the stamp object after the rotation.

Here's the step I do:

  • I am creating a stamp and using Stamp.BindLogo to set some FormattedText to stamp on the PDF.
  • Rotate the Stamp object
  • Set the Stamp object location, but cannot set it because I don't know the rotated Stamp size
  • Add the Stamp to the pdfStamp object


Hi Simon,

Thank you very much for considering Aspose.

I would like to share with you that while placing the stamp, you can calculate the center based on the height and width of the page i.e height/2 and width/2; these height and width values can be obtained using PdfFileInfo class. However, in order to calculate the disposition of the stamp, when text is rotated, you will have to estimate the new values using your own code. This estimation might be based on the number of characters in your text stamp and the font size etc. I’m afraid, there is currently no way to calculate the exact center point at the moment. Nevertheless, if you could elaborate your requirement a little bit and mention the platform you’re working with – .NET or Java – we’ll try to provide support for such a feature in our future versions.

We’re sorry for the inconvenience and looking forward to help you out.


I'm working in .Net and my requierement is simply to add a text watermark in the center of an existing PDF file. Since the PDF format can be letter, legal or any size, I need to compute the watermark position for each pdf page.

I have already found the info about the page size with the PdfFileInfo class.

Since I simply need to add text I create an Aspose.Pdf.Kit.FormattedText object that I add to the Stamp object using the BindLogo function. This works very well and it's well describe in the Demo project.

The Aspose.Pdf.Kit.FormattedText object have properties to retrieve the width and height of the object. But I can only use these value to center the watermark if there is no rotation on the Stamp object. Because if there is a rotation apply to the stamp object, the values from the FormattedText loose there meaning. Hope you understand the problem.

What would have really help me is having Width and Height properties on the Stamp object. Values that change with the rotation. Having the value as properties of the Stamp object will also help center watermark from both image files and String. Unless there is a specific function to do that works.

Thank you

Hi Simon,

Thank you very much for sharing further details.

As I shared earlier, this feature is currently not available; however, I have logged a new feature request as PDFKITNET-26170 in our issue tracking system. Our team will look into this requirement and you’ll be updated via this forum thread once it is supported in our future versions.

We’re sorry for the inconvenience.


I too would like to see this feature. Any word on when it will be implemented as it’s been 6 months since your last post here? I have a text (not image) watermark that I need absolutely centered on the page and “guessing” what the “bounding box” of the rotated text will be is just not cutting it for me.

Secondly, I found out that your formattedText.TextHeight and formattedText.TextWidth are only being calculated for the first line in the stamp when they should factor in all lines in the stamp. Here’s my workaround, but it’s not very accurate as it only calculates a width adjustment based on the number of characters in each line and doesn’t account for character spacing (caps, character width, etc.)
//NOTE: The TextWidth and TextHeight are only calculated on the first line of the formattedText object, so manual calculations have to be performed
//NOTE: TextHeight is calculated by multiplying the number of lines times the TextHeight, but calculation of the TextWidth is more cumbersome and inaccurate
float textHeight = formattedText.TextHeight * textLines.Length;
float textWidth = formattedText.TextWidth;
int maxTextLineLength = 0;
foreach (var textLine in textLines)
if (textLine.Length > maxTextLineLength)
maxTextLineLength = textLine.Length;
if(maxTextLineLength > textLines[0].Length)
textWidth = ((float)maxTextLineLength / (float)textLines[0].Length) * (int)formattedText.TextWidth;

Basically, the TextHeight and TextWidth of the text box needs to account for the number of lines in the stamp and the rotation angle.
Finally, do you have any plans to allow for horizontal alignment of the stamp text when there are multiple lines?  For example, if I have a stamp placed in the lower right hand corner, I might want the text right aligned or perhaps even have the text centered among all lines.  Do you anticipate adding this functionality?

Hi Brian,

I’m sorry to share with you that this issue is not yet resolved. However, I’m moving this thread to the Aspose.Pdf forum as Aspose.Pdf.Kit for .NET has been merged into Aspose.Pdf for .NET and the respective team would be able to follow up and get back to you with any updates.