Skip to content

Commit

Permalink
added support link, linkToPage and linkToDestination for SVG #2770
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Nov 1, 2024
1 parent 2260545 commit 40fb9d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Changed Virtual file system (VFS) format for better compatibility with frameworks (backwards compatibility preserved). **For compatibility with frameworks, rebuild VFS required!**
- Browser: Added methods for fonts (`addFonts`, `setFonts`, `clearFonts`)
- Browser: Added methods for table layouts (`addTableLayouts`, `setTableLayouts`, `clearTableLayouts`)
- Added support `link`, `linkToPage` and `linkToDestination` for SVG
- Update pdfkit to 0.15.1
- Fixed bug with how page breaks provoked by cells with rowspan were handled
- Fixed find where previous cell started with row span and col span combination
Expand Down
11 changes: 11 additions & 0 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,17 @@ function renderSVG(svg, x, y, pdfKitDoc, fontProvider) {
};

SVGtoPDF(pdfKitDoc, svg.svg, svg.x, svg.y, options);

if (svg.link) {
pdfKitDoc.link(svg.x, svg.y, svg._width, svg._height, svg.link);
}
if (svg.linkToPage) {
pdfKitDoc.ref({Type: 'Action', S: 'GoTo', D: [svg.linkToPage, 0, 0]}).end();
pdfKitDoc.annotate(svg.x, svg.y, svg._width, svg._height, { Subtype: 'Link', Dest: [svg.linkToPage - 1, 'XYZ', null, null, null] });
}
if (svg.linkToDestination) {
pdfKitDoc.goTo(svg.x, svg.y, svg._width, svg._height, svg.linkToDestination);
}
}

function beginClip(rect, pdfKitDoc) {
Expand Down

0 comments on commit 40fb9d0

Please sign in to comment.