修改字体文件路径

This commit is contained in:
xzh
2025-08-08 20:29:44 +08:00
parent 625ce49c7e
commit 21eb5cc0d8
5 changed files with 8 additions and 11 deletions

View File

@@ -245,7 +245,3 @@ justauth:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=gitlab
# 字体文件路径
ttfFile:
path: E:\giftBook\MicrosoftYaHei.ttf

View File

@@ -247,7 +247,3 @@ justauth:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=gitlab
# 字体文件路径
ttfFile:
path: /usr/local/project/giftBook/jar/fonts/MicrosoftYaHei.ttf

View File

@@ -279,3 +279,7 @@ warm-flow:
- 255,205,23
## 已办理
- 157,255,0
# 字体文件名称
ttfFile:
name: simhei.ttf

Binary file not shown.

View File

@@ -64,8 +64,8 @@ public class TGiftBookDetailsServiceImpl implements ITGiftBookDetailsService {
private final ITGiftBookService giftBookService;
@Value("${ttfFile.path}")
private String ttfPath;
@Value("${ttfFile.name}")
private String ttfName;
/**
@@ -243,7 +243,8 @@ public class TGiftBookDetailsServiceImpl implements ITGiftBookDetailsService {
Document document = new Document(pdfDoc, PageSize.A4, false);
// 设置字体
PdfFont font = PdfFontFactory.createFont(ttfPath, PdfEncodings.IDENTITY_H);
ClassPathResource classPathResource = new ClassPathResource("font/" + ttfName);
PdfFont font = PdfFontFactory.createFont(classPathResource.getPath(), PdfEncodings.IDENTITY_H);
document.setFont(font);
pdfDoc.addNewPage();