简体   繁体   中英

How can I limit in xsl-fo to print at maximum 10 pages for pdf document?

I use apache FOP to export data in pdf files. Every time i'm trying to export large tables (more than 4000 raws) i'm gettin "outOfMemoryError". My question - how can I set limit in xsl-fo to print at maximum 10 pages in one pdf document?

In general, you can't.

The way that XSL is specified, you can't limit the number of pages. There is a force-page-count property (see https://www.w3.org/TR/xsl11/#force-page-count ) but this is for forcing an fo:page-sequence to end on an odd or even page, not to force a specific number of pages. You could try setting your fo:page-sequence-master (see https://www.w3.org/TR/xsl11/#fo_page-sequence-master ) to run out of alternatives after a certain number of pages, but you'll probably find that the formatter will recover from the error (as it is allowed to do) by continuing to re-use the last-used page master.

The FOP advice about memory usage is at https://xmlgraphics.apache.org/fop/2.3/running.html#memory

Can you (as the FOP advice says) split your tables into multiple fo:page-sequence ? FOP is inclined to release some memory after its finished with a page sequence.

You could try using a different formatter. It may do better at your tables, it may have two-pass processing (most useful when there's a lot of forward references), or it may have an option for formatting only a limited number of pages. For example, AH Formatter can do two-pass formatting and it can output only the pages between specified start and end pages (see https://www.antennahouse.com/product/ahf66/ahf-xslcmd.html ), and XEP can output the first n pages for SVG and XHTML output (see http://www.renderx.com/reference.html#Generate_Each_Page_as_separate_file ).

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