jsPDF Tutorial to Insert Hyperlinks in PDF Document Using link() & textWithLink() Methods in Browser Using HTML5



Hi everyone, I’ve noticed that there isn’t clear documentation for the .link() and .textWithLink() features, so I’m writing up a doc here.


jsPDF Method Argument type(s) Description
link(x, y, w, h, options) number, number, number, number, Object Creates a transparent rectangular hyperlink at the chosen coordinates.
textWithLink(text, x, y, options) string, number, number, Object Creates plain text with a hyperlink overlay at the chosen coordinates.

options object

Optional Field Type Default Description
url string undefined An external URL to link to.
pageNumber number undefined A PDF page number to link to.
name string undefined Name of an element in the PDF to link to? (Unknown)
magFactor string 'XYZ' For pageNumber links: The zoom/magnification strategy to use. Available options: 'Fit''FitH''FitV', and 'XYZ'.
top number 0 For pageNumber links: The vertical position to use as the top of the page (only used on 'FitH' and 'XYZ' magFactors).
left number 0 For pageNumber links: The horizontal position to use as the left of the page (only used on 'FitV' and 'XYZ' magFactors).
zoom number 0 For pageNumber links: The zoom level to apply (only used on 'XYZ' magFactors).


Leave a Reply