首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在xsl-fo中乘以页面序列?

如何在xsl-fo中乘以页面序列?
EN

Stack Overflow用户
提问于 2019-06-06 04:32:37
回答 1查看 0关注 0票数 0

我正在使用apache fop将表导出为pdf。当我试图导出大表(超过4000行)时,我得到OutOfMemory错误。在一些论坛上,我得到的信息是页面序列的倍增可以解决这个问题,但我不知道如何在我的情况下这样做。我将把我的.fo代码放在下面。请帮帮我

代码语言:javascript
复制
<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>&#160;</fo:block>
                    </fo:table-cell>
                #end
            </fo:table-row>
        #end

        </fo:table-body>
      </fo:table>
    #end
   </fo:flow>
  </fo:page-sequence>
</fo:root>
EN

回答 1

Stack Overflow用户

发布于 2019-06-06 14:05:09

我建议你需要用#foreach等命令语言做一些事情(我不认识)。

基本上,在你拥有的地方#if ($data.TableColumns.size() > 0),你应该找到一种方法来$data.TableData组成10行的组。我不知道该语言是否有类似的模数运算符。

10行,每行大块需要做出独立fo:tablefo:table-header以及fo:table-body就像你现在要做的。在#foreach($row in $data.TableData)需要做同样的事情,只是当前组。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100006945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档