State width&height of label in cm

This commit is contained in:
Philipp Klaus 2017-02-06 15:11:45 +01:00
parent 7ed5c077d9
commit 7935fd0940

View File

@ -95,9 +95,10 @@
<fieldset class="form-group">
<label for="previewImg">Label Preview:</label><br />
<img id="previewImg" style="border: 1px solid #444; max-height: 350px; width: auto; max-width: 100%; margin-bottom: 10px;"/>
<button id="printButton" type="button" class="btn btn-primary btn-block btn-lg" onClick="print()">
<span class="glyphicon glyphicon-print" aria-hidden="true"></span> Print
</button>
<p>Printed size w/o margins: <span id="labelWidth">?</span> cm x <span id="labelHeight">?</span> cm</p>
<button id="printButton" type="button" class="btn btn-primary btn-block btn-lg" onClick="print()">
<span class="glyphicon glyphicon-print" aria-hidden="true"></span> Print
</button>
</fieldset>
<div class="panel panel-default">
<div class="panel-heading">
@ -136,6 +137,11 @@ function preview() {
data: formData(),
success: function( data ) {
$('#previewImg').attr('src', 'data:image/png;base64,' + data);
var img = $('#previewImg')[0];
img.onload = function() {
$('#labelWidth').html( (img.naturalWidth /300*2.54).toFixed(1));
$('#labelHeight').html((img.naturalHeight/300*2.54).toFixed(1));
};
}
});
}