Skip to content

When saving a file that has HTML content starting with a pre tag using Docx, the first line is duplicated. #489

@arowland-informatics

Description

@arowland-informatics

When saving HTML content to a file using Docx, it duplicates the first line if a break is inserted on the second line. Below is a code snippet example. The content in the pre tag will show in the file twice.

Imports Xceed.Document.NET
Imports Xceed.Words.NET

Dim sbHtmlContent As New StringBuilder

sbHtmlContent.Append("<pre>schema-version = 1.0.0</pre>")

sbHtmlContent.Append("<br/>")

sbHtmlContent.Append("<p>some other content<p/>")

Dim htmlContent = sbHtmlContent.ToString

Dim fullFileName As String = "pathtofile.doc"

Dim doc As Xceed.Words.NET.DocX = Xceed.Words.NET.DocX.Create(fullFileName)

doc.InsertContent(htmlContent, Xceed.Document.NET.ContentType.Html)

doc.Save()

UPDATE: This is happening because of the self closing tag. If I replace this

sbHtmlContent.Append("<br/>")

with this

sbHtmlContent.Append("<br></br>")

It doesn't duplicate the first line.

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