add multi-printer support
parent
c3b660fa23
commit
af683eed28
|
@ -87,8 +87,14 @@
|
|||
</div>
|
||||
<div data-action="save" id="tool_save" class="menu_item">Save Image... <span class="shortcut">⌘S</span></div>
|
||||
<div data-action="export" id="tool_export" class="menu_item">Export as PNG</div>
|
||||
<div class="separator"></div>
|
||||
<div data-action="print" id="tool_print" class="menu_item">Print on Zebra <span class="shortcut">⌘P</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="menu">
|
||||
<div class="menu_title" style="background: pink; color: black; border-radius: 4px;">Print</div>
|
||||
<div class="menu_list inverted-undo" id="print_menu">
|
||||
<div data-action="print_dymo" id="tool_print" class="menu_item">Print on DYMO (small label)</div>
|
||||
<div data-action="print_zebra" id="tool_print" class="menu_item">Print on Zebra (big label)</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -278,9 +278,9 @@ MD.Editor = function(){
|
|||
c.width = svgCanvas.contentW;
|
||||
c.height = svgCanvas.contentH;
|
||||
canvg(c, data.svg, {renderCallback: function() {
|
||||
if (data.shouldPrint) {
|
||||
if (data.printerName) {
|
||||
c.toBlob((blob) => {
|
||||
fetch('/print?printer=zebra', {
|
||||
fetch(`/print?printer=${data.printerName}`, {
|
||||
method: 'POST',
|
||||
body: blob
|
||||
}).then(response => {
|
||||
|
@ -425,22 +425,32 @@ MD.Editor = function(){
|
|||
this.saveCanvas = saveCanvas;
|
||||
this.loadFromUrl = loadFromUrl;
|
||||
|
||||
this.export = function(shouldPrint = false){
|
||||
this.export = function(printerName = null){
|
||||
if(window.canvg) {
|
||||
svgCanvas.rasterExport(shouldPrint);
|
||||
svgCanvas.rasterExport(printerName);
|
||||
} else {
|
||||
$.getScript('js/lib/rgbcolor.js', function() {
|
||||
$.getScript('js/lib/canvg.js', function() {
|
||||
svgCanvas.rasterExport(shouldPrint);
|
||||
svgCanvas.rasterExport(printerName);
|
||||
});
|
||||
});
|
||||
}}
|
||||
|
||||
|
||||
function print() {
|
||||
editor.menu.flash($('#file_menu'));
|
||||
if (!confirm("Do you want to print?")) return;
|
||||
this.export(true)
|
||||
function print(printerName) {
|
||||
if (!confirm(`Do you want to print on ${printerName}?`)) return;
|
||||
this.export(printerName)
|
||||
}
|
||||
this.print = print
|
||||
|
||||
function print_dymo() {
|
||||
this.print("DYMO")
|
||||
}
|
||||
|
||||
function print_zebra() {
|
||||
this.print("Zebra")
|
||||
}
|
||||
|
||||
this.print_dymo = print_dymo
|
||||
this.print_zebra = print_zebra
|
||||
}
|
|
@ -5364,7 +5364,7 @@ this.save = function() {
|
|||
// Function: rasterExport
|
||||
// Generates a PNG Data URL based on the current image, then calls "exported"
|
||||
// with an object including the string and any issues found
|
||||
this.rasterExport = function(shouldPrint) {
|
||||
this.rasterExport = function(printerName) {
|
||||
// remove the selected outline before serializing
|
||||
clearSelection();
|
||||
|
||||
|
@ -5391,7 +5391,7 @@ this.rasterExport = function(shouldPrint) {
|
|||
});
|
||||
|
||||
var str = this.svgCanvasToString();
|
||||
call("exported", {svg: str, issues: issues, shouldPrint});
|
||||
call("exported", {svg: str, issues: issues, printerName});
|
||||
};
|
||||
|
||||
// Function: getSvgString
|
||||
|
|
Loading…
Reference in New Issue