diff --git a/cara/apps/calculator/static/css/report.css b/cara/apps/calculator/static/css/report.css index d4bed711..f35a6940 100644 --- a/cara/apps/calculator/static/css/report.css +++ b/cara/apps/calculator/static/css/report.css @@ -99,15 +99,12 @@ p.notes { } @media (width: 1200px) { - /* CSS styling for break avoid. */ + /* CSS styling to avoid page breaks. */ .break-avoid { page-break-inside: avoid; } - .first_page { - height: 380pt; - } .second_page { - height: 540pt; + height: 530pt; } .third_page { height: 90pt; diff --git a/cara/apps/calculator/static/js/pdf.js b/cara/apps/calculator/static/js/pdf.js index fbce502e..7432b62b 100644 --- a/cara/apps/calculator/static/js/pdf.js +++ b/cara/apps/calculator/static/js/pdf.js @@ -1,8 +1,12 @@ function execute_me(qr_link) { const pdf_version = this.document.getElementById("body"); - console.log(pdf_version); - console.log(window); + // Set height of first page break according to the results div + const header_height = this.document.getElementById("report-header-div").offsetHeight; + const results_height = this.document.getElementById("results-div").offsetHeight; + this.document.getElementById("break-first-page").style.height = (1420 - header_height - results_height) + 'pt'; + + // PDF styling var opt = { filename: 'myfile.pdf', image: { type: 'jpeg', quality: 0.98 }, @@ -18,7 +22,7 @@ function execute_me(qr_link) { html2pdf().set(opt).from(pdf_version).toPdf().get('pdf').then(function(pdf) { var totalPages = pdf.internal.getNumberOfPages(); pdf.setPage(1); - pdf.link(530, 25, 60, 60, { url: qr_link }); + pdf.link(530, 25, 60, 60, { url: qr_link }); //Hyperlink to reproduce results for (i = 1; i <= totalPages; i++) { pdf.setPage(i); diff --git a/cara/apps/calculator/templates/base/calculator.report.html.j2 b/cara/apps/calculator/templates/base/calculator.report.html.j2 index d7ea8b5b..d4342934 100644 --- a/cara/apps/calculator/templates/base/calculator.report.html.j2 +++ b/cara/apps/calculator/templates/base/calculator.report.html.j2 @@ -16,7 +16,7 @@ {% block report_header %} -
+

CARA - CALCULATOR REPORT

@@ -45,7 +45,7 @@
{% block report_results %} -
+
Results
-
-
+
+
Alternative scenarios