File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,13 +55,20 @@ var html2pdf = (function(html2canvas, jsPDF) {
5555
5656 // Get the locations of all hyperlinks.
5757 if ( opt . enableLinks ) {
58+ // Find all anchor tags and get the container's bounds for reference.
59+ opt . links = [ ] ;
5860 var links = container . querySelectorAll ( 'a' ) ;
5961 var containerRect = unitConvert ( container . getBoundingClientRect ( ) , pageSize . k ) ;
60- opt . links = Array . prototype . map . call ( links , function ( link ) {
61- var clientRect = unitConvert ( link . getBoundingClientRect ( ) , pageSize . k ) ;
62- clientRect . left -= containerRect . left ;
63- clientRect . top -= containerRect . top ;
64- return { el : link , clientRect : clientRect } ;
62+
63+ // Treat each client rect as a separate link (for text-wrapping).
64+ links . forEach ( function ( link ) {
65+ var clientRects = link . getClientRects ( ) ;
66+ for ( var i = 0 ; i < clientRects . length ; i ++ ) {
67+ var clientRect = unitConvert ( clientRects [ i ] , pageSize . k ) ;
68+ clientRect . left -= containerRect . left ;
69+ clientRect . top -= containerRect . top ;
70+ opt . links . push ( { el : link , clientRect : clientRect } ) ;
71+ }
6572 } ) ;
6673 }
6774
You can’t perform that action at this time.
0 commit comments