Skip to content

Commit c7e4c3f

Browse files
committed
Fix nested properties in hyperlink plugin
1 parent 2d5856f commit c7e4c3f

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/plugin/hyperlinks.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,31 @@ Worker.prototype.toPdf = function toPdf() {
1111
// Add hyperlinks if the option is enabled.
1212
if (this.opt.enableLinks) {
1313
// Find all anchor tags and get the container's bounds for reference.
14-
var links = this.container.querySelectorAll('a');
15-
var containerRect = unitConvert(this.container.getBoundingClientRect(), this.pageSize.k);
14+
var container = this.prop.container;
15+
var links = container.querySelectorAll('a');
16+
var containerRect = unitConvert(container.getBoundingClientRect(), this.prop.pageSize.k);
1617

1718
// Loop through each anchor tag.
1819
Array.prototype.forEach.call(links, function(link) {
1920
// Treat each client rect as a separate link (for text-wrapping).
2021
var clientRects = link.getClientRects();
2122
for (var i=0; i<clientRects.length; i++) {
22-
var clientRect = unitConvert(clientRects[i], this.pageSize.k);
23+
var clientRect = unitConvert(clientRects[i], this.prop.pageSize.k);
2324
clientRect.left -= containerRect.left;
2425
clientRect.top -= containerRect.top;
2526

26-
var page = Math.floor(clientRect.top / this.pageSize.inner.height) + 1;
27-
var top = this.opt.margin[0] + clientRect.top % this.pageSize.inner.height;
27+
var page = Math.floor(clientRect.top / this.prop.pageSize.inner.height) + 1;
28+
var top = this.opt.margin[0] + clientRect.top % this.prop.pageSize.inner.height;
2829
var left = this.opt.margin[1] + clientRect.left;
2930

30-
this.pdf.setPage(page);
31-
this.pdf.link(left, top, clientRect.width, clientRect.height, { url: link.href });
31+
this.prop.pdf.setPage(page);
32+
this.prop.pdf.link(left, top, clientRect.width, clientRect.height, { url: link.href });
3233
}
3334
});
3435

3536
// Reset the active page of the PDF to the final page.
36-
var nPages = this.pdf.putTotalPages().internal.getNumberOfPages();
37-
this.pdf.setPage(nPages);
37+
var nPages = this.prop.pdf.putTotalPages().internal.getNumberOfPages();
38+
this.prop.pdf.setPage(nPages);
3839
}
3940
});
4041
};

0 commit comments

Comments
 (0)