A while back I reported issues with double spacing in the html conversion:
http://www.docx4java.org/forums/docx-java-f6/issue-with-double-spacing-in-html-t1171.html#p4050
I have found a couple of issue that are still happening. It appears that if the paragraph is set to the defaults, there is no pPr node and it never gets in to the code to set the default margin-top at line 364 of the HtmlExporterNG2 code. Also, the same issue happens with the bottom margin. When it is not defined, it adds a margin in the browser, so that would need to be inline styled as well.
Using java Syntax Highlighting
// Does our pPr contain anything else?
boolean ignoreBorders = (htmlElementName.equals("p"));
if (pPr!=null) {
StringBuffer inlineStyle = new StringBuffer();
HtmlCssHelper.createCss(context.getWmlPackage(), pPr, inlineStyle, ignoreBorders);
if (!inlineStyle.toString().equals("") ) {
xhtmlBlock.setAttribute("style", inlineStyle.toString() );
}
if (!inlineStyle.toString().contains(SpaceBefore.CSS_NAME) ) {
// If there is no w:spacing/@w:before, it should be 0.
// unless it is set to anything in the effective style
PropertyResolver propertyResolver = context.getPropertyResolver();
PPr stylePPr = propertyResolver.getEffectivePPr(pStyleVal);
if (stylePPr.getSpacing()!=null
&& stylePPr.getSpacing().getBefore()!=null) {
// it is specified in the style
} else {
/* For a doc where there is no w:spacing/@w:before specified
* in the styles, Word's HTML output defaults to
p.MsoNormal, li.MsoNormal, div.MsoNormal
{
margin-top:0cm;
margin-right:0cm;
margin-bottom:10.0pt;
margin-left:0cm;
line-height:115%; <------- from w:spacing/@w:line?
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
Here, for now, we are just dealing with
w:spacing/@w:before.
*/
xhtmlBlock.setAttribute("style", inlineStyle.toString() + "; margin-top:0cm; " );
}
}
}
boolean ignoreBorders = (htmlElementName.equals("p"));
if (pPr!=null) {
StringBuffer inlineStyle = new StringBuffer();
HtmlCssHelper.createCss(context.getWmlPackage(), pPr, inlineStyle, ignoreBorders);
if (!inlineStyle.toString().equals("") ) {
xhtmlBlock.setAttribute("style", inlineStyle.toString() );
}
if (!inlineStyle.toString().contains(SpaceBefore.CSS_NAME) ) {
// If there is no w:spacing/@w:before, it should be 0.
// unless it is set to anything in the effective style
PropertyResolver propertyResolver = context.getPropertyResolver();
PPr stylePPr = propertyResolver.getEffectivePPr(pStyleVal);
if (stylePPr.getSpacing()!=null
&& stylePPr.getSpacing().getBefore()!=null) {
// it is specified in the style
} else {
/* For a doc where there is no w:spacing/@w:before specified
* in the styles, Word's HTML output defaults to
p.MsoNormal, li.MsoNormal, div.MsoNormal
{
margin-top:0cm;
margin-right:0cm;
margin-bottom:10.0pt;
margin-left:0cm;
line-height:115%; <------- from w:spacing/@w:line?
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
Here, for now, we are just dealing with
w:spacing/@w:before.
*/
xhtmlBlock.setAttribute("style", inlineStyle.toString() + "; margin-top:0cm; " );
}
}
}
Parsed in 0.017 seconds, using GeSHi 1.0.8.4