diff --git a/ereuse_devicehub/static/js/print.pdf.js b/ereuse_devicehub/static/js/print.pdf.js index 5316e1ef..0d6fe6d5 100644 --- a/ereuse_devicehub/static/js/print.pdf.js +++ b/ereuse_devicehub/static/js/print.pdf.js @@ -5,8 +5,8 @@ $(document).ready(function() { load_size(); }) -function qr_draw(url) { - var qrcode = new QRCode($("#qrcode")[0], { +function qr_draw(url, id) { + var qrcode = new QRCode($(id)[0], { text: url, width: 128, height: 128, @@ -54,16 +54,26 @@ function printpdf() { var border = 2; var height = parseInt($("#height-tag").val()); var width = parseInt($("#width-tag").val()); - var tag = $("#tag").text(); - var pdf = new jsPDF('l', 'mm', [width, height]); - var imgData = $('#qrcode img').attr("src"); img_side = Math.min(height, width) - 2*border; max_tag_side = (Math.max(height, width)/2) + border; if (max_tag_side < img_side) { max_tag_side = img_side+ 2*border; }; min_tag_side = (Math.min(height, width)/2) + border; - pdf.addImage(imgData, 'PNG', border, border, img_side, img_side); - pdf.text(tag, max_tag_side, min_tag_side); - pdf.save('Tag_'+tag+'.pdf'); + var last_tag_code = ''; + + var pdf = new jsPDF('l', 'mm', [width, height]); + $(".tag").map(function(x, y) { + if (x != 0){ + pdf.addPage(); + console.log(x) + }; + var tag = $(y).text(); + last_tag_code = tag; + var imgData = $('#'+tag+' img').attr("src"); + pdf.addImage(imgData, 'PNG', border, border, img_side, img_side); + pdf.text(tag, max_tag_side, min_tag_side); + }); + + pdf.save('Tag_'+last_tag_code+'.pdf'); } diff --git a/ereuse_devicehub/templates/inventory/print_tags.html b/ereuse_devicehub/templates/inventory/print_tags.html index 421eecde..25a43a9d 100644 --- a/ereuse_devicehub/templates/inventory/print_tags.html +++ b/ereuse_devicehub/templates/inventory/print_tags.html @@ -32,7 +32,9 @@
-
{{ tag.id }}
+
+ {{ tag.id }} +
@@ -95,14 +97,7 @@ {% endblock main %} diff --git a/ereuse_devicehub/templates/inventory/tag_detail.html b/ereuse_devicehub/templates/inventory/tag_detail.html index 691838df..3bc3863b 100644 --- a/ereuse_devicehub/templates/inventory/tag_detail.html +++ b/ereuse_devicehub/templates/inventory/tag_detail.html @@ -47,10 +47,10 @@
-
+
-
{{ tag.id }}
+
{{ tag.id }}
@@ -109,6 +109,6 @@ {% endblock main %}