How to show different style formatted text in footer

Hello Team ,

I need to show following text below in footer of my word document

AT&T Proprietary: The information contained herein is for use by authorized
persons only and is not for general distribution.

I coded like below but it did not help me , Please suggest in code to get how desired result.

-----Code----
pageSetup.DifferentFirstPageHeaderFooter = true;

    // --- Create header for the first page. ---
    pageSetup.HeaderDistance = 20;
    builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
    builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

    // Set font properties for Header/Footer text.

    Aspose.Words.Style style_footer = doc.Styles.Add(StyleType.Paragraph, "MyStyle1");
    style_footer.Font.Size = 7.5;
    style_footer.Font.Name = "Calibri";

    Aspose.Words.Style style_bold_footer = doc.Styles.Add(StyleType.Paragraph, "MyStyleBold1");
    style_bold_footer.Font.Size = 7.5;
    style_bold_footer.Font.Bold = true;
    style_bold_footer.Font.Name = "Calibri";

           builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
    pageSetup.FooterDistance = 10;       
    builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Center;
    builder.InsertImage(bluehr, RelativeHorizontalPosition.Page, 0, RelativeVerticalPosition.Page, 0, 550, 1, WrapType.Inline);
    Aspose.Words.Tables.Table table_footer = builder.StartTable();


    builder.CellFormat.ClearFormatting();
    // Set first cell to 20% of the page width.
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
    builder.ParagraphFormat.Style = style_footer;
    builder.Writeln("");
    builder.Writeln(deaddt);
    builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
    builder.CellFormat.ClearFormatting();

    // Set the second cell to 60% of the page width.
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(65);
    ParagraphFormat paragraphFormat = builder.ParagraphFormat;
    paragraphFormat.Alignment = ParagraphAlignment.Center;
    FieldIf fieldIf = (FieldIf)builder.InsertField(FieldType.FieldIf, false);
    builder.MoveTo(fieldIf.Separator);
    builder.InsertField(FieldType.FieldPage, true);  
    builder.Write(" > 3 \"Page ");
    builder.MoveTo(fieldIf.Separator);
    FieldFormula ff = (FieldFormula)builder.InsertField(FieldType.FieldFormula, false);
    builder.MoveTo(ff.Separator);

    builder.InsertField(FieldType.FieldPage, true);
    builder.Write(" - 3 ");
    builder.MoveToField(ff, true);
    builder.Write("\"");
    doc.UpdateFields();
    builder.MoveToField(fieldIf, true);

    builder.Writeln("");      
    builder.ParagraphFormat.Style = style_bold_footer;
    builder.Write("ATT Proprietary:");
    builder.ParagraphFormat.Style = style_footer;
    builder.Write("The information contained herein is for use by authorized");
    builder.Writeln(" persons only and is not for general distribution.");

    builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Center;
    builder.CellFormat.ClearFormatting();

Thanks
Abhishek

Capture.JPG (19.6 KB)

@plasmacomp,

Please ZIP and attach the following resources here for testing.

  • Input Word document
  • Aspose.Words generated output document showing the undesired behavior
  • Expected document showing the desired output. Please create expected document by using MS Word.

We will then investigate the scenario on our end and provide you code to achieve the same by using Aspose.Words. Thanks for your cooperation.

Hi Hafeez,

Please find the attached code in which i am creating document by reading attached html file.
Expected document is also attached where i need first text of footer (AT&T Proprietary:) in bold and rest of text as normal.code.zip (28.7 KB)

Thanks
Abhishek

@plasmacomp,

We are working over your query and will get back to you soon.

Any luck guys?

@plasmacomp,

Please spare us some time to investigate the issue on our end. We will test this on our end and will get back to you soon.

@plasmacomp,

Please use the following code to get the desired output:

...
...
FieldIf fieldIf = (FieldIf)builder.InsertField(FieldType.FieldIf, false);
builder.MoveTo(fieldIf.Separator);
//Insert the page field
builder.InsertField(FieldType.FieldPage, true);
builder.Write(" > 3 \"Page ");
builder.MoveTo(fieldIf.Separator);
FieldFormula ff = (FieldFormula)builder.InsertField(FieldType.FieldFormula, false);
builder.MoveTo(ff.Separator);
//Insert the page field
builder.InsertField(FieldType.FieldPage, true);
builder.Write(" - 3 ");
builder.MoveToField(ff, true);
builder.Write("\"");
doc.UpdateFields();
builder.MoveToField(fieldIf, true);
builder.Writeln("");
builder.Font.Bold = true;
builder.Write("AT&T Proprietary: ");
builder.Font.Bold = false;
builder.Writeln("The information contained herein is for use by authorized ");
builder.Writeln("persons only and is not for general distribution.");
builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.ClearFormatting();
...
...

It really helpful!!
Thank you so much Hafeez

Regards
Abhishek