Attempt to fix scaling issue
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pierre HUBERT 2023-08-28 10:09:54 +02:00
parent 209cfe8965
commit c433934d68

View File

@ -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