简体   繁体   English

如何限制xsl-fo最多可打印pdf文档10页?

[英]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. 我使用apache FOP导出pdf文件中的数据。 Every time i'm trying to export large tables (more than 4000 raws) i'm gettin "outOfMemoryError". 每次我尝试导出大表(超过4000个原始数据)时,我都会收到“ outOfMemoryError”。 My question - how can I set limit in xsl-fo to print at maximum 10 pages in one pdf document? 我的问题-如何在xsl-fo中设置限制以在一个pdf文档中最多打印10页?

In general, you can't. 一般来说,您不能。

The way that XSL is specified, you can't limit the number of pages. XSL的指定方式,您不能限制页面数。 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. 有一个force-page-count属性(请参阅https://www.w3.org/TR/xsl11/#force-page-count ),但这是强制fo:page-sequence以奇数或偶数结尾页面,而不是强制使用特定数量的页面。 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. 您可以尝试将fo:page-sequence-master (请参阅https://www.w3.org/TR/xsl11/#fo_page-sequence-master )设置为在一定数量的页面后用完其他选项,但是ll可能会发现,通过继续重用上次使用的页面母版,格式化程序将从错误中恢复(允许这样做)。

The FOP advice about memory usage is at https://xmlgraphics.apache.org/fop/2.3/running.html#memory 有关内存使用情况的FOP建议位于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建议所述)将表格拆分为多个fo:page-sequence吗? FOP is inclined to release some memory after its finished with a page sequence. FOP在完成页面序列后倾向于释放一些内存。

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 ). 例如,AH Formatter可以进行两次遍历格式化,并且只能输出指定的起始页面和结束页面之间的页面(请参阅https://www.antennahouse.com/product/ahf66/ahf-xslcmd.html ),而XEP可以输出SVG和XHTML输出的前n页(请参见http://www.renderx.com/reference.html#Generate_Each_Page_as_separate_file )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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