From 2156210952d460ab270b22d7de302f737906caa1 Mon Sep 17 00:00:00 2001 From: dlawler489 <104159223@student.swin.edu.au> Date: Tue, 3 Jun 2025 10:59:09 +1000 Subject: [PATCH] Update script.js --- script/script.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/script/script.js b/script/script.js index 4fa26df..94dc611 100644 --- a/script/script.js +++ b/script/script.js @@ -250,20 +250,24 @@ Promise.all([ return; } const { jsPDF } = window.jspdf; - const doc = new jsPDF({ - orientation: 'landscape', - unit: 'pt', - format: [960, 600] - }); - const svgElement = document.querySelector("svg"); const svgClone = svgElement.cloneNode(true); svgClone.removeAttribute("style"); - svgClone.setAttribute("width", "960"); - svgClone.setAttribute("height", "600"); // Ensure correct namespace for svg2pdf svgClone.setAttribute("xmlns", "http://www.w3.org/2000/svg"); + // Set cloned SVG width and height explicitly + svgClone.setAttribute("width", svg.attr("width")); + svgClone.setAttribute("height", svg.attr("height")); + + // Use fixed format and orientation + const doc = new jsPDF({ + orientation: 'landscape', + unit: 'pt', + format: [+svg.attr("width"), +svg.attr("height")] + }); + + // Use standard margin offset and scale await window.svg2pdf(svgClone, doc, { xOffset: 0, yOffset: 0,