Insert Page field in the document footer with right alignment using C#

Hi,
i am using the below code to add page number to the document. This code is adding page number to the left corner of the footer.is there a way to move the page number to the right corner of the footer
docBuilder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
// Add fields for current page number
docBuilder.InsertField(“PAGE”, “”);
thank you

@vikasm361

Please set the paragraph alignment as right to get the desired output. Please check the following code example. Hope this helps you.

Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);
docBuilder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
docBuilder.InsertField(FieldType.FieldPage, false);

doc.Save(MyDir + "20.2.docx");