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

Free Support Forum - aspose.com

Footer at Left and Right

Hi,

I would like to write Footer in Left and Page Number in Right side of the document, But Both are writing in the Right side of the footer.Please find the below code i have used.Can anyone help me on this issue.

var doc = new Document(strFilePath);
var builder = new DocumentBuilder(doc);

builder.PageSetup.DifferentFirstPageHeaderFooter = true;

builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.ParagraphFormat.TabStops.Add(474.9, TabAlignment.Right, TabLeader.None);
builder.Write(
“Left Header” + ControlChar.Tab + “Right Header”);

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.Write(“Left Footer”);

builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Write("Page “);
builder.InsertField(“PAGE”);
builder.Write(” of ");
builder.InsertField(“NUMPAGES”);

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Write("Page “);
builder.InsertField(“PAGE”);
builder.Write(” of ");
builder.InsertField(“NUMPAGES”);

doc.UpdatePageLayout();
doc.UpdateFields();

doc.Save(strFilePath);

Regards,
Kavi


Hi Kavi,


Thanks for your inquiry. Please try executing the following simplified code which explains how you can achieve this:

Document doc = new
Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

builder.ParagraphFormat.TabStops.Add(474.9, TabAlignment.Right, TabLeader.None);

builder.Write("Left Footer" + ControlChar.Tab);

builder.Write("Page ");

builder.InsertField("PAGE");

builder.Write(" of ");

builder.InsertField("NUMPAGES");

doc.Save(MyDir + @“out.doc”);


I hope, this helps.

Best regards,