Page 1 of 1

Borders in DOCX made by converting HTML??

PostPosted: Fri Sep 14, 2012 7:23 pm
by trondbert
Hi!

I've converted an HTML <table> to docx using XHTMLImporter, but no table borders are displayed in the resulting document. Is there a way to specify the border in html so that docx4j honors it? I've tried various approaches.

String xhtml= "<div>" +
"<p>The <b>quick</b> <span style=\"font-size: 14pt;\">brown</span> fox...</p>" +
"<p>Paragraph 2</p><table border=\"1\" style=\""+
"display:table; table-layout:fixed; border-color: #600; border-style: solid; border-width: 0 0 1px 1px; border-spacing: 0; border-collapse: collapse;"+
"\"><tr><td>foo</td></tr></table>" +
"</div>";
...
WordprocessingMLPackage mlPackage = (WordprocessingMLPackage) loader.get(getClass().getResourceAsStream("/brevmal.docx"));
...
mlPackage.getMainDocumentPart().getContent().addAll(XHTMLImporter.convert( xhtml, null, mlPackage));

Re: Borders in DOCX made by converting HTML??

PostPosted: Tue Sep 18, 2012 7:20 pm
by trondbert
Come on :) I need some help here...

Re: Borders in DOCX made by converting HTML??

PostPosted: Wed Sep 19, 2012 7:05 pm
by jason
With the current nightly build, I think there will always be borders:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                        // TODO support: borders
                        // for now, just
                        //         <w:tblStyle w:val="TableGrid"/>
                        TblStyle tblStyle = Context.getWmlObjectFactory().createCTTblPrBaseTblStyle();
                        tblStyle.setVal("TableGrid");
                        tblPr.setTblStyle(tblStyle);  
 
Parsed in 0.019 seconds, using GeSHi 1.0.8.4


docx4j 2.8.0 may have been different. For xhtml import, I recommend you use a nightly build since there have been some important fixes.

Re: Borders in DOCX made by converting HTML??

PostPosted: Wed Sep 19, 2012 7:50 pm
by jason
Simple minded support for either all borders off or all on, added in https://github.com/plutext/docx4j/commi ... 4ebe496677