Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6853263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:29:29+00:00 2026-05-27T01:29:29+00:00

I’m generating a PDF using Apache FOP and a XSL-FO stylesheet. In the PDF,

  • 0

I’m generating a PDF using Apache FOP and a XSL-FO stylesheet. In the PDF, I output headings (html equiv h1) which belong to a table, so should be kept together always. However, my tables may also contain so much data that they don’t necessarily fit on one page.

The desired result is a rule set that allows a heading to be kept with the table and fit both on one page if possible, but if the table data is so long that it does not fit on one page, then page breaks would be inserted in the table while still keeping the heading element on the same page as the start of the table.

The solution I have right now does keep the heading and the table together, but I get an Content overflows error for the table data if everything does not fit onto one page. I was hoping that page-break-inside: avoid set on the table element would help with this, but apparently not… suggestions?

Example xsl (cut short for readability):

<!-- add test table with header that should stay on same page -->
<fo:block font-size="20pt" font-weight="bold">Table header</fo:block>

<fo:table keep-with-previous.within-page="always"
      page-break-inside="avoid" 
      table-layout="fixed" border-width="1mm" border-style="solid">
  <fo:table-column column-width="auto" />
  <fo:table-column column-width="30mm" />

  <fo:table-header text-align="center" background-color="silver">
    <fo:table-row>
      <fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
    <fo:block>First name</fo:block>
      </fo:table-cell>
      <fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
    <fo:block>Last name</fo:block>
      </fo:table-cell>
    </fo:table-row>
  </fo:table-header>
  <fo:table-body>
    <!-- the table-rows can be repeated N times, spanning several pages -->
    <fo:table-row >
      <fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
    <fo:block>ab</fo:block>
      </fo:table-cell>
      <fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
    <fo:block>cd</fo:block>
      </fo:table-cell>
    </fo:table-row>
    <!-- .... more table-row:s ---> 

Update on desired output

To better describe what result I’m looking for:

The result document contains both text paragraphs, headings and tables.

  1. If the amount of content is such that the table would have only one or two rows on the next page, then the xsl-fo should move the entire table and the heading to the next page provided that it fits on that page entirely.
  2. If on the other hand the table as so many rows that it wouldn’t fit on an entirely new page anyway, then output should be started right away in the document flow, while still allowing the table to be split acros several pages.

If I remove page-break-inside=”avoid”, then I get a table that breaks across several pages nicely, but cases described in #1 would not be matched. I.e. it does not move a table and it’s heading entirely to the next page if only a few rows would end up being moved to the next page. If I leave page-break-inside, then I get a content overflow problem with long tables, because rows that don’t fit on the page are not moved to the next page.

I guess one of the basic problems is that my output tables are very dynamic in length and unfortunately I don’t have any control over what amount of data gets produced into the tables.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:29:29+00:00Added an answer on May 27, 2026 at 1:29 am

    The CSS property page-break-inside=”avoid” maps to the native FO property keep-together=”always”. This mapping is questionable IMO (but that’s a different story). Anyway, I suggest you use the native FO property keep-together.within-column=”1″ instead of page-break-inside. That allows Apache FOP to break inside the table when absolutely necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.