Skip to content
Snippets Groups Projects
Commit f8acfe51 authored by Tomáš Hozman's avatar Tomáš Hozman
Browse files

repeatable downloads

parent 3ef42e24
No related branches found
No related tags found
No related merge requests found
...@@ -407,7 +407,7 @@ $(window).ready( ...@@ -407,7 +407,7 @@ $(window).ready(
} }
); );
const createPdf = () => { const createPdf = (page2Canvas = null) => {
const pdfDocument = new jsPDF({ const pdfDocument = new jsPDF({
orientation: "portrait", orientation: "portrait",
unit: "pt", unit: "pt",
...@@ -424,7 +424,10 @@ $(window).ready( ...@@ -424,7 +424,10 @@ $(window).ready(
pdfDocument.addPage(); pdfDocument.addPage();
pdfDocument.addImage( pdfDocument.addImage(
document.getElementById("page-2-canvas"), (
(page2Canvas === null) ?
document.getElementById("page-2-canvas") : page2Canvas
),
"JPEG", "JPEG",
0, 0, 0, 0,
595.28, 841.89 595.28, 841.89
...@@ -443,18 +446,29 @@ $(window).ready( ...@@ -443,18 +446,29 @@ $(window).ready(
$("#download-electronic-pdf").on( $("#download-electronic-pdf").on(
"click", "click",
() => { () => {
const tempCanvas = document.createElement("canvas");
const secondPageCanvas = document.getElementById("page-2-canvas"); const secondPageCanvas = document.getElementById("page-2-canvas");
const secondPageContext = secondPageCanvas.getContext("2d");
const canvasHeight = secondPageCanvas.height * 0.8;
secondPageContext.fillStyle = "#ffffff"; tempCanvas.width = secondPageCanvas.width;
tempCanvas.height = secondPageCanvas.height;
secondPageContext.fillRect( const tempContext = tempCanvas.getContext("2d");
0, secondPageCanvas.height - canvasHeight,
secondPageCanvas.width, canvasHeight tempContext.drawImage(
secondPageCanvas,
0, 0
); );
createPdf(); const rectHeight = tempCanvas.height * 0.8;
tempContext.fillStyle = "#ffffff";
tempContext.fillRect(
0, tempCanvas.height - rectHeight,
tempCanvas.width, rectHeight
);
createPdf(tempCanvas);
} }
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment