Update script.js

This commit is contained in:
dlawler489 2025-06-03 10:59:09 +10:00
parent 897d1a8f1e
commit 2156210952

View file

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