Apache FOP - Table component getting misaligned from second page onwards

风流意气都作罢 提交于 2020-01-17 05:34:26

问题


I am using FOP version 2.0. My template has some text paragraphs on first page after which there is a dynamic table with n number of rows.

The issue is that The table layout is perfect till the rows on first page of the generated PDF file. But when it continues on the 2nd page, the columns are shifted to the right by some margin and the last column becomes invisible. Any insight on this what may be the reason?

Below is he relevant portion of FO template with page masters and initial table code.

<fo:layout-master-set>
    <fo:simple-page-master master-name="first" margin-right="0.5cm"
                           margin-left="0.5cm" margin-bottom="0.5cm"
                           margin-top="0.75cm" page-width="21cm"
                           page-height="29.7cm">
      <fo:region-body></fo:region-body>
    </fo:simple-page-master>
    <fo:simple-page-master master-name="rest" margin-right="2.5cm"
                           margin-left="2.5cm" margin-bottom="2cm"
                           margin-top="1cm" page-width="21cm"
                           page-height="29.7cm">
      <fo:region-body></fo:region-body>
    </fo:simple-page-master>
    <fo:page-sequence-master master-name="psmA">
      <fo:repeatable-page-master-alternatives>
        <fo:conditional-page-master-reference master-reference="first"
                                              page-position="first"/>
        <fo:conditional-page-master-reference master-reference="rest"
                                              page-position="rest"/>
        <!-- recommended fallback procedure -->
        <fo:conditional-page-master-reference master-reference="rest"/>
      </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="psmA">
    <fo:flow flow-name="xsl-region-body">

 <fo:block-container height="0.5cm" width="7.40cm" top="8.80cm"
                          left="0.3cm" padding=".4mm" position="absolute">
        <fo:block text-align="start" space-after.optimum="3pt"
                  line-height="14pt" font-family="sans-serif" font-size="12pt">Header
                                                                               Options</fo:block>
      </fo:block-container>
      <fo:block-container border-style="solid" border-width=".5mm"
                          height="1.00cm" width="16.40cm" top="8.80cm"
                          left="3.40cm" padding=".4mm" position="absolute">
        <fo:block text-align="start" space-after.optimum="3pt"
                  line-height="14pt" font-family="sans-serif" font-size="12pt">$header.miscInfo</fo:block>
      </fo:block-container>

       <fo:block  margin-left="0.40cm" margin-top="10.30cm" padding=".4mm" >
        <fo:table border-top-style="solid" border-top-width="thick" >
        <fo:table-header text-align="center" >
        <fo:table-row border-bottom-style="solid" border-bottom-color="#000"
                          border-bottom-width="thick">
              <fo:table-cell padding-top="1mm" padding-bottom="1mm">

and the table rows continue in an iterative manner after the header.

Any insight on this what may be the reason for this behaviour?

Thanks in advance.


回答1:


Your document has two kind of pages, as defined by your fo:simple-page-master elements:

  • the first page is created using the page master named first which has small side margins (0.5 cm on both left and right sides)
  • the following pages are created with the rest page master, whose side margins are much wider (2.5 cm each)

You should probably modify the page master definitions to have similar left and right margins on all the page types.



来源:https://stackoverflow.com/questions/37442963/apache-fop-table-component-getting-misaligned-from-second-page-onwards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!