Position of TextStamp YIndent start from Button of the page

I need to place a TextStamp at the position 100, 100 (from top left corner of the document) in the document.
How can I do this? When set YIndent to 100 then the bottom of the TextStamp is 100 points from the bottom of the document.
Just set the YIndent to PageHeight – 100, still not working, because i don’t know the height of the TextStamp.

@GEDAT

Would you kindly share sample text for a text stamp along with a desired PDF document? Also, please share in which platform you are using the API e.g. Java/.NET? We will try to prepare a sample code snippet for you and share it with you.

Hi,

thank you for the response.
I use the .NET API Version 20.x

As Attachment i added two files. 1 is what i expect to get, the second is what i get.
In the Example i added a second TextStamp, only a dot, where i would like the text to start of the second TextStamp.

Hiere is some code:

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fullFileName);

// Create text stamp
TextStamp textStampDot = new TextStamp(".");
textStampDot.Background = false;
textStampDot.XIndent = 100;
textStampDot.YIndent = pdfDocument.PageInfo.Height - 100;
textStampDot.TextState.FontSize = 24;
textStampDot.TextState.ForegroundColor = Color.FromArgb(100, 255, 0, 0);

pdfDocument.Pages[1].AddStamp(textStampDot);

// Create text stamp
TextStamp textStamp = new TextStamp("THIS IS A COPY");
textStamp.Background = false;
textStamp.XIndent = 100;
textStamp.YIndent = pdfDocument.PageInfo.Height - 100;
textStamp.TextState.FontSize = 24;
textStamp.TextState.ForegroundColor = Color.FromArgb(100, 255, 0, 0);
textStamp.Opacity = 0.5f;
textStamp.RotateAngle = 330;

pdfDocument.Pages[1].AddStamp(textStamp);
pdfDocument.Save(fullFileName);

kind regards
Peter

What i need.pdf (38.2 KB)
What i get.pdf (37.8 KB)

@GEDAT

You can please include Page Top Margin in the calculation in order to render the text stamp at your desired location.

TextStamp textStamp = new TextStamp("THIS IS A COPY");
textStamp.Background = false;
textStamp.XIndent = 100;
textStamp.YIndent = pdfDocument.Pages[1].PageInfo.Height - pdfDocument.Pages[1].PageInfo.Margin.Top - 100;
textStamp.TextState.FontSize = 24;
textStamp.TextState.ForegroundColor = Color.FromArgb(100, 255, 0, 0);
textStamp.Opacity = 0.5f;
textStamp.RotateAngle = 330;

pdfDocument.Pages[1].AddStamp(textStamp);

Please let us know if it still does not suit your needs.

Hi Ali,
Thank you for your response.
You are right, I need to include Page Top Margin in my calculation, but this in not enough. I need also the height of the TextStamp. And the TextStamp height depends on the font, font size, rotateAngle …
I added two examples, they are made by the same code, only the length of the text in the TextStamp is different.

The text must always start at the same position, no matter how long it is or which font size or rotateAngle is used.

Kind regards
Peter

Normal Text.pdf (37.8 KB)
Longer Text.pdf (37.8 KB)

@GEDAT

We were able to notice the issue with Aspose.PDF for .NET 20.9 that TextStamp was not honoring the given location when we changed the length of text. Therefore, we have logged an issue as PDFNET-48871 in our issue tracking system. We will further look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.