HTML table content only loaded within html tag

Hi GemBox Team,

when I load the following HTML text into a document and convert this document to image or to pdf, the content of the table is not included:

<p>Table: </p>
<table>
    <tbody>
        <span>Table content</span>
    </tbody>
</table>

When I add tags around it, the table content is included:

<html>
    <p>Table: </p>
    <table>
        <tbody>
            <span>Table content</span>
        </tbody>
    </table>
</html>

As the tag is not required in HTML-documents or the HTML-body of mails, some document conversions appear to be empty when they only contain a table as content.

How can I ensure, all content is visible exactly as it is when opened in a browser or mail program?

Kind regards,
Sarah

Hi Sarah,

How exactly are you loading this content into a DocumentModel, can you please share your code that reproduces the issue so that I can help you out with it?

Regards,
Mario

Hi Mario,

I use DocumentModel.Load() with the file path or in case of working with mails I use DocumentModel.Content.End.LoadText() with the text as string and LoadOptions.HtmlDefault. The document is then saved as Pdf with DocumentModel.Save() or converted to images by saving it pagewise with DocumentModel.GetPaginator().Pages and DocumentModelPage.Save().

I am using GemBox.Bundle in version 47.0.1024 in a .net472 Application.

Kind regards,
Sarah

Hi Sarah,

This is a specific edge case that occurs because your <tbody> content doesn’t contain a table row, so it ends up being moved outside of it. However, in the case where you’re missing <html> (or <body>) there is no parent element where that invalid <tbody> content could be moved into.

So as a quick fix, can you try this:

<p>Table: </p>
<table>
    <tbody>
        <tr><td><span>Table content</span></td></tr>
    </tbody>
</table>

Does this solve your issue?

Regards,
Mario

Hi Mario,

using the table row tags helps, but I don’t edit the contents in my application’s general workflow. So adding tags is not my preferred solution. Is there any way to handle this within the document loading process, for example ensuring that a document contains valid HTML content when it is loaded with HtmlLoadOptions?

Kind regards,
Sarah

What exactly do you mean by that?
Do you mean that GemBox.Document should repair any HTML irregularity it encounters.

Note that GemBox.Document does try to do that, but I’m afraid some errors are more difficult to recover then others. Or better said, it can be challenging to have the same “repair” behavior as modern browsers have for some of those irregularities.

Nevertheless, we’ll investigate this context further.

Regards,
Mario

Hi Mario,

I was thinking about something like a check for the standard HTML document start tags (as or ) and some sort of exception or note if they are missing completely. But I am not sure if this behaviour causes more problems than it solves, as these tags are not required for mails with HTML body (this is the context in which the problem originally occurred).

Thank you for looking into it.

Kind regards,
Sarah

Please try again with this bugfix:
https://www.gemboxsoftware.com/document/nightlybuilds/GBD35v1363.zip

Or this NuGet package:
Install-Package GemBox.Document -Version 35.0.1363-hotfix

Does this solve your issue?

Hi Mario,

Newest version of GemBox.Bundle is working for the case of HTML documents, thank you!

But in case of loading the HTML body of mails (which had the problem of being shown empty before) to a document I received a NullReferenceException.
I am using GemBox.Bundle v. 47.0.1036 and the following statement:

var documentModel = new DocumentModel();
documentModel.Content.End.LoadText(_mailMessage.GetEmbeddedBodyHtml(), LoadOptions.HtmlDefault);

Is this another issue within the mail?

Kind regards,
Sarah

Sarah, please send us your email file so that we reproduce the issue and investigate it.

Hi Mario,

the file that I encountered the exception with is a confidential mail, I am afraid I cannot forward it.
However, when I have another file with the same behaviour that I can forward, I will notify you.

Most important: The main issue of this topic is fixed with the new GemBox version, thank you!

Kind regards,
Sarah