|
|
@ -12,8 +12,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@ -63,9 +63,11 @@ public class PdfService {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 加载模板PDF
|
|
|
|
// 加载模板PDF
|
|
|
|
ClassLoader classLoader = getClass().getClassLoader();
|
|
|
|
InputStream templateStream = getClass().getClassLoader().getResourceAsStream("static/file/pdf/smryscb.pdf");
|
|
|
|
File templateFile = new File(classLoader.getResource("static/file/pdf/smryscb.pdf").getFile());
|
|
|
|
if (templateStream == null) {
|
|
|
|
document = PDDocument.load(templateFile);
|
|
|
|
throw new IOException("无法找到模板PDF文件");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
document = PDDocument.load(templateStream);
|
|
|
|
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
|
|
|
|
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
|
|
|
|
|
|
|
|
|
|
|
|
if (acroForm == null) {
|
|
|
|
if (acroForm == null) {
|
|
|
@ -73,9 +75,8 @@ public class PdfService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 加载中文字体
|
|
|
|
// 加载中文字体
|
|
|
|
PDType0Font font = PDType0Font.load(document,
|
|
|
|
InputStream fontStream = getClass().getClassLoader().getResourceAsStream("static/file/pdf/STSONG.TTF");
|
|
|
|
new File(classLoader.getResource("static/file/pdf/STSONG.TTF").getFile()));
|
|
|
|
PDType0Font font = PDType0Font.load(document, fontStream);
|
|
|
|
|
|
|
|
|
|
|
|
// 设置需要更新表单外观
|
|
|
|
// 设置需要更新表单外观
|
|
|
|
acroForm.setNeedAppearances(true);
|
|
|
|
acroForm.setNeedAppearances(true);
|
|
|
|
|
|
|
|
|
|
|
|