diff --git a/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx b/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx index a16707f..8f3d00b 100644 --- a/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx +++ b/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx @@ -162,7 +162,7 @@ export function SimpleFamilyTree(p: { console.info(`tree width=${tree.width} height=${height}`); const doExport = async (onlySVG: boolean) => { - const el = document.querySelector(".simpletree")!; + const el: HTMLElement = document.querySelector(".simpletree")!; const svg = el.outerHTML; // Download in SVG format @@ -178,10 +178,18 @@ export function SimpleFamilyTree(p: { const PDF_MARGIN = 10; + const PDF_MAX_SIZE = 14400 - PDF_MARGIN * 2; + + const tree_width = Math.min(tree.width, PDF_MAX_SIZE); + const tree_height = Math.min(height, PDF_MAX_SIZE); + + console.info(`pdf tree w=${tree_width} h=${tree_height}`); + // Download in PDF format const doc = new jsPDF({ orientation: "l", - format: [height + PDF_MARGIN * 2, tree.width + PDF_MARGIN * 2], + unit: "px", + format: [tree_height + PDF_MARGIN * 2, tree_width + PDF_MARGIN * 2], }); doc.setFont("Roboto", "normal"); @@ -189,8 +197,8 @@ export function SimpleFamilyTree(p: { await doc.svg(el, { x: PDF_MARGIN, y: PDF_MARGIN, - height: height, - width: tree.width, + height: tree_height, + width: tree_width, }); // Save the created pdf