C# Code to Align Rich Hebrew Text Structured Document Tags (Content Controls) to Right in Word Document with Aspose.Words for .NET

Hi,

I am creating the word document codefully.
I am adding SDT/content control and then add the text inside it.
My requirement is, SDT should be aligned to Right when the language is hebrew.
How to align SDT to right code fully while creating it ?

In Created word file, If I activate Developer Tab and add new SDT, it gets aligned to right side correctly.
I am thinking, If I can do it in word then I should also be able to do using Aspose.words.

@bipih.oswal,

Please check the following code:

Document doc = new Document(@"C:\Temp\input.docx");
DocumentBuilder builder = new DocumentBuilder(doc);

// create a sample content control
StructuredDocumentTag sdt = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline);
sdt.Tag = "Tag";
sdt.Title = "Tag";
sdt.IsShowingPlaceholderText = true;
sdt.LockContents = true;
sdt.LockContentControl = true;
builder.InsertNode(sdt);

Node node1 = sdt.FirstChild;
builder.MoveTo(sdt.FirstChild);
// write some formatted text in RichText content control
builder.InsertHtml("<b>הלכה למשה מסיני</b>");
node1.Remove();
// insert content control at the end of document
builder.MoveToDocumentEnd();
builder.InsertNode(sdt);
// Get the paragraph of content control and make it right-to-left
Paragraph sdtPara = sdt.GetAncestor(NodeType.Paragraph) as Paragraph;
sdtPara.ParagraphFormat.Bidi = true;

doc.Save(@"C:\Temp\20.11.docx"); 

Hope, this helps in achieving what you are looking for.