Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.0
-
Linux JDK8 fop 2.0 stable
Description
I am using FOP to convert from XHTML to RTF using Antennahouse Stylesheet for XHTML to XSL-FO transformation.
My scenario is desbribed below:
I am using stylesheet xhtml2fo.xslt and it works fine when parsing XHTML to PDF, but when I change Fop MIME_TYPE to RTF and execute the same code, RTF output file does not contain first line indentation according XHTML style.
1) XHTML input:
<p style="text-indent: 3cm">BLAH BLAH BLAH</p>
Stylesheet xhtml2fo.xslt:
http://www.antennahouse.com/XSLsample/sample-xsl-xhtml2fo/xhtml2fo.xsl
2) FO Output:
<fo:block text-indent:3m>BLAH BLAH BLAH</fo:block>
3) Expected RTF output:
{ fiXXX BLAH BLAH BLAH }4) I have verified FOP source code and noticed that current version have a bug on RtfText:
<pre>
/** constant for left indent first */
public static final String LEFT_INDENT_FIRST = "fi-";
</pre>
5) Also TextAttributesConverter is not considering text-indent attribute:
public static RtfAttributes convertAttributes(Block fobj)
throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
attrFont(fobj.getCommonFont(), attrib);
attrFontColor(fobj.getColor(), attrib);
//attrTextDecoration(fobj.getTextDecoration(), attrib);
attrBlockBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
attrBlockTextAlign(fobj.getTextAlign(), attrib);
attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj);
attrBreak(fobj, attrib);
return attrib;
}
6) I implemented the following patch and it is working fine for me. Check this out:
- Fixed LEFT_INDENT_FIRST to public static final String LEFT_INDENT_FIRST = "fi";
- New method to convert text-indent attribute:
public static RtfAttributes convertAttributes(Block fobj)
throws FOPException
private static void attrBlockTextIndent(Length textIndent, FOPRtfAttributes rtfAttr)
{ rtfAttr.setTwips(RtfText.LEFT_INDENT_FIRST, textIndent.getValue()); }Thank you!