Skip to content

SetHTML ignores blanks #31

@marcelbeutner

Description

@marcelbeutner

When rendering HTML with handler.SetHtml(), spaces inside nested tags are not displayed.
The following HTML:

<span>This is a<span>&nbsp;</span></span><strong>bold</strong><span><span>&nbsp;</span>text</span>

Image

Sample
` col.Item().HTML(handler => ConfigureHtmlHandler(handler, "This is a bold text"));

private void ConfigureHtmlHandler(HTMLDescriptor handler, string htmlContent)
{
handler.SetTextStyleForHtmlElement("h1", TextStyle.Default.FontSize(16).Bold());
handler.SetTextStyleForHtmlElement("h2", TextStyle.Default.FontSize(14).Bold());
handler.SetTextStyleForHtmlElement("h3", TextStyle.Default.Bold());
handler.SetTextStyleForHtmlElement("h4", TextStyle.Default.Bold());
handler.SetContainerStyleForHtmlElement("ul", c => c.PaddingVertical(10));
handler.SetHtml(htmlContent ?? string.Empty);
}
`

Expected result:

The non-breaking spaces should be preserved and displayed correctly.

Actual result:

The spaces are swallowed and not visible in the final PDF.

Additional info:

QuestPDF version: 2025.7.4
QuestPDF.HTML version: 1.4.2
.NET version: 9.0

Screenshot attached

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions