我正在使用apache fop将表导出为pdf。当我试图导出大表(超过4000行)时,我得到OutOfMemory错误。在一些论坛上,我得到的信息是页面序列的倍增可以解决这个问题,但我不知道如何在我的情况下这样做。我将把我的.fo代码放在下面。请帮帮我
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="page"
page-height="21cm"
page-width="29.7cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="1.5cm"
margin-right="1.5cm">
<fo:region-body margin-top="1cm"/>
<fo:region-before region-name="page-header" extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="page">
<fo:static-content flow-name="page-header">
<fo:block text-align="right" font-size="10pt" font-family="Arial">
<page number><fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="14pt"
font-family="Arial"
line-height="24pt"
space-after.optimum="5pt"
background-color="gray"
color="white"
text-align="center"
padding-top="3pt">
$!data.Title
</fo:block>
#foreach($header in $!data.DocumentHeaders)
<fo:block font-size="12pt"
font-family="Arial"
text-align="left">
<fo:inline>$!header.Name</fo:inline>
<fo:inline>:</fo:inline>
<fo:inline>$!header.Value</fo:inline>
</fo:block>
#end
#if ($data.TableColumns.size() > 0)
<fo:table table-layout="fixed" width="100%" border-collapse="separate" font-family="Arial" >
#foreach($column in $data.TableColumns)
<fo:table-column column-width="${column.Width}mm"/>
#end
<fo:table-header>
<fo:table-row font-size="8pt">
#foreach($column in $data.TableColumns)
<fo:table-cell border-width="0.25mm" border-style="solid">
<fo:block hyphenate="true" language="ru">
$column.Caption
</fo:block>
</fo:table-cell>
#end
</fo:table-row>
</fo:table-header>
<fo:table-body>
#if (!$data.TableData.isEmpty())
#foreach($row in $data.TableData)
<fo:table-row font-size="8pt">
#foreach($column in $data.TableColumns)
<fo:table-cell border-width="0.25mm" border-style="solid" background-color="$column.getColor($row)">
<fo:block hyphenate="true" language="ru">
<![CDATA[
$!column.getCellValue($row)
]]>
</fo:block>
</fo:table-cell>
#end
</fo:table-row>
#end
#else
<fo:table-row font-size="8pt">
#foreach($column in $data.TableColumns)
<fo:table-cell border-width="0.25mm" border-style="solid">
<fo:block> </fo:block>
</fo:table-cell>
#end
</fo:table-row>
#end
</fo:table-body>
</fo:table>
#end
</fo:flow>
</fo:page-sequence>
</fo:root>
发布于 2019-06-06 14:05:09
我建议你需要用#foreach
等命令语言做一些事情(我不认识)。
基本上,在你拥有的地方#if ($data.TableColumns.size() > 0)
,你应该找到一种方法来$data.TableData
组成10行的组。我不知道该语言是否有类似的模数运算符。
10行,每行大块需要做出独立fo:table
,fo:table-header
以及fo:table-body
就像你现在要做的。在#foreach($row in $data.TableData)
需要做同样的事情,只是当前组。
https://stackoverflow.com/questions/-100006945
复制相似问题