Update script.js
This commit is contained in:
parent
897d1a8f1e
commit
2156210952
1 changed files with 12 additions and 8 deletions
|
|
@ -250,20 +250,24 @@ Promise.all([
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { jsPDF } = window.jspdf;
|
const { jsPDF } = window.jspdf;
|
||||||
const doc = new jsPDF({
|
|
||||||
orientation: 'landscape',
|
|
||||||
unit: 'pt',
|
|
||||||
format: [960, 600]
|
|
||||||
});
|
|
||||||
|
|
||||||
const svgElement = document.querySelector("svg");
|
const svgElement = document.querySelector("svg");
|
||||||
const svgClone = svgElement.cloneNode(true);
|
const svgClone = svgElement.cloneNode(true);
|
||||||
svgClone.removeAttribute("style");
|
svgClone.removeAttribute("style");
|
||||||
svgClone.setAttribute("width", "960");
|
|
||||||
svgClone.setAttribute("height", "600");
|
|
||||||
// Ensure correct namespace for svg2pdf
|
// Ensure correct namespace for svg2pdf
|
||||||
svgClone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
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, {
|
await window.svg2pdf(svgClone, doc, {
|
||||||
xOffset: 0,
|
xOffset: 0,
|
||||||
yOffset: 0,
|
yOffset: 0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue