Skip to content

Commit

Permalink
Add SBPL image support (qzind#851)
Browse files Browse the repository at this point in the history
Add SBPL image support and examples
  • Loading branch information
Brett Berenz authored Aug 18, 2021
1 parent fb8755d commit b9da58b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
14 changes: 14 additions & 0 deletions assets/sbpl_sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AV0050H0110P02L1010X20,SATO
V0150H0130P03L0102X2,25/05/21-17:41
V0220H0030P01L0505X3,SBPL
V0360H0050FW02H0030
V0360H0120FW02H0030
V0360H0190FW02H0030
V0360H0260FW02H0030
V0360H0330FW02H0030
V0360H0400FW02H0030
V0400H0020P02L0303X20,123
V0390H0110P02L1010X20,TEST
V0430H0020P02L0303X20,ABC
V0470H0020B102060*123456789012*
Q01Z
20 changes: 20 additions & 0 deletions sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ <h3>Raw Printing</h3>
<input type="radio" name="pLanguage" id="pLangEVOLIS" value="EVOLIS" />
Evolis
</label>
<label>
<input type="radio" name="pLanguage" id="pLangSBPL" value="SBPL" />
SBPL
</label>
</div>
</div>
<div class="form-group">
Expand All @@ -189,6 +193,7 @@ <h3>Raw Printing</h3>
<button type="button" class="btn btn-default" onclick="printFile('zpl_sample.txt');">zpl_sample.txt</button>
<button type="button" class="btn btn-default" onclick="printFile('fgl_sample.txt');">fgl_sample.txt</button>
<button type="button" class="btn btn-default" onclick="printFile('epl_sample.txt');">epl_sample.txt</button>
<button type="button" class="btn btn-default" onclick="printFile('sbpl_sample.txt');">sbpl_sample.txt</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -1566,6 +1571,13 @@ <h4 class="panel-title">Options</h4>
'\x1BSe\x0D' // End of sequence
];
break;
case 'SBPL':
printData = [
'\x1BA',
'\x1BH0100\x1BV0100\x1BXSPRINTED WITH QZ ' + qzVersion,
'\x1BQ1\x1BZ'
];
break;
default:
displayError("Sample page cannot print commands using this printer language");
return;
Expand Down Expand Up @@ -1792,6 +1804,14 @@ <h4 class="panel-title">Options</h4>
{ type: 'raw', format: 'image', data: 'assets/img/image_sample_bw.png', options: opts },
];
break;
case 'SBPL':
printData = [
'\x1BA',
'\x1BH0100\x1BV0100',
{ type: 'raw', format: 'image', data: 'assets/img/image_sample_bw.png', options: opts },
'\x1BQ1\x1BZ'
];
break;
default:
displayError("Cannot print images using this printer language");
return;
Expand Down
9 changes: 9 additions & 0 deletions src/qz/printer/ImageWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@ public byte[] getImageCommand(JSONObject opt) throws InvalidRawImageException, U
throw new InvalidRawImageException(ioe.getMessage(), ioe);
}

break;
case SBPL:
String sbplHexAsString = ByteUtilities.getHexString(getImageAsIntArray());
StringBuilder sbpl = new StringBuilder("GH")
.append(String.format("%03d", getWidth() / 8))
.append(String.format("%03d", getHeight() / 8))
.append(sbplHexAsString);

getByteBuffer().append(new byte[] {27}).append(sbpl, charset);
break;
default:
throw new InvalidRawImageException(languageType + " image conversion is not yet supported.");
Expand Down
1 change: 1 addition & 0 deletions src/qz/printer/LanguageType.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum LanguageType {
CPCL(false, true, 203),
ESCP(false, false, 180, "ESCP", "ESCP2", "ESCPOS", "ESC", "ESC/P", "ESC/P2", "ESCP/P2", "ESC/POS", "ESC\\P", "EPSON"),
EVOLIS(false, false, 300),
SBPL(false, true, 203, "SATO"),
UNKNOWN(false, false, 72);


Expand Down

0 comments on commit b9da58b

Please sign in to comment.