Skip to content

Adding xhtml content into SdtRun causing document to be corrupted #107

@src107

Description

@src107

I am trying to add a xhtml content into SdtContent of a SdtRun element using XHTMLImporterImpl.

String xhtmlContent = "<html><body><a href="https://www.w3schools.com">20</a></body></html>"
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
		List<Object> htmlPart = XHTMLImporter.convert( xhtmlContent, null);
	if (htmlPart != null && !htmlPart.isEmpty()) {
				sdtObject.getSdtContent().getContent().clear();
				sdtObject.getSdtContent().getContent().addAll(htmlPart);
		}

The <w:hyperlink> is wrapped under P element which is causing the issue I guess and the document generated is corrupted.
My xhtml content can also be a big html content as well with links, h1, p.
OpenXML structure
image

Need help on this, Please @plutext can you help on this issue

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