|
|
|
@ -6,6 +6,7 @@ import lombok.Data; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import com.google.zxing.*; |
|
|
|
@ -348,8 +349,12 @@ public class ZplGenerator { |
|
|
|
boolean showContent = element.getShowContent() != null ? element.getShowContent() : true; |
|
|
|
|
|
|
|
// 将毫米转换为ZPL单位 |
|
|
|
double widthMM = element.getWidth() != null ? element.getWidth().doubleValue() : 2.0; |
|
|
|
int width = Math.max(1, Math.min(10, (int) Math.round(widthMM * 1.5))); |
|
|
|
BigDecimal width = (element.getWidth() != null ? element.getWidth() : new BigDecimal("0.33")) |
|
|
|
.multiply(BigDecimal.valueOf(this.dpi)) |
|
|
|
.divide(BigDecimal.valueOf(25.4), 2, RoundingMode.HALF_UP) |
|
|
|
.setScale(0, RoundingMode.HALF_UP) |
|
|
|
.min(BigDecimal.TEN); |
|
|
|
|
|
|
|
|
|
|
|
// 高度:毫米转换为点数 |
|
|
|
int height = Math.max(1, Math.round((element.getHeight() != null ? element.getHeight() : 15) * this.dpi / 25.4f)); |
|
|
|
@ -386,7 +391,7 @@ public class ZplGenerator { |
|
|
|
String data = element.getData() != null ? element.getData() : ""; |
|
|
|
|
|
|
|
return String.format("^FO%d,%d^BY%d%s,%d%s^FD%s^FS", |
|
|
|
x, y, width, zplCommand, height, additionalParams, data); |
|
|
|
x, y, width.setScale(3, RoundingMode.HALF_UP).intValue(), zplCommand, height, additionalParams, data); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|