W3C home > Mailing lists > Public > www-xsl-fo@w3.org > April 2011

Keeping together a text line with the first row in a table

From: Lars Bjørndal <lars@lamasti.net>
Date: Wed, 13 Apr 2011 14:18:19 +0200
To: www-xsl-fo@w3.org
Message-ID: <m38vveuyyc.fsf@dalen.lamasti.net>
I use a Perl script to generate a fo file out of a non-standard csv
format. The structure is one line of text, and then a table with several
rows, then one line of text, and a new table and so on. The single lines
of text is actually a heading, and should not go to the bottom line of a
page. Instead, it should go to a new page.

To generate the PDF output, I use fop version 0.95 on a Fedora Linux
system.

The fo file structure looks like the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  font-family="Helvetica" font-size="18pt">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="A4-landscape"
      reference-orientation="90" page-width="21cm"
      page-height="29.7cm"
      margin-left="2cm" margin-right="1cm" margin-top=".5cm" margin-bottom="2cm">
      <fo:region-body margin-top=".5cm"/>
      <fo:region-before extent="0cm"/>
      <fo:region-after extent=".5cm"/>
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence master-reference="A4-landscape">
    <fo:static-content flow-name="xsl-region-after">
      <fo:block text-align-last="right" font-size="10pt">
	<fo:page-number />
      </fo:block>
    </fo:static-content>
    <fo:flow flow-name="xsl-region-body">
      <fo:block font-weight="bold">The first hading</fo:block>

      <fo:table table-layout="fixed" width="100%" border-width=".5mm" border-style="dotted">
	<fo:table-column column-width="2cm" />
	<fo:table-column column-width="10cm" />
	<fo:table-column column-width="8cm" />
	<fo:table-column column-width="5cm" />
	<fo:table-body>

	<fo:table-row>
	  <fo:table-cell padding=".5mm" border-width=".5mm"
	      border-style="dotted" text-align="center">
	    <fo:block>1</fo:block>
	  </fo:table-cell>
	  <fo:table-cell padding=".5mm" border-width=".5mm" border-style="dotted">
	    <fo:block>John Johnsen</fo:block>
	  </fo:table-cell>
          <fo:table-cell padding=".5mm" border-width=".5mm" border-style="dotted">
            <fo:block>NOR-Oslo</fo:block>
	  </fo:table-cell>
		    <fo:table-cell padding=".5mm" border-width=".5mm"
		    border-style="dotted" text-align="right">
		      <fo:block>30.40</fo:block>
		    </fo:table-cell>
	</fo:table-row>

	<fo:table-row>
	  <fo:table-cell padding=".5mm" border-width=".5mm"
	      border-style="dotted" text-align="center">
	    <fo:block>2</fo:block>
	  </fo:table-cell>
	  <fo:table-cell padding=".5mm" border-width=".5mm" border-style="dotted">
	    <fo:block>Jack Jacksen</fo:block>
	  </fo:table-cell>
          <fo:table-cell padding=".5mm" border-width=".5mm" border-style="dotted">
            <fo:block>NOR-Oslo</fo:block>
	  </fo:table-cell>
		    <fo:table-cell padding=".5mm" border-width=".5mm"
		    border-style="dotted" text-align="right">
		      <fo:block>39.30</fo:block>
		    </fo:table-cell>
	</fo:table-row>
	</fo:table-body>
      </fo:table>

      <fo:block font-weight="bold">The second heading</fo:block>

And then, a new table. ...

How can I keep together the heading with the first row in the table?

Regards,
Lars
Received on Wednesday, 13 April 2011 14:25:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 13 April 2011 14:25:34 GMT