Search code examples
xsltxsl-foapache-fopdocbook-5

Struggling with some margin in a table in XSL generated FO document


I hope you all had some Happy Holidays so far!

I'm currently working on a XSLT Transformation from DocBook to apache fo (and then onward to PDF) but I'm struggling with one table.

Here is the relevant part of my stylesheet.

<fo:block>
  <fo:table border-style="none" border-width="0pt">    
    <fo:table-column column-width="20%"/>
    <fo:table-column column-width="80%"/>                  
     <fo:table-body>                                               
       <fo:table-row>                                             
         <fo:table-cell border-style="solid" border-width="1pt" text-align="start" padding-left="0cm"> 
           <fo:block font-weight="bold">First Column <xsl:text> </xsl:text> <xsl:number level="multiple" count="d:appnote" format="1"/>
            </fo:block>                         
         </fo:table-cell>                         
         <fo:table-cell  border-style="solid" border-width="1pt" text-align="start"> 
           <fo:block><xsl:value-of select="d:description" /></fo:block>
         </fo:table-cell>                        
      </fo:table-row>
    </fo:table-body>
  </fo:table>
</fo:block>

Unfortunately, the resulting table shows some pretty big margins between the left border of the table and the beginning of the text (even though I set padding-left="0cm")

enter image description here

I tried a dozen of different attributes and options but I cannot get rid of this whitespace.
Does anybody have a tip for me?


Solution

  • The start-indent property is inherited by the descendant FO elements of the one where it is set, which sometimes leads to some counter-intuitive results.

    As apparently not all implementations behave in the same way, FOP's site has a specific FAQ entry: When I use margins, my content in a nested table or block-containers gets indented twice. Is this a bug?


    So, in your situation it is probable that the content of the table cells is inheriting a start-indent set on an ancestor element (even a very remote one).

    If this is the case, you could add a start-indent="0pt" attribute on the fo:table-body to "reset" it to 0.