add label code in tag

This commit is contained in:
Cayo Puigdefabregas 2022-01-31 10:12:44 +01:00
parent 999cd3e26c
commit 05b4353cc4
4 changed files with 180 additions and 189 deletions

164
ereuse_devicehub/static/js/jspdf.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ function qr_draw(url) {
height: 128,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
correctLevel : QRCode.CorrectLevel.Q
});
}
@ -51,10 +51,19 @@ function change_size() {
}
function printpdf() {
var border = 2;
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');
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('Tags.pdf');
}

View File

@ -52,7 +52,7 @@
<div id="qrcode"></div>
</div>
<div class="col">
<div style="padding-top: 55px"><b>{{ tag.id }}</b></div>
<div style="padding-top: 55px"><b id="tag">{{ tag.id }}</b></div>
</div>
</div>
</div>
@ -109,7 +109,7 @@
</section>
<script src="{{ url_for('static', filename='js/jquery-3.6.0.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/qrcode.js') }}"></script>
<script src="{{ url_for('static', filename='js/pdf.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jspdf.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/print.pdf.js') }}"></script>
<script type="text/javascript">
qr_draw("{{url_for('inventory.devices.device_details', id=tag.device.devicehub_id, _external=True)}}");