Not able to align the text added using TextFragment

I am trying to add text with three alignment options i.e., Top, Bottom, Centre.
Sample code:

var doc = new Document(“d://Input.pdf”);
var textValue = “Test Address”;

Page page = doc.Pages[1];
page.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);

// First Text box (TOP)
Aspose.Pdf.Drawing.Rectangle rectfirst = new Aspose.Pdf.Drawing.Rectangle(127.949623, 571.9400634765625, 139.511337, 35.4562454);
var colorName = ColorTranslator.FromHtml("#FFFF00");
rectfirst.Text = new TextFragment(textValue);
rectfirst.Text.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top;
rectfirst.GraphInfo.Color = Aspose.Pdf.Color.FromRgb(colorName);

// SECOND Text box (CENTER)
Aspose.Pdf.Drawing.Rectangle rectsecond = new Aspose.Pdf.Drawing.Rectangle(277.4811, 571.9400634765625, 139.511337, 35.4562454);
rectsecond.Text = new TextFragment(textValue);
rectsecond.GraphInfo.Color = Aspose.Pdf.Color.FromRgb(colorName);

// Third Text box (bottom)
Aspose.Pdf.Drawing.Rectangle rectThird = new Aspose.Pdf.Drawing.Rectangle(427.0126, 571.9400634765625, 139.511337, 35.4562454);
rectThird.Text = new TextFragment(textValue);
rectThird.Text.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom;
rectThird.GraphInfo.Color = Aspose.Pdf.Color.FromRgb(colorName);


input.pdf (206.4 KB)
output.pdf (268.1 KB)

However, using the above code all the text comes in the centre.

Is there any way the text inside rectangle can be aligned top, bottom or centre?


We were able to notice the issue at our side while testing the scenario and have logged it as PDFNET-49205 for further investigation. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Any Update for above reported issue is it resolve? what should i have to do for this.


We are afraid that the earlier logged issue is not yet resolved due to other issues in queue which were logged prior to it. However, we will surely inform you as soon as we have some definite updates regarding its resolution. We highly appreciate your patience and comprehension in this matter.

We apologize for the inconvenience.

PS: You may please check our priority support option in case you want to get it resolved on urgent basis.


I encountered exactly the same problem.
It has a solution in the new versions (I use 21.3) ?


Regretfully, the ticket is not yet resolved as it is pending for investigation at the moment. We have recorded your concerns and will surely inform you once it is resolved. Please give us some time.

We are sorry for the inconvenience.