From 999cd3e26cba0226e51c2e6c4640fb7fb8c548a6 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 28 Jan 2022 12:29:49 +0100 Subject: [PATCH] try printpdf --- ereuse_devicehub/static/js/print.pdf.js | 12 +++++++----- .../templates/inventory/tag_details.html | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ereuse_devicehub/static/js/print.pdf.js b/ereuse_devicehub/static/js/print.pdf.js index 46f7b89a..850c2757 100644 --- a/ereuse_devicehub/static/js/print.pdf.js +++ b/ereuse_devicehub/static/js/print.pdf.js @@ -3,11 +3,10 @@ $(document).ready(function() { $("#printerType").on("change", change_size); change_size(); load_size(); - // printpdf(); }) function qr_draw(url) { - var qrcode = new QRCode(document.getElementById("qrcode"), { + var qrcode = new QRCode($("#qrcode")[0], { text: url, width: 128, height: 128, @@ -52,7 +51,10 @@ function change_size() { } function printpdf() { - var height = $("#height-tag").val(); - var width = $("#width-tag").val(); - console.log(height); + var height = parseInt($("#height-tag").val()); + var width = parseInt($("#width-tag").val()); + var doc = new jsPDF('l', 'mm', [width, height]); + //var doc = new jsPDF('l', 'mm', [62, 29]); + doc.addHTML($("#print"), 2, 2); + doc.save('Tags.pdf'); } diff --git a/ereuse_devicehub/templates/inventory/tag_details.html b/ereuse_devicehub/templates/inventory/tag_details.html index e7602562..7c61fdc1 100644 --- a/ereuse_devicehub/templates/inventory/tag_details.html +++ b/ereuse_devicehub/templates/inventory/tag_details.html @@ -112,6 +112,6 @@ {% endblock main %}