Replies: 1 comment
-
|
resulting docx attached |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. I'm trying to create docx from html. Header is also created from html string. So when I add header it works fine but it's content is duplicated in body part. I use docx4j-ImportXHTML to convert html into elements.
My pom.xml
`
org.docx4j
docx4j-JAXB-Internal
8.3.1
My java code:
`import org.apache.commons.io.FileUtils;
import org.docx4j.Docx4J;
import org.docx4j.convert.in.xhtml.XHTMLImporter;
import org.docx4j.convert.in.xhtml.XHTMLImporterImpl;
import org.docx4j.model.structure.SectionWrapper;
import org.docx4j.openpackaging.exceptions.InvalidFormatException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.Part;
import org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.relationships.Relationship;
import org.docx4j.wml.*;
import java.io.File;
import java.util.List;
public class DuplicatedHeaderInBodyExample {
private static ObjectFactory objectFactory = new ObjectFactory();
}
`
My main.html:
<p>BODY CONTENT</p>My header.html:
<p>HEADER</p>THE RESULTIN DOCX SCREENSHOT ATTACHED AS SCREENSHOT

As you can see on the screenshot. Header content is added twice: as header and as content in body. I want header by added only as header without duplicating it in body. Can you guys suggest any fix or workaround please?
Beta Was this translation helpful? Give feedback.
All reactions