Add image in header using html-pdf node module

后端 未结 6 1101
轻奢々
轻奢々 2021-02-13 23:10

I am using this to convert the html to PDF.The conversions are really good.But the problem is to add header and footer in the PDF pages.In the options if i add the header text i

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-13 23:53

    It is possible to add the image in options header. 1.Load the image in html body with "display:none" style. 2.Then add the image in the options header By doing this the image is cached and can attach the image in header.

        var options = {
        "format": 'Letter',
        "orientation": "portrait",
        "header": {
        "contents": "",
            "height": "30mm"
      },
      "footer": {
        "contents": footer
      }
    }
    pdf.create("
    ", options).toFile("sample.pdf", function(err, res) { if (err) { console.error(err); callback(); } });

提交回复
热议问题