This project is read-only.

Problem with FO.NET tables

Jun 16, 2010 at 11:42 AM

I have problems with tables. Those are not shown on PDF at all... and FO.NET does not give me any errors.

Here is listing:

<?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="A4">
			<fo:region-body />
		</fo:simple-page-master>
	</fo:layout-master-set>

	<fo:page-sequence master-reference="A4">
		<fo:flow flow-name="xsl-region-body">
		
	
		<fo:block>Hi!</fo:block>	

		<fo:table-and-caption>
		<fo:table>
		<fo:table-column column-width="25mm"/>
		<fo:table-column column-width="25mm"/>

		<fo:table-header>
		  <fo:table-row>
			<fo:table-cell>
			  <fo:block font-weight="bold">Car</fo:block>
			</fo:table-cell>
			<fo:table-cell>
			  <fo:block font-weight="bold">Price</fo:block>
			</fo:table-cell>
		  </fo:table-row>
		</fo:table-header>

		<fo:table-body>
		  <fo:table-row>
			<fo:table-cell>
			  <fo:block>Volvo</fo:block>
			</fo:table-cell>
			<fo:table-cell>
			  <fo:block>$50000</fo:block>
			</fo:table-cell>
		  </fo:table-row>
		  <fo:table-row>
			<fo:table-cell>
			  <fo:block>SAAB</fo:block>
			</fo:table-cell>
			<fo:table-cell>
			  <fo:block>$48000</fo:block>
			</fo:table-cell>
		  </fo:table-row>
		</fo:table-body>

		</fo:table>
		</fo:table-and-caption>

		<fo:block>Hi again!</fo:block>
			
		</fo:flow>
	</fo:page-sequence>

</fo:root>

It only shows "Hi!" and "Hi again!".

Table code is taken from w3schools.

Jun 23, 2010 at 1:16 AM
I have found the same issue, anyone have a sollution? XSL-FO below; <?xml version="1.0" encoding="ISO-8859-1"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm"> <fo:region-body margin-top="3cm"/> <fo:region-before extent="3cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="A4"> <fo:flow flow-name="xsl-region-body"> <fo:block font-size="18pt" font-family="Arial" font-weight="bold" color="#00A4F2" text-align="left"> Table Test! </fo:block> <fo:table-and-caption> <fo:table width="100%" background-color="#00A4F2"> <fo:table-body> <fo:table-row keep-together="always"> <fo:table-cell> Put things you want kept together here! </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:table-and-caption> <fo:block font-family="Arial" font-size="12pt">Table Ends!</fo:block> </fo:flow> </fo:page-sequence> </fo:root>
Jun 23, 2010 at 10:01 AM
I'm having exactly the same issue, all tables I define in XSL-FO are not rendered in the PDF. XSL-FO Below result in an entirely blank PDF: <?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="simple" page-height="29.7cm" page-width="210mm" margin-top="1cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm"> <fo:region-body margin-top="0cm"/> <fo:region-before extent="1.5cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="simple"> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:table border="0.5pt solid black" text-align="center"> <fo:table-body> <fo:table-row> <fo:table-cell padding="6pt" border="0.5pt solid black"> <fo:block> upper left </fo:block> </fo:table-cell> <fo:table-cell padding="6pt" border="0.5pt solid black"> <fo:block> upper right </fo:block> </fo:table-cell> </fo:table-row> <fo:table-row> <fo:table-cell padding="6pt" border="0.5pt solid black"> <fo:block> lower left </fo:block> </fo:table-cell> <fo:table-cell padding="6pt" border="0.5pt solid black"> <fo:block> lower right </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:block> </fo:flow> </fo:page-sequence> </fo:root>
Jun 23, 2010 at 10:22 AM
Found the solution, table has to have three key properties; 1. table-layout="fixed". 2. fo:table-column with width defined for each column. 3. each table-cell padding must be defined. Working version below; <?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="simple" page-height="29.7cm" page-width="210mm" margin-top="1cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm"> <fo:region-body margin-top="0cm"/> <fo:region-before extent="1.5cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="simple"> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:table table-layout="fixed" border="0.0pt solid black" text-align="center"> <fo:table-column column-width="50mm"/> <fo:table-column column-width="50mm"/> <fo:table-body> <fo:table-row> <fo:table-cell padding="6pt" border="0.5pt solid #dddddd"> <fo:block> upper left </fo:block> </fo:table-cell> <fo:table-cell padding="6pt" border="0.5pt solid #dddddd"> <fo:block> upper right </fo:block> </fo:table-cell> </fo:table-row> <fo:table-row> <fo:table-cell padding="6pt" border="0.5pt solid #dddddd"> <fo:block> lower left </fo:block> </fo:table-cell> <fo:table-cell padding="6pt" border="0.5pt solid #dddddd"> <fo:block> lower right </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:block> </fo:flow> </fo:page-sequence> </fo:root>
Jun 23, 2010 at 11:02 AM
Thanks so much npg195, that fixed it - I just couldn't work out what the problem was.
Sep 3, 2010 at 12:08 PM

Remove the <fo:table-and-caption> does the trick. And it is not necessary to specify any of the table properties.

Nov 28, 2012 at 9:08 AM

I got similar problem with <fo:block-container /> in table cell. Having all 3 "principles" above satisfied, I got an empty table with following cell markup:

<fo:table-cell border-bottom-style="none" border-left-style="none" border-right-style="none" border-top-style="none" border="solid 1pt gray" padding="2pt" display-align="center">
  <fo:block-container overflow="hidden">
    <fo:block text-align="center">
      <fo:inline>CUR</fo:inline>
    </fo:block>
  </fo:block-container>
</fo:table-cell>

As soon as I replaced block-container with its content, I got my table rendered (I tried to remove overflow attribute, but there were no effects). Btw, Fonet version is 1.0.3318.11064.