diff --git a/js/qz-tray.js b/js/qz-tray.js
index ee455d89a..4a31f5dce 100644
--- a/js/qz-tray.js
+++ b/js/qz-tray.js
@@ -853,6 +853,17 @@ var qz = (function() {
}
}
+ if(_qz.tools.versionCompare(2, 2, 4) < 0) {
+ for(var i = 0; i < printData.length; i++) {
+ if (printData[i].constructor === Object) {
+ // dotDensity: "double-legacy|single-legacy" since 2.2.4. Fallback to "double|single"
+ if (printData[i].options && typeof printData[i].options.dotDensity === 'string') {
+ printData[i].options.dotDensity = printData[i].options.dotDensity.toLowerCase().replace("-legacy", "");
+ }
+ }
+ }
+ }
+
if (_qz.tools.isVersion(2, 0)) {
/*
2.0.x conversion
diff --git a/src/qz/printer/action/PrintRaw.java b/src/qz/printer/action/PrintRaw.java
index d5e728768..675a3edaf 100644
--- a/src/qz/printer/action/PrintRaw.java
+++ b/src/qz/printer/action/PrintRaw.java
@@ -285,6 +285,9 @@ private ImageWrapper getWrapper(BufferedImage img, JSONObject opt, PrintOptions.
case "single": density = 32; break;
case "double": density = 33; break;
case "triple": density = 39; break;
+ // negative: legacy mode
+ case "single-legacy": density = -32; break;
+ case "double-legacy": density = -33; break;
}
} else {
density = 32; //default
diff --git a/src/qz/printer/action/raw/ImageWrapper.java b/src/qz/printer/action/raw/ImageWrapper.java
index 3330ae3b4..7ea4514de 100644
--- a/src/qz/printer/action/raw/ImageWrapper.java
+++ b/src/qz/printer/action/raw/ImageWrapper.java
@@ -85,6 +85,8 @@ public class ImageWrapper {
private boolean igpDots = false; // PGL only, toggle IGP/PGL default resolution of 72dpi
private int dotDensity = 32; // Generally 32 = Single (normal) 33 = Double (higher res) for ESC/POS. Irrelevant for all other languages.
+ private boolean legacyMode = false; // Use newlines for ESC/POS spacing; simulates <=2.0.11 behavior
+
/**
* Creates a new
* ImageWrapper
from a
@@ -199,7 +201,8 @@ public int getDotDensity() {
}
public void setDotDensity(int dotDensity) {
- this.dotDensity = dotDensity;
+ this.legacyMode = dotDensity < 0;
+ this.dotDensity = Math.abs(dotDensity);
}
public void setLogoId(String logoId) {
@@ -590,6 +593,11 @@ private void appendEpsonSlices(ByteArrayBuilder builder) {
boolean stripe = dotDensity == 1;
int bytesNeeded = (dotDensity <= 1 || stripe)? 1:3;
+ if(legacyMode) {
+ // Temporarily set line spacing to 24 dots
+ builder.append(new byte[] { 0x1B, 0x33, 24});
+ }
+
int offset = 0; // keep track of chunk offset currently being written
boolean zeroPass = true; // track if this segment get rewritten with 1 pixel offset, always true if not striping
@@ -631,11 +639,21 @@ private void appendEpsonSlices(ByteArrayBuilder builder) {
zeroPass = !zeroPass;
} else {
- //shift down for next segment
- builder.append(new byte[] {0x1B, 0x4A, (byte)segmentHeight});
+ if(legacyMode) {
+ // render a newline to bump the print head down
+ builder.append(new byte[] {10});
+ } else {
+ //shift down for next segment
+ builder.append(new byte[] {0x1B, 0x4A, (byte)segmentHeight});
+ }
offset += 8 * bytesNeeded;
}
}
+
+ if(legacyMode) {
+ // Restore line spacing to 30 dots
+ builder.append(new byte[] { 0x1B, 0x33, 30});
+ }
}
private ArrayList convertToCYMK() throws IOException {