diff --git a/.gitignore b/.gitignore
index 7964536..989668d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -186,4 +186,5 @@ FakesAssemblies/
# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
-ModelManifest.xml
\ No newline at end of file
+ModelManifest.xml
+/.vs/config/applicationhost.config
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a962e8a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,19 @@
+# ZplPrinter
+
+Printer emulator for zpl rendering engine.
+
+Printer emulator for zpl rendering engine. The emulator is based on the [labelary](http://labelary.com/service.html) web service. You can configure print density, label size and the tcp server to listen for any incoming labels.
+
+## References
+* [ZPL Command Support](http://labelary.com/docs.html)
+* [ZPL Web Service](http://labelary.com/service.html)
+
+## Release notes
+
+### Version 1.3
+
+* **Change** Labelary web service call from GET to POST to support large ZPL templates. (Thanks to [pitufo](https://github.com/sbinkert/ZplPrinter/issues/1))
+
+## Download
+
+
diff --git a/ZplPrinter.zip b/ZplPrinter.zip
index af25f89..aa3b027 100644
Binary files a/ZplPrinter.zip and b/ZplPrinter.zip differ
diff --git a/ZplPrinter/ZplPrinter.zip b/ZplPrinter/ZplPrinter.zip
deleted file mode 100644
index af25f89..0000000
Binary files a/ZplPrinter/ZplPrinter.zip and /dev/null differ
diff --git a/ZplPrinter/css/style.css b/ZplPrinter/css/style.css
index 5f6bc66..20f7780 100644
--- a/ZplPrinter/css/style.css
+++ b/ZplPrinter/css/style.css
@@ -8,12 +8,6 @@ body {
padding: 0;
}
-webview {
- height: 100%;
- margin: 0;
- width: 100%;
-}
-
input:required:invalid, input:focus:invalid { border-color: #d9534f; }
::-webkit-scrollbar-thumb { display: none; }
diff --git a/ZplPrinter/js/main.js b/ZplPrinter/js/main.js
index b9217b6..745aa6c 100644
--- a/ZplPrinter/js/main.js
+++ b/ZplPrinter/js/main.js
@@ -16,17 +16,38 @@ $(document).ready(function () {
chrome.sockets.tcp.onReceive.addListener(function (info) {
notify('{0} bytes received from Client: {1} Port: {2}'.format(info.data.byteLength, clientSocketInfo.peerAddress, clientSocketInfo.peerPort), 'print', 'info', 1000);
- var zpl = encodeURIComponent(String.fromCharCode.apply(null, new Uint8Array(info.data)));
+ var zpl = String.fromCharCode.apply(null, new Uint8Array(info.data));
chrome.sockets.tcp.close(info.socketId);
var factor = (configs.unit == '1') ? 1 : (configs.unit == '2') ? 2.54 : 25.4;
var width = parseFloat(configs.width) / factor;
var height = parseFloat(configs.height) / factor;
- var uri = 'http://api.labelary.com/v1/printers/{0}dpmm/labels/{1}x{2}/0/{3}'.format(configs.density, width, height, zpl);
- var size = getSize(width, height);
- $('#label').prepend('
'.format(size.width, size.height, uri));
- var offset = size.height + 20;
- $('#label').css({ "top": '-' + offset + 'px' });
- $('#label').animate({ "top": "0px" }, 1500);
+
+ var xhr = new XMLHttpRequest();
+ xhr.open('POST', 'http://api.labelary.com/v1/printers/{0}dpmm/labels/{1}x{2}/0/'.format(configs.density, width, height), true);
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhr.responseType = 'blob';
+ xhr.onload = function (e) {
+ if (this.status == 200) {
+ var blob = this.response;
+ var size = getSize(width, height)
+ var img = document.createElement('img');
+ img.setAttribute('height', size.height);
+ img.setAttribute('width', size.width);
+ img.setAttribute('class', 'thumbnail');
+ img.onload = function (e) {
+ window.URL.revokeObjectURL(img.src);
+ };
+
+ img.src = window.URL.createObjectURL(blob);
+
+ $('#label').prepend(img);
+ var offset = size.height + 20;
+ $('#label').css({ "top": '-' + offset + 'px' });
+ $('#label').animate({ "top": "0px" }, 1500);
+ }
+ };
+
+ xhr.send(zpl);
});
});
@@ -91,7 +112,7 @@ function startTcpServer() {
// Stop tcp server
function stopTcpServer() {
if (socketId == undefined) return;
- chrome.sockets.tcpServer.close(socketId, function() {
+ chrome.sockets.tcpServer.close(socketId, function () {
notify('Printer stopped on {0} Port: {1}'.format(configs.host, configs.port));
socketId = undefined;
});
@@ -109,7 +130,7 @@ function initEvents() {
}
});
- $('#btn-remove').click(function() {
+ $('#btn-remove').click(function () {
var size = $('.thumbnail').size();
if (size > 0) {
@@ -123,8 +144,8 @@ function initEvents() {
}
});
- $('#btn-close').click(function() {
- chrome.storage.local.set({ isOn: $('#btn-on').hasClass('active') }, function() {
+ $('#btn-close').click(function () {
+ chrome.storage.local.set({ isOn: $('#btn-on').hasClass('active') }, function () {
window.close();
stopTcpServer();
});
@@ -148,7 +169,7 @@ function initEvents() {
});
- $('#settings-window').on('shown.bs.modal', function() {
+ $('#settings-window').on('shown.bs.modal', function () {
if ($('#btn-on').hasClass('active')) {
toggleSwitch('.btn-toggle');
stopTcpServer();
@@ -193,7 +214,7 @@ function initConfigs() {
for (var key in configs) {
if (key == 'density') {
initDropDown('density', configs[key]);
- }else if (key == 'unit') {
+ } else if (key == 'unit') {
initDropDown('unit', configs[key]);
} else if (key == 'isOn' && configs[key]) {
toggleSwitch('.btn-toggle');
diff --git a/ZplPrinter/manifest.json b/ZplPrinter/manifest.json
index dd0c441..c4fc74d 100644
--- a/ZplPrinter/manifest.json
+++ b/ZplPrinter/manifest.json
@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Zpl Printer",
"short_name": "Zpl Printer",
- "version": "1.2",
+ "version": "1.3",
"description": "Printer emulator for zpl rendering engine.",
"author": "Simon Binkert",
"app": {
@@ -12,8 +12,8 @@
}
},
"permissions": [
- "storage",
- "webview"
+ "storage",
+ "http://api.labelary.com/*"
],
"sockets": {
"tcpServer": {