修改字体代码
This commit is contained in:
@@ -245,3 +245,7 @@ justauth:
|
|||||||
client-id: 10**********6
|
client-id: 10**********6
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
client-secret: 1f7d08**********5b7**********29e
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
||||||
|
|
||||||
|
# 字体文件路径
|
||||||
|
ttfFile:
|
||||||
|
path: E:\giftBook\MicrosoftYaHei.ttf
|
||||||
|
|||||||
@@ -247,3 +247,7 @@ justauth:
|
|||||||
client-id: 10**********6
|
client-id: 10**********6
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
client-secret: 1f7d08**********5b7**********29e
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
||||||
|
|
||||||
|
# 字体文件路径
|
||||||
|
ttfFile:
|
||||||
|
path: /usr/local/project/giftBook/jar/fonts/MicrosoftYaHei.ttf
|
||||||
|
|||||||
Binary file not shown.
@@ -39,9 +39,11 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import jakarta.validation.ConstraintViolation;
|
import jakarta.validation.ConstraintViolation;
|
||||||
import jakarta.validation.ConstraintViolationException;
|
import jakarta.validation.ConstraintViolationException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
@@ -62,6 +64,10 @@ public class TGiftBookDetailsServiceImpl implements ITGiftBookDetailsService {
|
|||||||
|
|
||||||
private final ITGiftBookService giftBookService;
|
private final ITGiftBookService giftBookService;
|
||||||
|
|
||||||
|
@Value("ttfFile.path")
|
||||||
|
private String ttfPath;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询礼薄详情
|
* 查询礼薄详情
|
||||||
*
|
*
|
||||||
@@ -237,8 +243,8 @@ public class TGiftBookDetailsServiceImpl implements ITGiftBookDetailsService {
|
|||||||
Document document = new Document(pdfDoc, PageSize.A4, false);
|
Document document = new Document(pdfDoc, PageSize.A4, false);
|
||||||
|
|
||||||
// 设置字体
|
// 设置字体
|
||||||
ClassPathResource fontResource = new ClassPathResource("/fonts/MicrosoftYaHei.ttf");
|
File file = new File(ttfPath);
|
||||||
PdfFont font = PdfFontFactory.createFont(fontResource.getFile().getAbsolutePath(), PdfEncodings.IDENTITY_H);
|
PdfFont font = PdfFontFactory.createFont(file.getAbsolutePath(), PdfEncodings.IDENTITY_H);
|
||||||
document.setFont(font);
|
document.setFont(font);
|
||||||
pdfDoc.addNewPage();
|
pdfDoc.addNewPage();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user