修改字体代码
This commit is contained in:
@@ -39,9 +39,11 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@@ -62,6 +64,10 @@ public class TGiftBookDetailsServiceImpl implements ITGiftBookDetailsService {
|
||||
|
||||
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);
|
||||
|
||||
// 设置字体
|
||||
ClassPathResource fontResource = new ClassPathResource("/fonts/MicrosoftYaHei.ttf");
|
||||
PdfFont font = PdfFontFactory.createFont(fontResource.getFile().getAbsolutePath(), PdfEncodings.IDENTITY_H);
|
||||
File file = new File(ttfPath);
|
||||
PdfFont font = PdfFontFactory.createFont(file.getAbsolutePath(), PdfEncodings.IDENTITY_H);
|
||||
document.setFont(font);
|
||||
pdfDoc.addNewPage();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user