Add image in header using html-pdf node module

后端 未结 6 1085
轻奢々
轻奢々 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-13 23:43

    Maybe will be helpful for someone.

    Shanoor answer is correct and code example he provided works well if you don't set "base" property for options.

    So remove "base" property and make path full.

    One more way to get the path to the image. This snippet

    var projectRoot = process.cwd();
    projectRoot = projectRoot.replace(/\\/g,'/');
    var imgBase = 'file:///' + projectRoot + 'path to the image';

    Will return something like this file:///C:/project folder/path to the image/img1.jpg

提交回复
热议问题