0
votes

Is there a way in XSL-FO to define a single page layout? meaning that all content should be on a single page. Basically the page should be as long as the content, which is dynamic.

I'm using Apache FOP.

Any help will be appreciated.

2
What have you tried so far that has not worked? How much content are you talking about?Tony Graham
@TonyGraham The content is dynamic. I don't have anything to show as I couldn't figure out how to do it or if that even possible.Wolf
If you could do it, how would you print it? Would it be for viewing only?Tony Graham
You could create a document with a huge page-height. Format your document to the formatter's area tree and then examine the last content's "Y" value and set the page-height in the area tree to this value and reformat.Kevin Brown
@KevinBrown can you give me an example of how to accomplish this?Wolf

2 Answers

0
votes

You want a formatter that supports page-height="indefinite". (See https://www.w3.org/TR/xsl11/#page-height)

I don't know any formatter that supports page-height="indefinite". AH Formatter doesn't (https://www.antenna.co.jp/AHF/help/v70e/ahf-fo11.html#page-height). FOP says 'not yet' (https://xmlgraphics.apache.org/fop/compliance.html#fo-property-page-height). RenderX don't qualify their support for page-height, so they might (http://www.renderx.com/reference.html).

0
votes

You could use the XSLTExtensions (https://github.com/pplcg/XSLTExtensions, https://www.w3.org/community/ppl/wiki/XSLTExtensions) from the Print and Page Layout Community Group (http://www.w3.org/community/ppl/).

Within the single XSLT transformation that generates the XSL-FO, you could:

  • Make a variable for the XSL-FO for a very long page with the correct width
  • Run the extension on the variable to get the area tree
  • Use the extension's XSLT functions to get the height of the formatted content
  • Generate the XSL-FO again with the exact page height to fit the content

You would then format the output XSL-FO.

It might be simplest to put all of your content in an fo:block with known ID so that it's easy to get the height of the content by getting the height of the block.

It's been a while since I used the extensions, but that's the general idea.