Jirin
Jirin

Reputation: 33

One page only by content

Please, how to do in xsl-fo something as receipt printing? It means only one page printout with height of page by content? So far, I have only working with A4 printouts with paging, now I need to print a long receipt, ie a single-page long printout, where I do not know the length of the page. Thanks.

Upvotes: 0

Views: 269

Answers (1)

Tony Graham
Tony Graham

Reputation: 8068

You could do it in two passes:

  • Format the receipt on a very long page
  • Get the area tree of the formatted receipt to find the height of the content
  • Format again using a page of the desired height

XSL-FO, as implemented, really only works with fixed page heights. XSL 1.1 allows you to use page-height="indefinite" (see https://www.w3.org/TR/xsl11/#page-height), but AFAIK, it isn't implemented by any formatter.

Every formatter (I believe) can output an XML representation of its formatted result. Area Tree XML is formatter-specific, but you may be able to use the XSLT Extensions from the Print and Page Layout Community Group (see https://www.w3.org/community/ppl/wiki/XSLTExtensions and https://github.com/pplcg/XSLTExtensions) both to simplify working with the Area Tree XML and to do it within your XSLT transformation.

Once you know how much space the receipt needs, you can regenerate/modify the XSL-FO to use a page of the correct height to fit everything exactly.

Upvotes: 1

Related Questions