【问题标题】:Nested/Sub Tables with PDFMake使用 PDFMake 的嵌套/子表
【发布时间】:2016-09-12 16:30:16
【问题描述】:

如何在 PDFmake 中使用嵌套/子表?我试过简单地放入多个表格,但这不会自动重复顶级表格的标题以进行分页。

【问题讨论】:

    标签: pdfmake


    【解决方案1】:

    此代码是使用子表的简化示例。它改编自 pdfmake 游乐场的表格部分(通过 Google 搜索不容易找到)。

    将以下内容粘贴到:http://pdfmake.org/playground.html

    // playground requires you to assign document definition to a variable called dd
    
    var dd = {
        content: [
    
                    { text: 'A simple table with nested elements', style: 'subheader' },
                    'It is of course possible to nest any other type of nodes available in pdfmake inside table cells',
                    {
                            style: 'tableExample',
                            table: {
                                    headerRows: 1,
                                    body: [
                                            ['Column 1', 'Column 2'],
                                            [
                                                    {
                                                            stack: [
                                                                    'Let\'s try an unordered list',
                                                                    {
                                                                            ul: [
                                                                                    'item 1',
                                                                                    'item 2'
                                                                            ]
                                                                    }
                                                            ]
                                                    },
                                                    [
                                                        'or a nested table',
                                                        {
                                                            table: {
                                                                body: [
                                                                    [ 'Col1', 'Col2', 'Col3'],
                                                                    [ '1', '2', '3'],
                                                                    [ '1', '2', '3']
                                                                ]
                                                            },
                                                        }
                                                    ]
                                            ]
                                    ]
                            }
                    },
    
        ]
    
    }
    

    【讨论】:

      【解决方案2】:

      我需要实现与上面几乎相似的功能。我已经尝试了很多,但没有做对。如何创建一个使用 pdfmake 生成 pdf 输出的 json 数组?我需要在一个表中创建一个表:

      var dd = {
        content: [
          {
            text: 'A simple table with nested elements',
            style: 'subheader'
          },
          'It is of course possible to nest any other type of nodes available in pdfmake inside table cells',
          {
            style: 'tableExample',
            table: {
              headerRows: 1,
              body: [
                ['Column 1', 'Column 2'],
                [
                  [
                    'or a nested table',
                    {
                      table: {
                        body: [
                          [ 'Col1', 'Col2', 'Col3'],
                          [ '1', '2', '3'],
                          [ '1', '2', '3']
                        ]
                      },
                    }
                  ]
                ]
              ]
            }
          },
        ]
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-15
        • 1970-01-01
        • 2018-01-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多