Free Support Forum -

Creating a TabStop in the correct position

I'm attempting to create a tabstop in a specific position on my document using the following C# code.

Aspose.Words.Style TOC1Style1 = MasterDoc.Styles[@"TOC 1"];
TOC1Style1.ParagraphFormat.LineSpacing = 16;
TOC1Style1.ParagraphFormat.TabStops.Add(new Aspose.Words.TabStop(7.25, TabAlignment.Right, TabLeader.Dots));

I'm relatively sure I have the correct reference since the linespacing property does take effect. The issue I am having is that the position of the tabstop created when the document is generated comes out at 1 inch where I would like it to be is 7.25 inches.

I blew out the position to 725 to be sure that I had the correct reference for the tabstop and it did effect the layout. So it seems as if there must be something I'm missing in specifying that I want the position to be in inches and not in whatever the default is.




Thanks for your inquiry. I used the following code for testing and it seems that all works fine on my side.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Aspose.Words.Style normalStyle = doc.Styles[StyleIdentifier.Normal];

normalStyle.ParagraphFormat.TabStops.Add(new TabStop(200, Aspose.Words.TabAlignment.Right, TabLeader.Dots));

builder.Write(ControlChar.Tab + "test");


You can attach your document for testing. I will investigate this problem and try to help you.

Best regards.

Yes it works for me too but getting the tabstop into the document is not my issue.

My issue is getting it into the expected position in inches horizontally across the document. Your code defines the position in the constructor of the TabStop to be 200. When the document is generated the actual tabstop position is at 2.78 inches.

So what unit is your 200 expressed in? Or in other words, how do we get from 200 inputted into the constructor to 2.78 inches in the generated document?

I think I'm looking for some sort of conversion that needs to be done to the position parameter in the constructor so that I can define that I want the tabstop position in the generated document to be 7.25 INCHES horizontally across the document? Currently if I use 7.25 as the position parameter in the constructor for the TabStop (as in code provided in the beginning of the thread) the tabstop in the generated document comes out at 0.1 inches horizontally across the document.

thanks for the fast response



Thanks for explanation. Aspose.Words use points as measurement units. I think that you can use the following formula.

1 inch = 72 points.

Best regards.

Works perfectly - thank you!