I have a docx template , from which i generates the needed docx by way of content binding .
Now I also prefer to add some xhtml contents to the resultant docx on the run .
Which is the prefered and best way to accomplish this goal .
i found one possible solution is to use the method as described ,
- Code: Select all
wordMLPackage.getMainDocumentPart().getContent().addAll(
XHTMLImporter.convert( new File(inputfilepath + ".html"), null, wordMLPackage) );
but getting the below error ,
WARNING:: Unhandled exception. Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 3; The element type "meta" must be terminated by the matching end-tag "</meta>"
after i tried , using the below method ,
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
mdp.addAltChunk(AltChunkType.Xhtml, xhtml.getBytes());
// Round trip
wordMLPackage = mdp.convertAltChunks();
This seems to be working by appending html to the resultant docx, but again it throws the the above error
Unhandled exception. Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 3; The element type "meta" must be terminated by the matching end-tag "</meta>".
I hope , my xhtml is not well formed , and i needs some formatting with Jtidy .
Also the the styles in xhtml in resultant docx are not applied correctly ,
Can you tell where to find the new xhtmlrenderer.jar with all resources includes as described in ,
http://www.docx4java.org/forums/xhtml-import-f28/problems-while-converting-html-entities-t1197.html#p4173
, after i found this post ,
http://www.docx4java.org/forums/data-binding-java-f16/inject-converted-html-to-custom-xml-t1332.html#p4690
which says it is possible to bind xhtml via opendope . Can you also please tell me the steps invloved in binding xhtml data via opendope extension/word-addin