diff --git a/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx b/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx index fcc7a79..c4b6abd 100644 --- a/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx +++ b/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx @@ -5,6 +5,10 @@ import { FamilyTreeNode } from "../../utils/family_tree"; import { Member, fmtDate } from "../../api/MemberApi"; import { Couple } from "../../api/CoupleApi"; import { useDarkTheme } from "../../hooks/context_providers/DarkThemeProvider"; +import { IconButton } from "@mui/material"; +import PictureAsPdfIcon from "@mui/icons-material/PictureAsPdf"; +import { jsPDF } from "jspdf"; +import "svg2pdf.js"; export function ComplexFamilyTree(p: { tree: FamilyTreeNode; @@ -69,12 +73,58 @@ export function ComplexFamilyTree(p: { store.update.tree({ initial: true }); }; + const exportPDF = async () => { + const doc = new jsPDF({ + orientation: "l", + format: [1000, 1000], + }); + + // Clone the SVG to manipulate it + const srcEl = document.getElementById("FamilyChart")?.children[0]!; + const srcSVG = srcEl.innerHTML!; + + // SVG manipulations (adaptations to export) + let dstSVG = srcSVG.replaceAll( + ` +
+
+ + + +
+
+
); } @@ -211,21 +261,3 @@ function treeToF3DataDownRecurse( } } } - -/* -import { jsPDF } from "jspdf"; -import "svg2pdf.js"; - -setTimeout(() => { - const doc = new jsPDF({ - orientation: "l", - format: [1000, 1000], - }); - - const element = document.getElementById("FamilyChart"); - console.log(element); - doc.svg(element!.children[0], { height: 1000, width: 1000 }).then(() => { - // save the created pdf - //doc.save("myPDF.pdf"); - }); - }, 6000);*/