最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - pdfMake page break effect when used canvas with type="line" - Stack Overflow

programmeradmin1浏览0评论

I would appreciate if someone explain me, which one can be that case, when the canvas declaration with type "line" emit a page break, in the pdf. I unable to figured out what is the cause of it. If I removed all cancas, no page break in the downloaded pdf.

Thank you in advance.

Here is the code which I used:

var dd = {
  content: [{
      "canvas": [{
        "lineColor": "gray",
        "type": "line",
        "x1": 0,
        "y1": 0,
        "x2": 515,
        "y2": 0,
        "lineWidth": 1
      }]
    },
    {
      "margin": [5, 10, 0, 5],
      "layout": "noBorders",
      "fontSize": 10,
      "table": {
        "heights": 18,
        "widths": [110, "*", "*", "*"],
        "body": [
          [{
              "text": "Text 1",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 1 value"
            }

          ],
          [{
              "text": "Text 2",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 2 value"
            }
          ]
        ]
      }
    },
    {
      "canvas": [{
        "lineColor": "gray",
        "type": "line",
        "x1": 0,
        "y1": 0,
        "x2": 515,
        "y2": 0,
        "lineWidth": 1
      }]
    },
    {
      "margin": [5, 10, 0, 5],
      "layout": "noBorders",
      "fontSize": 10,
      "table": {
        "heights": 18,
        "widths": [110, "*", "*", "*"],
        "body": [
          [{
              "text": "Text 1",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 1 value"
            }

          ],
          [{
              "text": "Text 2",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 2 value"
            }
          ]
        ]
      }
    }
  ]
}

I would appreciate if someone explain me, which one can be that case, when the canvas declaration with type "line" emit a page break, in the pdf. I unable to figured out what is the cause of it. If I removed all cancas, no page break in the downloaded pdf.

Thank you in advance.

Here is the code which I used:

var dd = {
  content: [{
      "canvas": [{
        "lineColor": "gray",
        "type": "line",
        "x1": 0,
        "y1": 0,
        "x2": 515,
        "y2": 0,
        "lineWidth": 1
      }]
    },
    {
      "margin": [5, 10, 0, 5],
      "layout": "noBorders",
      "fontSize": 10,
      "table": {
        "heights": 18,
        "widths": [110, "*", "*", "*"],
        "body": [
          [{
              "text": "Text 1",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 1 value"
            }

          ],
          [{
              "text": "Text 2",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 2 value"
            }
          ]
        ]
      }
    },
    {
      "canvas": [{
        "lineColor": "gray",
        "type": "line",
        "x1": 0,
        "y1": 0,
        "x2": 515,
        "y2": 0,
        "lineWidth": 1
      }]
    },
    {
      "margin": [5, 10, 0, 5],
      "layout": "noBorders",
      "fontSize": 10,
      "table": {
        "heights": 18,
        "widths": [110, "*", "*", "*"],
        "body": [
          [{
              "text": "Text 1",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 1 value"
            }

          ],
          [{
              "text": "Text 2",
              "margin": [10, 0, 0, 0],
              "bold": true
            },
            {
              "text": "Text 2 value"
            }
          ]
        ]
      }
    }
  ]
}
Share Improve this question edited Aug 27, 2018 at 20:30 SiddAjmera 39.5k6 gold badges76 silver badges113 bronze badges asked Aug 27, 2018 at 20:14 L. KvriL. Kvri 1,7334 gold badges26 silver badges46 bronze badges 2
  • One more thing which can be help, the line in the pdf shifted right, but in the preview it is not shifted. – L. Kvri Commented Aug 27, 2018 at 20:17
  • did you got solution to your problem ? @Laszlo – J4GD33P 51NGH Commented Sep 21, 2020 at 7:39
Add a ment  | 

1 Answer 1

Reset to default 4

Got Alternative solution to draw line without using canvas:

          {
                table : {
                    headerRows : 1,
                    widths: [930],
                    body : [
                            [''],
                            ['']
                            ]
                },
                layout : 'headerLineOnly'
          }
发布评论

评论列表(0)

  1. 暂无评论