Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-2527

RTF first line indent not being rendered by fo:block text-indent

    XMLWordPrintableJSON

Details

    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

      { ... attrBlockTextIndent(fobj.getTextIndent(), attrib); ... return attrib; }

      private static void attrBlockTextIndent(Length textIndent, FOPRtfAttributes rtfAttr)

      { rtfAttr.setTwips(RtfText.LEFT_INDENT_FIRST, textIndent.getValue()); }

      Thank you!

      Attachments

        1. RtfText.java
          12 kB
          Stanley Santos de Araújo
        2. test.fo
          0.5 kB
          Simon Steiner
        3. test.html
          0.0 kB
          Stanley Santos de Araújo
        4. TestFOP.java
          4 kB
          Stanley Santos de Araújo
        5. TextAttributesConverter.java
          20 kB
          Stanley Santos de Araújo
        6. xhtml2fo.xsl
          63 kB
          Stanley Santos de Araújo

        Activity

          People

            ssteiner Simon Steiner
            stanleysantos Stanley Santos de Araújo
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: