Page 1 of 1

bugs for style transformation ?

PostPosted: Tue Aug 12, 2014 9:50 am
by pengppp11
Hello everyone

I'm recently using the XHTMLImporterImpl to transform HTML into DOCX, and I meet a small problem, I'm not sure whether it is a small bug.

What I want is to convert some or all combination of bold, italic, underline, and strike into DOCX, but I failed in many cases.

For example, if I have a following string :

String xhtml="<b><i><u><s>2014</s></u></i></b>"; and if I convert this into DOCX, the third tag for underline, namely <u></u> will not be transformed into DOCX. However, if I remove the internal tag <s></s>, then everything will be OK. That is : Underline in <b><i><u>2011</u></i></b> can be converted.

And the same thing as <b><i><s><u>2014</u></s></i></b>, now in this case, also the third one, the strike style <s></s> can't be converted into DOCX. But without <u></u>, <b><i><s> can be converted.

Also by <u><s>2014</s></u>, the underline will be ignored after converting, but <s> remains. For <u>2014</u> and <s>2014</s>, nothing will happen in DOCX, instead <b>2014</b> and <i>2014</i> can be done into DOCX.

Maybe there are some other similar cases also containing the same problem, so I don't know why some styles are missing after the transformation into DOCX. :shock:

Thanks a lot

Re: bugs for style transformation ?

PostPosted: Tue Aug 12, 2014 1:44 pm
by jason
Suggest you use CSS, not legacy b/i/u/s tags

Re: bugs for style transformation ?

PostPosted: Tue Aug 12, 2014 8:35 pm
by pengppp11
jason wrote:Suggest you use CSS, not legacy b/i/u/s tags


Thanks, jason. I have tried in many cases and found <b><i> are nicely supported, except <u> and <s>. :cry:

So then I try to use CSS based on your suggestion, e.g. <b><i><span style="text-decoration:underline; ">text</span></i></b>". As a result, underline can be converted as well as bold and italic.

However when I combine underline and strike together, I also failed, e.g. <b><i><span style="text-decoration:underline line-through; ">text</span></i></b>, none of underline and strike are converted if I put underline and line-through in the css together. :(

So could you give an example how the 4 styles, namely, bold. italic, underline, strike can be converted at the same time ? Thank you very much. :)