Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add HyperLink with JsPDF?

Tags:

jspdf

Is it possible to add HyperLink in jsPDF?

Here is my code which I am using for the same.

    var doc = new jsPDF('p', 'pt'); 
    doc.fromHTML(
     '<a href="http://www.google.com">Click Here</a>',
     35,
     25,
     {
         'width': 180, 'elementHandlers': elementHandler
     });
     doc.save("info.pdf");
like image 307
Sachin Avatar asked Jun 20 '16 09:06

Sachin


1 Answers

I got the solution after sicking from last two hours. there is also a method in jsPDF which is not so popular i.e.

doc.textWithLink('Click here', x, y, { url: 'http://www.google.com' });

Hope it will help someone :)

like image 107
Sachin Avatar answered Nov 04 '22 11:11

Sachin