Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
src107 opened this issue Aug 23, 2024 · 0 comments
Open

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

src107 opened this issue Aug 23, 2024 · 0 comments

Comments

@src107
Copy link

src107 commented Aug 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant