user2042963
user2042963

Reputation: 15

JSPDF - display hand signature from canvas

How can I get a hand drawn signature onto the PDF? I have a jquery mobile report which the customer signs at the end. After the signature is drawn on the canvas it is displayed back to the customer.

I am then converting the report to PDF using JSPdf. I am displaying text, tables, and a logo with no problem, but this signature thing has really stumped me. With a normal pic you just convert to a URI and the pic is displayed but all I am getting with the signature is the URI.

enter image description here

Upvotes: 0

Views: 2798

Answers (2)

user2042963
user2042963

Reputation: 15

The answer was as simple as finding the generated image. Thank you once again.

var SigImg = document.getElementById("sig-image");
doc.addImage(SigImg, 'png', 20, 20, 100, 40)

Upvotes: 1

Harish Kommuri
Harish Kommuri

Reputation: 2854

Use signaturepad.js jQuery plugin to generate base64 coded signature image. Use that code as image src in htmltopdf in jspdf

signaturepad.js documentation

Upvotes: 1

Related Questions