html2canvas to render document PDF with css styling using angular2/typescript

后端 未结 5 740
情话喂你
情话喂你 2021-01-02 05:24

How to generate an output file PDF using html2canvas with angular2

I tried to import the file html2canvas typescript and made a declaration like this to use it

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-02 06:27

    This is in addition to above answer, i.e. add @types/html2canvas to dependencies and add import statement in your code.

    However, using the above sample code, I am getting error in VisualStudioCode i.e.

    'onrendered' does not exist in type 'Html2CanvasOptions'.

    To resolve that, I used "then" as below:

    html2canvas(document.body).then((canvas) => {
      document.body.appendChild(canvas);
    });
    

提交回复
热议问题