代码之家  ›  专栏  ›  技术社区  ›  Sebastián

如何在pdfmake中创建表尾

  •  5
  • Sebastián  · 技术社区  · 7 年前

    有没有办法在pdfMake中创建表尾?我有一张只适合多页的大桌子。我想在每页上重复表尾。

    4 回复  |  直到 7 年前
        1
  •  2
  •   ForestG    7 年前
        2
  •  2
  •   Manu    6 年前

    将此添加到文档中:

    footer: {
        columns: [ 
            '',
            { 
                alignment: 'right',
                text: 'Footer text'
            }
        ],
        margin: [10, 0]
    }
    
        3
  •  1
  •   Lane    5 年前

    我终于想出了办法。 (1)将当前的“headerRows”计数增加1。 (2.)将页脚行放在页眉行和数据行之间。 (3.)将页脚行的marginTop设置为略小于页面高度。 (4.)将页脚行的marginBottom设置为((marginTop+行高)*-1)。

    这会将表的页脚从表的空间推到页面的页脚空间。

    示例:

    table: { headerRows: 2, widths: [700], body: [
      [{ text: 'My Header' }],
      [{ marginTop: 480, marginBottom: -490, text: 'My Footer' }], //480 roughly fits Landscape-Letter
      [{ text: 'My Data Row 1' }],
      [{ text: 'My Data Row 2' }],
      // more data rows
      [{ text: 'My Data Row N' }]
    ]}
    
        4
  •  -1
  •   Sushil    3 年前

    尝试此页脚

     footer: function (currentPage, pageCount) {
            return currentPage.toString() + " of " + pageCount;
          },
    

      footer: {
            columns: [
              'Report generated on 8/30/2021 6:02:31PM',
              { text: 'Page 1 of 2', alignment: 'right' },
              // { text: 'Developed by KRATOS Fitness Software ', alignment: 'left' },
            ],
          },
    
      footer: {
              columns: [
                  'Report generated on 8/30/2021 6:02:31PM',
                  'Developed by XYZ Fitness Software',
                  {
                      alignment: 'right',
                      text: 'Page 1 of 2'
                  },
                  {
                    alignment: 'right',
                    text: 'www.xyz.com'
                },
              ],
              margin: [60, 10, 60, 10 ]
          },
    

    这是工作