Add page number in rtf using HTML and handlebars

Hi,

I am creating my document from html to rtf using aspose.words.
I have the following html div in my footer and need to populate the handle bar with the page and total number of pages. Is there a way to do that using any aspose property?

div style=“font-family: OpenSans; font-size: 10pt; text-align: right; color:#1A2B57; padding:5px 0 5px 0;”>PAGE {page} OF {total-pages}</div

Instead of using the following:

builder.Write("Page “);
builder.InsertField(“PAGE”, “”);
builder.Write(” of ");
builder.InsertField(“NUMPAGES”, “”);

Also, is padding css property supported from html to rtf?

@sophiakhan,

Aspose.Words will create real PAGE and NUMPAGES fields in output RTF file during inserting following HTML:

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

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertHtml("<p><span>Page </span><span style=\"-aw-field-start:true\"></span><span style=\"-aw-field-code:' PAGE  '\"></span><span style=\"-aw-field-separator:true\"></span><span>1</span><span style=\"-aw-field-end:true\"></span><span> of </span><span style=\"-aw-field-start:true\"></span><span style=\"-aw-field-code:' NUMPAGES  '\"></span><span style=\"-aw-field-separator:true\"></span><span>2</span><span style=\"-aw-field-end:true\"></span></p>");

builder.MoveToDocumentStart();
for (int i = 1; i < 10; i++)
{
    builder.Writeln("Page " + i);
    builder.InsertBreak(BreakType.PageBreak);
}

doc.Save(@"C:\Temp\a RTF file.rtf"); 

Please check this RTF file (21.1.zip (2.0 KB)) that was generated by using the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Only one Page");
builder.Writeln();
builder.InsertHtml("<div style=\"font-family: OpenSans; font-size: 10pt; text-align: right; color:#1A2B57; padding:5px 0 5px 0;\">PAGE {page} OF {total-pages}</div>");
doc.Save(@"C:\Temp\21.1.rtf");

Please provide your expected RTF file showing the desired output. You can create this document manually by using MS Word.