GingerHead
GingerHead

Reputation: 8240

Shift a fop table to the right

I'm implementing FOP by mixing xsl and xml files to obtain as a result a PDF file.

But I can't seem to shift the table to the right correctly.
I manipulated the following FOP attributes related to the table:

  1. start-indent: But the contents of the table shift more than the shifting value of the start-indent by two times corrupting the overall layout
  2. margin-left: This attribute seems to effect the same way on the table as start-indent

Is there any other way?

Upvotes: 2

Views: 3140

Answers (2)

ibram
ibram

Reputation: 4589

If the solution above doesn't work, there is another way. It's just a table with an empty first column. So it looks like a right-shifted table.

<fo:block wrap-option="no-wrap">
    <fo:table border-collapse="collapse" width="100%">
        <fo:table-column column-width="proportional-column-width(60)" />
        <fo:table-column column-width="proportional-column-width(20)" />
        <fo:table-column column-width="proportional-column-width(20)" />
        <fo:table-header />
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell />
                <fo:table-cell>
                    <fo:block>John</fo:block>
                </fo:table-cell>
                <fo:table-cell>
                    <fo:block>Doe</fo:block>
                </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
                <fo:table-cell />
                <fo:table-cell>
                    <fo:block>Peter</fo:block>
                </fo:table-cell>
                <fo:table-cell>
                    <fo:block>Parker</fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
</fo:block>
  • The table has a width of 100% and the first column is empty.
  • The columns have percentaged width.
  • The % in column-width is apparently not allowed, use proportional-column-width instead.
  • In this example there are no header names, but you can add names except of the first column.
  • If a border is needed, it should be done except of the first one logically.

Upvotes: 1

mzjn
mzjn

Reputation: 51042

It should work if you specify, say, start-indent="20mm" on the fo:table element and start-indent="0mm" on fo:table-body (and also on fo:table-header and fo:table-footer, if they are used). For example:

<fo:table table-layout="fixed" width="60mm" 
          border-style="solid" start-indent="20mm">
  <fo:table-column column-width="40%"/>
  <fo:table-column column-width="60%"/>
  <fo:table-body start-indent="0mm" >
    <fo:table-row>
      <fo:table-cell border-style="solid">
        <fo:block>Col1</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid">
        <fo:block>Col2</fo:block>
      </fo:table-cell>
    </fo:table-row>
  </fo:table-body>
</fo:table>

start-indent is an inherited property. Resetting it makes it not apply to the child areas of fo:table.

I was unable to make it work with margin-left (a non-inherited property). This might be a FOP bug (it works with XEP).

See also the Interpreting Indent Inheritance in XSL-FO article on the Xmlgraphics-fop wiki (especially the "Further examples with tables" section).

Upvotes: 4

Related Questions