fixed sized and Printer Configuration
parent
b06178cdb4
commit
05c2559af5
|
@ -7,7 +7,7 @@ public enum BarcodeStickerSize {
|
||||||
SIZE_4_X_4( 4 * 72, 4 * 72, 8, 8, 8, 8, 200, 100, 250, 250, 14, 9, 7),
|
SIZE_4_X_4( 4 * 72, 4 * 72, 8, 8, 8, 8, 200, 100, 250, 250, 14, 9, 7),
|
||||||
SIZE_1_75_X_3_5( 3.5f * 72, 1.75f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
SIZE_1_75_X_3_5( 3.5f * 72, 1.75f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
||||||
SIZE_4_X_7( 7f * 72, 4f * 72, 200, 10, 40, 6, 50, 40, 125, 125, 14, 9, 7),
|
SIZE_4_X_7( 7f * 72, 4f * 72, 200, 10, 40, 6, 50, 40, 125, 125, 14, 9, 7),
|
||||||
SIZE_1_X_2( 67.69f, 125.73f ,10 , 10, 20, 6, 60, 60, 125, 125, 4, 9, 7);
|
SIZE_1_X_2( 67.69f, 128.73f ,10 , 10, 20, 6, 60, 60, 125, 125, 4, 9, 7);
|
||||||
|
|
||||||
private final float width;
|
private final float width;
|
||||||
private final float height;
|
private final float height;
|
||||||
|
|
|
@ -287,7 +287,6 @@ public class BarcodeService {
|
||||||
g2d.drawString(text, adjustedX, adjustedY);
|
g2d.drawString(text, adjustedX, adjustedY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getBarcodeImagesForStitchItems(List<? extends InventoryArtifact> artifacts,
|
public void getBarcodeImagesForStitchItems(List<? extends InventoryArtifact> artifacts,
|
||||||
BarcodeStickerSize stickerSize) throws Exception {
|
BarcodeStickerSize stickerSize) throws Exception {
|
||||||
|
|
||||||
|
@ -313,7 +312,7 @@ public class BarcodeService {
|
||||||
float qrY =stickerSize.getMarginLeft()+50 ;
|
float qrY =stickerSize.getMarginLeft()+50 ;
|
||||||
float qrX = stickerSize.getMarginTop();
|
float qrX = stickerSize.getMarginTop();
|
||||||
|
|
||||||
qrCodeImage.setFixedPosition(qrX - 16, qrY-47);
|
qrCodeImage.setFixedPosition(qrX - 16, qrY-40);
|
||||||
document.add(qrCodeImage);
|
document.add(qrCodeImage);
|
||||||
|
|
||||||
float textX = stickerSize.getMarginLeft() + 40;
|
float textX = stickerSize.getMarginLeft() + 40;
|
||||||
|
@ -326,7 +325,7 @@ public class BarcodeService {
|
||||||
|
|
||||||
int maxLength = 14;
|
int maxLength = 14;
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
int start = i * maxLength;
|
int start = i * maxLength;
|
||||||
if (start < combinedText.length()) {
|
if (start < combinedText.length()) {
|
||||||
String part = combinedText.substring(start, Math.min(start + maxLength, combinedText.length())).replaceAll("\\s+", "");
|
String part = combinedText.substring(start, Math.min(start + maxLength, combinedText.length())).replaceAll("\\s+", "");
|
||||||
|
@ -336,7 +335,7 @@ public class BarcodeService {
|
||||||
|
|
||||||
float labelWidth = 67.69f;
|
float labelWidth = 67.69f;
|
||||||
float textBoxWidth = 220;
|
float textBoxWidth = 220;
|
||||||
float textY1 = textY-30;
|
float textY1 = textY-23;
|
||||||
float textXCenter = textX + (labelWidth / 2) - (textBoxWidth / 2)-50;
|
float textXCenter = textX + (labelWidth / 2) - (textBoxWidth / 2)-50;
|
||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
@ -354,13 +353,13 @@ public class BarcodeService {
|
||||||
String id = String.valueOf(artifact.getId());
|
String id = String.valueOf(artifact.getId());
|
||||||
document.add(new Paragraph(id)
|
document.add(new Paragraph(id)
|
||||||
.setFont(font)
|
.setFont(font)
|
||||||
.setFontColor(ColorConstants.BLACK)
|
|
||||||
.setBold()
|
.setBold()
|
||||||
|
.setFontColor(ColorConstants.BLACK)
|
||||||
.setFontSize(stickerSize.getTextSize() + 8)
|
.setFontSize(stickerSize.getTextSize() + 8)
|
||||||
.setTextAlignment(TextAlignment.LEFT)
|
.setTextAlignment(TextAlignment.LEFT)
|
||||||
.setFixedPosition(textX - 25, textY + 8, 140));
|
.setFixedPosition(textX - 25, textY + 13, 100));
|
||||||
|
|
||||||
float dottedLine = textY - 60;
|
float dottedLine = textY - 65;
|
||||||
for(int i= 0 ;i<16;i++){
|
for(int i= 0 ;i<16;i++){
|
||||||
document.add(new Paragraph("|")
|
document.add(new Paragraph("|")
|
||||||
.setFontSize(stickerSize.getTextSize())
|
.setFontSize(stickerSize.getTextSize())
|
||||||
|
@ -368,12 +367,12 @@ public class BarcodeService {
|
||||||
.setBold()
|
.setBold()
|
||||||
.setRotationAngle(-Math.PI / 2)
|
.setRotationAngle(-Math.PI / 2)
|
||||||
.setTextAlignment(TextAlignment.LEFT)
|
.setTextAlignment(TextAlignment.LEFT)
|
||||||
.setFixedPosition(dottedLine,textX+40, 100));
|
.setFixedPosition(dottedLine,textX+45, 100));
|
||||||
|
|
||||||
dottedLine += 7;
|
dottedLine += 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dottedLine2 = textY - 60;
|
float dottedLine2 = textY - 65;
|
||||||
for(int i= 0 ;i<16;i++){
|
for(int i= 0 ;i<16;i++){
|
||||||
document.add(new Paragraph("|")
|
document.add(new Paragraph("|")
|
||||||
.setFontSize(stickerSize.getTextSize())
|
.setFontSize(stickerSize.getTextSize())
|
||||||
|
@ -381,7 +380,7 @@ public class BarcodeService {
|
||||||
.setBold()
|
.setBold()
|
||||||
.setRotationAngle(-Math.PI / 2)
|
.setRotationAngle(-Math.PI / 2)
|
||||||
.setTextAlignment(TextAlignment.LEFT)
|
.setTextAlignment(TextAlignment.LEFT)
|
||||||
.setFixedPosition(dottedLine2,textX+75, 100));
|
.setFixedPosition(dottedLine2,textX+80, 100));
|
||||||
|
|
||||||
dottedLine2 += 7;
|
dottedLine2 += 7;
|
||||||
}
|
}
|
||||||
|
@ -434,38 +433,9 @@ public class BarcodeService {
|
||||||
public void printLabel(BufferedImage bufferedImage) throws Exception {
|
public void printLabel(BufferedImage bufferedImage) throws Exception {
|
||||||
Connection connection = new TcpConnection(ipAddress, port);
|
Connection connection = new TcpConnection(ipAddress, port);
|
||||||
connection.open();
|
connection.open();
|
||||||
|
|
||||||
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
|
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
|
||||||
|
|
||||||
//Reset Printer Settings
|
|
||||||
String resetSettings = "^XA^JUS^XZ";
|
|
||||||
printer.sendCommand(resetSettings);
|
|
||||||
|
|
||||||
//Force Label Length & Disable Auto Feed
|
|
||||||
String lengthFix = "^XA^LL555^PON^XZ"; // **Reduce Length (880) & Disable Auto Feed
|
|
||||||
printer.sendCommand(lengthFix);
|
|
||||||
|
|
||||||
//Apply New Settings
|
|
||||||
String settings = "^XA" +
|
|
||||||
"^MMT" + // Continuous Mode
|
|
||||||
"^MTT" + // Thermal Transfer Mode
|
|
||||||
"^LH0,0" + // Home Position
|
|
||||||
"^PR6" + // Print Speed (~120mm/sec)
|
|
||||||
"^MD25" + // Darkness Level
|
|
||||||
"^PW541" + // Label Width (67.69mm for 203 DPI)
|
|
||||||
"^LL550" + // Reduced Label Length (fix gap)
|
|
||||||
"^PN0" + // No Extra Page Feed
|
|
||||||
"^PON" + // Disable Printer's Auto Feed Mode
|
|
||||||
"^XZ";
|
|
||||||
|
|
||||||
printer.sendCommand(settings);
|
|
||||||
|
|
||||||
// Convert BufferedImage to ZebraImage
|
|
||||||
ZebraImage zebraImage = new ZebraImage(bufferedImage);
|
ZebraImage zebraImage = new ZebraImage(bufferedImage);
|
||||||
|
|
||||||
// Print image
|
|
||||||
printer.printImage(zebraImage, 0, 0, 0, 0, false);
|
printer.printImage(zebraImage, 0, 0, 0, 0, false);
|
||||||
|
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue