|
@@ -41,16 +41,16 @@ public class FlowCardRenderer {
|
|
|
private static final float PDF_PAGE_H_PT = 595.25f;
|
|
private static final float PDF_PAGE_H_PT = 595.25f;
|
|
|
|
|
|
|
|
// 三个动态元素在 PDF 坐标系里的位置(pt,左上原点)
|
|
// 三个动态元素在 PDF 坐标系里的位置(pt,左上原点)
|
|
|
- private static final float QR_X = 194.1f;
|
|
|
|
|
- private static final float QR_Y = 63.3f;
|
|
|
|
|
|
|
+ private static final float QR_X = 199.3f;
|
|
|
|
|
+ private static final float QR_Y = 60.2f;
|
|
|
private static final float QR_W = 35.7f;
|
|
private static final float QR_W = 35.7f;
|
|
|
private static final float QR_H = 34.6f;
|
|
private static final float QR_H = 34.6f;
|
|
|
|
|
|
|
|
// 文字 baseline(Graphics2D.drawString 的 y 参数)
|
|
// 文字 baseline(Graphics2D.drawString 的 y 参数)
|
|
|
private static final float PROD_TEXT_X = 120.0f;
|
|
private static final float PROD_TEXT_X = 120.0f;
|
|
|
- private static final float PROD_TEXT_Y = 81.1f;
|
|
|
|
|
|
|
+ private static final float PROD_TEXT_Y = 80.7f;
|
|
|
private static final float STEEL_TEXT_X = 286.7f;
|
|
private static final float STEEL_TEXT_X = 286.7f;
|
|
|
- private static final float STEEL_TEXT_Y = 76.3f;
|
|
|
|
|
|
|
+ private static final float STEEL_TEXT_Y = 75.6f;
|
|
|
private static final float SN_TEXT_X = 286.7f;
|
|
private static final float SN_TEXT_X = 286.7f;
|
|
|
private static final float SN_TEXT_Y = 86.3f;
|
|
private static final float SN_TEXT_Y = 86.3f;
|
|
|
|
|
|
|
@@ -310,17 +310,22 @@ public class FlowCardRenderer {
|
|
|
BufferedImage bgImage = getTemplateImage();
|
|
BufferedImage bgImage = getTemplateImage();
|
|
|
BufferedImage qr = generateQrCode(data.getSn(), 600);
|
|
BufferedImage qr = generateQrCode(data.getSn(), 600);
|
|
|
|
|
|
|
|
- // 2. 创建完整的打印图像(使用打印逻辑)
|
|
|
|
|
- int imgW = bgImage.getWidth();
|
|
|
|
|
- int imgH = bgImage.getHeight();
|
|
|
|
|
|
|
+ // 2. 创建打印尺寸的图像(PDF pt 坐标系)
|
|
|
|
|
+ int imgW = (int) Math.ceil(PDF_PAGE_W_PT);
|
|
|
|
|
+ int imgH = (int) Math.ceil(PDF_PAGE_H_PT);
|
|
|
BufferedImage finalImage = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_RGB);
|
|
BufferedImage finalImage = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_RGB);
|
|
|
Graphics2D g2 = finalImage.createGraphics();
|
|
Graphics2D g2 = finalImage.createGraphics();
|
|
|
|
|
|
|
|
- // 绘制底图
|
|
|
|
|
- g2.drawImage(bgImage, 0, 0, null);
|
|
|
|
|
|
|
+ // 设置高质量渲染
|
|
|
|
|
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
|
|
+ g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
|
|
|
|
+ g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
|
|
|
|
|
|
|
- // 绘制动态内容(二维码和文字)
|
|
|
|
|
- drawDynamic(g2, qr, data);
|
|
|
|
|
|
|
+ // 底图从 300dpi 缩小到 PDF pt 坐标(和打印时一致)
|
|
|
|
|
+ g2.drawImage(bgImage, 0, 0, imgW, imgH, null);
|
|
|
|
|
+
|
|
|
|
|
+ // 使用打印方法绘制动态内容(完全一致的坐标和字体)
|
|
|
|
|
+ drawDynamicForPrint(g2, qr, data);
|
|
|
g2.dispose();
|
|
g2.dispose();
|
|
|
|
|
|
|
|
// 3. 创建 PDF 并写入图片
|
|
// 3. 创建 PDF 并写入图片
|