新增检验报告打印接口

This commit is contained in:
2025-06-25 10:01:50 +08:00
parent 25597dcfc9
commit 97aa3efef6
7 changed files with 302 additions and 18 deletions

View File

@@ -0,0 +1,31 @@
package com.dpkj.modules.print.utils;
import com.itextpdf.text.pdf.BaseFont;
import java.io.InputStream;
/**
* @author 余文财
* @description 字体加载
* @date 2025.6.24
*/
public class FontLoader {
public static BaseFont loadFont(String resourcePath) {
try (InputStream fontStream = FontLoader.class.getResourceAsStream(resourcePath)) {
if (fontStream == null) {
throw new IllegalArgumentException("字体文件未找到: " + resourcePath);
}
// 创建支持中文的 BaseFont
return BaseFont.createFont(
resourcePath,
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED,
false,
fontStream.readAllBytes(),
null
);
} catch (Exception e) {
throw new RuntimeException("字体加载失败: " + resourcePath, e);
}
}
}