linkedinfacebooktwittermenuarrow-up

GemBox Support Forum

Change Paragraph Alignment within Paragraph

So, I want to change the TextAlignment within my Paragraph.

grafik

My first idea was to use the TabStop, but I cant find the end of the content as double, which would be needed for TabStop, neither can I insert the TabStop via paragraph.Content.End.InsertRange(tabstop);

There is no such thing.

What you need to do is get the location of the right position and then use the TabStopAlignment.Right.
For example, something like this:

var paragraph = new Paragraph(document);
paragraph.ParagraphFormat.Tabs.Add(new TabStop(200, TabStopAlignment.Right));

paragraph.Inlines.Add(new Run(document, "left text"));
paragraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.Tab));
paragraph.Inlines.Add(new Run(document, "right text"));

I hope this helps.

How can I do this when my left text has a variable length?

It doesn’t matter, you do it the same way I showed above.