Page 1 of 1

HTML into Headers and Footers

PostPosted: Wed Feb 04, 2015 5:48 pm
by dirtymike
Thanks for creating docx4j!

I have a question for anyone who stops by.

I'm working with ImportXHTML 3.2.2. I am using the example from ConvertInXHTMLFragment.java to turn a string of valid XHTML into the main body of my docx.

I wanted to try to make a header using XHTMLImporter.convert("<div>Hi</div>", null).

I followed the sample in the main docx4j github repo, HeaderFooterCreate.java. At like 125 I did something like:

hdr.getContent().add(XHTMLImporter.convert("<div>Hi</div>", null))

And then like

hdr.getContent().addAll(XHTMLImporter.convert("<div>Hi</div>", null))

In both cases I run into "SAXException2 unable to marshal type "java.lang.Boolean" as an element because it is missing an @XmlRootElement annotation"

Is there a better way to add a header or do I need to keep trying to debug my modifications to the code?

Re: HTML into Headers and Footers

PostPosted: Wed Feb 04, 2015 6:26 pm
by jason
What's the complete stack trace?

I just tried your addAll example, and it worked for me.