Font size in doc and rtf- in pdf header disappears on insert of toc

Hello,
In my output documents “doc” and “rtf”, the font size is 8 instead of the expected 10.
In the output document “pdf” it is however ok.
All are based on the same html.
How can I change the font size and enforce it on the existing paragraphs and text?
When I add toc functionality, the pdf loses either its headers of the pages before the toc, or the toc is not generated. This depends on where I execute the toc functionality. How can I fix this?
In that same toc I get an empty line inbetween the tocitems, which are not desired, how can I remove these empty lines?
Best regards,
Kees

Hi

Thanks for your inquiry. Could you please attach your HTML and output documents here? I will check the issue and provide you more information.
Also, it would be great if you provide me a simple code or application, which will allow to reproduce the problem with TOC.
Best regards,

Hello,
I have enclosed the doc output and the html source files.
Below you will find the code sample for the pdf, including the toc creation, which works ok, but results in the headers of the frontpage and the contentpage to not be included, although the footer has no problems.
Best regards,
PDF code sample:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(html);
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.ParagraphFormat.LeftIndent = -_options.Layout.Offsets.Left;
builder.ParagraphFormat.RightIndent = -_options.Layout.Offsets.Right;
builder.InsertHtml(htmlheader);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.ParagraphFormat.LeftIndent = -_options.Layout.Offsets.Left;
builder.ParagraphFormat.RightIndent = -_options.Layout.Offsets.Right;
html = html.Replace("%pn%/%pt%", "[PAGE]/[NUMPAGES]");
builder.InsertHtml(html);
builder.MoveToDocumentStart();
doc.Range.Replace(new Regex(@"\[PAGE\]"), new ReplaceEvaluator(ReplaceWithFieldEvaluator), true);
doc.Range.Replace(new Regex(@"\[NUMPAGES\]"), new ReplaceEvaluator(ReplaceWithFieldEvaluator), true);
builder.MoveToDocumentStart();
doc.Range.Replace(new Regex(@"\[TOC\]"), new ReplaceEvaluator(ReplaceWithFieldEvaluator), true);
builder.MoveToDocumentStart();
builder.Document.UpdateFields();
builder.Document.UpdatePageLayout();
doc.SaveOptions.ExportPrettyFormat = true;
MemoryStream pdf = new MemoryStream();
doc.Save(pdf, SaveFormat.Pdf);
private ReplaceAction ReplaceWithFieldEvaluator(object sender, ReplaceEvaluatorArgs e)
{
    DocumentBuilder builder = new DocumentBuilder((Document) e.MatchNode.Document);
    Run matchrun = (Run) e.MatchNode;
    string runText = matchrun.Text;
    Run run = (Run) e.MatchNode.Clone(true);
    run.Text = runText.Substring(runText.IndexOf(e.Match.Value) + e.Match.Value.Length);
    matchrun.Text = runText.Substring(0, runText.IndexOf(e.Match.Value));
    e.MatchNode.ParentNode.InsertAfter(run, e.MatchNode);
    builder.MoveTo(run);
    if (e.Match.Value == "[PAGE]")
        builder.InsertField("PAGE", null);
    else if (e.Match.Value == "[NUMPAGES]")
        builder.InsertField("NUMPAGES", null);
    else if (e.Match.Value == "[TOC]")
        builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");
    e.Replacement = "";
    return ReplaceAction.Replace;
}

Hi

Thank you for additional information. The problem with Header/Footer occurs because there are few section breaks in your HTML and in your code, you insert header and footer only into the last section. So the first section does not display any headers/footers. I modified your code and now header and footer is properly displayed on each page of the document:

string html = File.ReadAllText(@"Test001\Source.htm");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// First we should insert Header and Footer
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.InsertHtml("Header");
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertHtml("[PAGE]/[NUMPAGES]");
// Then insert main content
builder.MoveToDocumentStart();
builder.InsertHtml(html);
// Replace placeholders with field
doc.Range.Replace(new Regex(@"\[PAGE\]"), new ReplaceWithFieldEvaluator(), true);
doc.Range.Replace(new Regex(@"\[NUMPAGES\]"), new ReplaceWithFieldEvaluator(), true);
doc.Range.Replace(new Regex(@"\[TOC\]"), new ReplaceWithFieldEvaluator(), true);
// Update TOC
builder.Document.UpdateFields();
builder.Document.UpdatePageLayout();
// Save output.
doc.Save(@"Test001\out.doc");
doc.Save(@"Test001\out.pdf");

The problem with font size occurs because Aspose.Words does not support inheriting styles from parent elements in HTML. Currently, Aspose.Words expects that font formatting is set in element, formatting of paragraph – in
or

elements etc…
Best regards,

Hello,
Thanks very much for this information.
I am sorry, I thought that the formatting situation was only limited to the table.
I would like to know where I could find detail information on the style formattin. I am very sure I am not the only nor the first for expressing the need for this information. A difference table between importhtml, creation and export would be a extremely nice feature.
Best regards,
Kees

Hi Kees,

Thanks for your inquiry. We already have a list of supported features upon exporting to HTML. But unfortunately, there is no such list for HTML import. We will let you know once such list is available publicly.
Best regards.

Hello,
Thanks for the information.
I have tried the on part of the code to get the proper font settings, like font size, but regretfully there are no changes whatsoever. The expected font size of 11 points is still 8 points.
Which is very frustrating, the more as you do not have any information towards this, therefore a lot of trail and error must be done, which is very time consuming.
I have tried which also did not work.
If you could supply me with any information why it does not work for the class reference especially, I would highly appreciate it, and even more so how I can get it to work.
Best regards,
Kees

Hi Kees,

Thank you for additional information. Aspose.Words mostly support roundtrip of HTML. So, you can export the expected result (Word document) to HTML using Aspose.Words and see how Aspose.Words expects your HTML should look.
Best regards.

The issues you have found earlier (filed as WORDSNET-3742) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(5)

The issues you have found earlier (filed as WORDSNET-2021) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(21)