Page 1 of 1
Line spacing in generated docx
Posted:
Wed Feb 04, 2015 10:59 pm
by rabis
Hi ,
We need to convert html to docx file.
The generated docx is not preserving the line spacing as in html file.
We need to generate the docx with exact line spacing as in html file. Any inputs are welcome.Thanks.
Re: Line spacing in generated docx
Posted:
Thu Feb 05, 2015 11:28 am
by jason
What does your input XHTML look like?
What docx4j-ImportXHTML settings are you using?
What is your target docx ?
Re: Line spacing in generated docx
Posted:
Thu Feb 05, 2015 8:22 pm
by rabis
we used xhtmImporter for converting html file to docx file.
The conversion is happening fine.
But one issue:
<p></p> present in html file provides line spacing in html
Ex
<p>By:</p>
<p>Signature:</p>
Html ouput:
By:
Signature:
In converted docx the linespacing is missing its displayed as follows
By:
Signature:
Kindly let me know this can be fixed.
Re: Line spacing in generated docx
Posted:
Thu Feb 05, 2015 8:49 pm
by jason
OK, you've told me what your input xhtml looks like.
But you haven't told me anything else...
To control line spacing, use CSS or a @class value which matches a suitable style in the target docx (with ImportXHTML set to map class values to styles).
Re: Line spacing in generated docx
Posted:
Thu Feb 05, 2015 9:00 pm
by rabis
Could you explain how the CSS value for line spacing will be ?
For eg:
<w:p xmlns:http:....wordprocessingxml/2006 </w:p>
Re: Line spacing in generated docx
Posted:
Thu Feb 05, 2015 10:15 pm
by jason
Looking at PropertyFactory.createPropertyFromCssName
Using java Syntax Highlighting
if (name.
equals(LineSpacing.
CSS_NAME )) {
// line-height
return new LineSpacing
(value
);
}
Parsed in 0.014 seconds, using
GeSHi 1.0.8.4
LineSpacing.CSS_NAME = "line-height"
Looking at LineSpacing, there are 3 units of measurement you can choose from:
Using java Syntax Highlighting
if (CSSPrimitiveValue.
CSS_IN == type
) {
twip
= UnitsOfMeasurement.
inchToTwip(fVal
);
} else if (CSSPrimitiveValue.
CSS_MM == type
) {
twip
= UnitsOfMeasurement.
mmToTwip(fVal
);
} else if (CSSPrimitiveValue.
CSS_PERCENTAGE == type
) {
twip
= twipFromPercentage
(fVal
);
Parsed in 0.014 seconds, using
GeSHi 1.0.8.4