Commit ae935183 by zwb

修改简历生成html文件添加字体参数

parent f2f1daef
......@@ -756,7 +756,7 @@ public class NewEditionResumeServiceImpl implements NewEditionResumeService {
String htmlName = resumeId + ".html";
FileProcessor.processFileWithSize(properties.getPath() + "template/" + templateName, properties.getPath() + "output/" + htmlName, "<%- data %>", jsonString,"<%- FontSize %>", fontSize,"<%- LineHeight %>", lineHeight);
FileProcessor.processFileWithSize(properties.getPath() + "template/" + templateName, properties.getPath() + "output/" + htmlName, jsonString, fontSize, lineHeight);
redisTemplate.opsForValue().set(CacheConstants.CREATE_RESUME_HTML_DATA.formatted(resumeId), jsonString);
redisTemplate.opsForValue().set(CacheConstants.CREATE_RESUME_HTML.formatted(resumeId), properties.getHtmlDown() + htmlName);
......
......@@ -7,6 +7,9 @@ import java.nio.charset.StandardCharsets;
public class FileProcessor {
private static String OLD_DATA = "<%- data %>";
private static String OLD_DONTSIZE = "<%- FontSize %>";
private static String OLD_LINEHEIGHT = "<%- LineHeight %>";
/**
* 读取服务器路径上的文件,替换字符串并生成HTML文件
* @param sourceFilePath 原文件路径
......@@ -34,7 +37,7 @@ public class FileProcessor {
e.printStackTrace();
}
}
public static void processFileWithSize(String sourceFilePath, String targetFilePath, String oldData, String newData, String oldFontSize, String newFontSize, String oldLineHeight, String newLineHeight) {
public static void processFileWithSize(String sourceFilePath, String targetFilePath, String newData, String newFontSize, String newLineHeight) {
File sourceFile = new File(sourceFilePath);
File targetFile = new File(targetFilePath);
......@@ -46,15 +49,9 @@ public class FileProcessor {
while ((line = reader.readLine()) != null) {
// 替换字符串
String processedLine = line;
if (!oldData.isEmpty() && !newData.isEmpty()) {
processedLine = processedLine.replace(oldData, newData);
}
if (!oldFontSize.isEmpty() && !newFontSize.isEmpty()) {
processedLine = processedLine.replace(oldFontSize, newFontSize);
}
if (!oldLineHeight.isEmpty() && !newLineHeight.isEmpty()) {
processedLine = processedLine.replace(oldLineHeight, newLineHeight);
}
processedLine = processedLine.replace(OLD_DATA, newData);
processedLine = processedLine.replace(OLD_DONTSIZE, newFontSize);
processedLine = processedLine.replace(OLD_LINEHEIGHT, newLineHeight);
writer.write(processedLine);
writer.newLine(); // 写入换行符
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment