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

Free Support Forum - aspose.com

Text padding


Is it possible to define the padding of a text object?

for example:
Text ltext = new Text(“Hello World”);
ltext.TextWidth = 400;
ltext.Padding = 10;


Hello Bart,

Thanks for using our products.

In order to define the Padding information for a Text object, please try using the Margin property of Text class. In case you need to define the Top margin of the Text object, please try using Text.Margin.Top = 30; or in case you need to define the left margin, please try using text.Margin.Left = 30; and so is the case with Bottom, Inner, Outer and Right side.


  • TextInfo class has a property named CharSpace which offers the capability to specify a value that indicates the space between characters inside a text string.
  • TextInfo class also contains a property named WordSpace which takes a float value that indicates space between words inside a text string.

In case I've not properly understood your requirement or you've any further query, please feel free to contact.

Thanks for the answer.
When I use margin like
(see also attachments)
Pdf lPdf = new Pdf();
lPdf.DestinationType = DestinationType.FitPage;

MarginInfo lMarginInfo = new MarginInfo();
lMarginInfo.Top = 10;
lMarginInfo.Left = 10;
lMarginInfo.Right = 10;
lMarginInfo.Bottom = 10;

Section lSection = new Section();
lSection.PageInfo.PageHeight = Aspose.Pdf.PageSize.A4Height;
lSection.PageInfo.PageWidth = Aspose.Pdf.PageSize.A4Width;
lSection.PageInfo.Margin = lMarginInfo;

for (int i = 0; i < 10; i++)
TextInfo lTextInfo = new TextInfo();
lTextInfo.FontSize = 16;
lTextInfo.BackgroundColor = new Aspose.Pdf.Color(“Gold”);
lTextInfo.Alignment = AlignmentType.Left;
lTextInfo.FontName = “Helvetica-Bold”;
lTextInfo.TextBorder = new BorderInfo((int)BorderSide.All, 1.5F);
lTextInfo.TextBorder.SetBorderStyle((int)BorderSide.All, Aspose.Pdf.BorderStyle.Normal);

Text lText = new Text("test "+i.ToString(), lTextInfo);
lText.Margin.Left = 20;
lText.Margin.Top = 20;
lText.Margin.Right = 20;
lText.Margin.Bottom = 20;




return lPdf;

I get no left padding (margin) on the inside of my text-frame
and the border is around all text and not around each text object.
See attachments


Hello Bart,

Thanks for sharing the resources.

I've tested the scenario using Aspose.Pdf for .NET 4.1.2 and as per my observation the border around each individual text object is being displayed.

Regarding Text.Margin.Left, the margin information is page relative. I've set the left margin value to 100 and have noticed that the text objects are being displayed correctly. The resultant PDF is also in attachment. Please take a look.

In case you still have any further query, please feel free to contact.


Text.Margin.Left has indeed an influence on the text.
But the space of the left margin appears on the outside of the text frame in contrary of the top margin.
The top margin appears on the inside of the text frame.
You can see it when you test the 4 margins with a background color.
Is it possible to define the inner left margin of the text frame so my text wont stick to the left side of the frame.


Hello Bart,

I have tested the scenario and I’m able to notice that Text.Margin.Left is not working correclty. I have logged it in our issue tracking system as PDFNET-14904. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />