Free Support Forum - aspose.com

Footnote with multiple Styles


#1

Hi,
I would like to create a footnote with multiple styles (Eg: Part of the footnote text is bold, part of it is italic, etc).
Please let me know how to create such a footnote.
Regards,
Vishnu


#2

@vthumatty,

Please ZIP and attach your input Word and expected document showing the desired output here for our reference. You can create expected document by using MS Word. We will then investigate the structure of your expected document and provide you code to achieve the same by using Aspose.Words.


#3

Please find attached a word document containing a footnote with multiple styles like strikethrough, Bold Italics for parts of its text.AsposeExample.zip (16.7 KB)


#4

@vthumatty,

You can meet this requirement by using the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Some text is added.");

Footnote footnote = new Footnote(doc, FootnoteType.Footnote);
builder.CurrentParagraph.AppendChild(footnote);
footnote.Paragraphs.Add(new Paragraph(doc));

Run bRun = new Run(doc, "Bold text. ");
bRun.Font.Bold = true;

Run stRun = new Run(doc, "StrikeThrough text. ");
stRun.Font.StrikeThrough = true;

footnote.FirstParagraph.Runs.Add(stRun);
footnote.FirstParagraph.Runs.Add(bRun);

builder.Document.Save("E:\\Temp\\18.12.docx");

#5

Hi Awais,
Thanks for your response. I would like to use insertFootnote() method:

builder.insertFootnote(FootnoteType.FOOTNOTE, “some text”);

instead of adding the footnote to the current paragraph as indicated in your example.

Is it possible?
Regards,
Vishnu


#6

@vthumatty,

Yes, you can achieve the same results by using the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Some text is added.");

Footnote footnote = builder.InsertFootnote(FootnoteType.Footnote, "StrikeThrough text.");

Run stRun = (Run)footnote.FirstParagraph.LastChild;
stRun.Font.StrikeThrough = true;

Run bRun = new Run(doc, " Bold text. ");
bRun.Font.Bold = true;

footnote.FirstParagraph.Runs.Add(bRun);

builder.Document.Save("E:\\Temp\\19.1.docx");

#7

It works !!! Thanks !!!