This is the XSL-FO that I am trying to convert to PDF. When I use Apache FOP, in the first table, the 2nd row elements are superimposed over the 2nd cell of the 1st row. This is unexpected behavior as the 2nd table renders just fine.
You can use this online renderer to see the generated output. Paste the XML code in the third box and convert to pdf. Is there something wrong with my xsl-fo? As far as I can see both the tables are functionally identical
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="letter" page-height="11in" page-width="8.5in" margin-top="0.5in"
margin-bottom="0.5in" margin-left="0.5in" margin-right="0.5in">
<fo:region-body region-name="xsl-region-body" column-count="2"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="letter">
<fo:flow flow-name="xsl-region-body">
<fo:block span="all" font-size="16pt" font-weight="bold" margin-top="9pt">
<fo:inline text-decoration="underline">Sales Info</fo:inline>
</fo:block>
<fo:table table-layout="fixed" font-size="12pt">
<fo:table-column column-width="2.25in"/>
<fo:table-column column-width="1.5in"/>
<fo:table-column column-width="2.25in"/>
<fo:table-column column-width="1.5in"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="12pt">Name </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: 12314</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">Office Phone</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: -</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="12pt">Email1</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: -</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">Email 2</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: -</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block span="all" font-size="16pt" font-weight="bold" margin-top="9pt">
<fo:inline text-decoration="underline">Order</fo:inline>
</fo:block>
<fo:table table-layout="fixed" font-size="12pt">
<fo:table-column column-width="2.25in"/>
<fo:table-column column-width="1.5in"/>
<fo:table-column column-width="2.25in"/>
<fo:table-column column-width="1.5in"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="12pt">Number</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: asdasd</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">Type</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: A</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="12pt">Region</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: 12341</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">Location</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="12pt">: 12341</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
I get the same result with AH Formatter, and I was just as confused as you when I first saw it.
Your fo:region-body
has column-count="2"
. You are seeing the first table breaking across the two columns because of the following <fo:block span="all" ...>
.
The second table doesn't break because the formatter would ordinarily fill one column before placing content in the second column. The block with span="all"
makes the formatter want to balance the columns before placing the block. If you put another one of those blocks after the second table, the second table will behave similarly.
Your tables are too wide for a single column anyway. The second table looks like it works, but in reality each row is overflowing across the width of the second column.
span
applies to fo:block
and fo:block-container
only, so it doesn't apply to fo:table
. The solution is to put the fo:table
inside an fo:block
or fo:block-container
that has the span="all"
so that your tables take the full width of the page and do not break across columns.
Alternatively, if there's nothing that is meant to be formatted as two columns, then you can get rid of the column-count="2"
and all of the span="all"
.