简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM