Skip to content

Commit 40fb9d0

Browse files
committed
added support link, linkToPage and linkToDestination for SVG #2770
1 parent 2260545 commit 40fb9d0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Changed Virtual file system (VFS) format for better compatibility with frameworks (backwards compatibility preserved). **For compatibility with frameworks, rebuild VFS required!**
77
- Browser: Added methods for fonts (`addFonts`, `setFonts`, `clearFonts`)
88
- Browser: Added methods for table layouts (`addTableLayouts`, `setTableLayouts`, `clearTableLayouts`)
9+
- Added support `link`, `linkToPage` and `linkToDestination` for SVG
910
- Update pdfkit to 0.15.1
1011
- Fixed bug with how page breaks provoked by cells with rowspan were handled
1112
- Fixed find where previous cell started with row span and col span combination

src/printer.js

+11
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,17 @@ function renderSVG(svg, x, y, pdfKitDoc, fontProvider) {
692692
};
693693

694694
SVGtoPDF(pdfKitDoc, svg.svg, svg.x, svg.y, options);
695+
696+
if (svg.link) {
697+
pdfKitDoc.link(svg.x, svg.y, svg._width, svg._height, svg.link);
698+
}
699+
if (svg.linkToPage) {
700+
pdfKitDoc.ref({Type: 'Action', S: 'GoTo', D: [svg.linkToPage, 0, 0]}).end();
701+
pdfKitDoc.annotate(svg.x, svg.y, svg._width, svg._height, { Subtype: 'Link', Dest: [svg.linkToPage - 1, 'XYZ', null, null, null] });
702+
}
703+
if (svg.linkToDestination) {
704+
pdfKitDoc.goTo(svg.x, svg.y, svg._width, svg._height, svg.linkToDestination);
705+
}
695706
}
696707

697708
function beginClip(rect, pdfKitDoc) {

0 commit comments

Comments
 (0)