Exemplo n.º 1
0
        public void ToHtml(Document doc, RtfHtmlSettings settings)
        {
            _footnotes.Clear();
            _footnoteIdx = 0;
            _html        = doc.HasHtml ? (IHtmlWriter) new DeencapsulationWriter(_xml) : new HtmlWriter(_xml, settings);

            var body = new Group();

            foreach (var token in doc.Contents)
            {
                if (token is DefaultFontRef defaultFont)
                {
                    _html.DefaultFont = doc.FontTable.TryGetValue(defaultFont.Value, out var font) ? font : doc.FontTable.FirstOrDefault().Value;
                }
                else if (token is DefaultTabWidth tabWidth)
                {
                    _html.DefaultTabWidth = tabWidth.Value;
                }
                else if (token is Group group)
                {
                    if (group.Destination?.Type != TokenType.HeaderTag)
                    {
                        body.Contents.Add(token);
                    }
                }
                else if (token.Type != TokenType.HeaderTag)
                {
                    body.Contents.Add(token);
                }
            }

            ToHtmlGroup(doc, body, true);
            RenderFootnotes(doc);
            _html.Close();
        }