Skip to content
Advertisement

html page screenshot to pdf using html2canvas and jspdf

I am trying to create a receipt or invoice to pdf by screenshot of a php page. I found a source code on youtube and tried it for myself, however, it is not saving or downloading any pdf.

here is the code and i made it as short as possible to be able to recreate:

JavaScript

in the youtube i watched, whenever he clicks the button, it downloads a sample.pdf, this one doesn’t or am i missing something, please help

Advertisement

Answer

Here is the working code for December 16, 2020

It was just a matter of

  1. referencing the old version of html2canvas
  2. referencing the old version of jspdf
  3. slightly wrong API call to jspdf

cheers

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement