diff --git a/src/main/java/cn/teammodel/utils/PdfUtil.java b/src/main/java/cn/teammodel/utils/PdfUtil.java index 6a95419..4e07a00 100644 --- a/src/main/java/cn/teammodel/utils/PdfUtil.java +++ b/src/main/java/cn/teammodel/utils/PdfUtil.java @@ -1,9 +1,11 @@ package cn.teammodel.utils; import com.itextpdf.text.DocumentException; +import com.itextpdf.text.Font; import com.itextpdf.text.Image; import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.AcroFields; +import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfStamper; @@ -16,8 +18,13 @@ import java.util.Map; */ public class PdfUtil { public static void fillPdfForm(PdfStamper stamper, Map data) throws IOException, DocumentException { + BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); + Font boldFont = new Font(baseFont, 16, Font.BOLD); AcroFields fields = stamper.getAcroFields(); for (Map.Entry entry : data.entrySet()) { + + fields.setFieldProperty(entry.getKey(), "textsize", boldFont.getSize(), null); + fields.setFieldProperty(entry.getKey(), "textfont", baseFont, null); // 设置字体为加粗 fields.setField(entry.getKey(), entry.getValue()); } } diff --git a/src/main/resources/templates/pdf_templates/student_report.pdf b/src/main/resources/templates/pdf_templates/student_report.pdf index 5607a20..a2d6ccc 100644 Binary files a/src/main/resources/templates/pdf_templates/student_report.pdf and b/src/main/resources/templates/pdf_templates/student_report.pdf differ