Compare commits

..

No commits in common. '75674af97ce73d0f8defc096ddf2eb33246b9f7a' and '04bca1e9a151ad29f3a4caf60bd1f4b0e9a7313f' have entirely different histories.

@ -7,12 +7,9 @@ import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerFontProvider; import com.itextpdf.tool.xml.XMLWorkerFontProvider;
import com.itextpdf.tool.xml.XMLWorkerHelper; import com.itextpdf.tool.xml.XMLWorkerHelper;
import com.ruoyi.common.utils.http.HttpUtils;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -32,7 +29,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class HtmlToPdfConverter { public class HtmlToPdfConverter {
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
public static MultipartFile convertHtmlToPdf(String htmlArticleTitle, String htmlContent) throws IOException { public static MultipartFile convertHtmlToPdf(String htmlArticleTitle, String htmlContent) throws IOException {
@ -45,9 +41,8 @@ public class HtmlToPdfConverter {
String[] split = format.split("-"); String[] split = format.split("-");
Path dirPath = Paths.get(path, "temporary", split[0], split[1], split[2]); Path dirPath = Paths.get(path, "temporary", split[0], split[1], split[2]);
try { try {
// clearTemporaryDirectory(Paths.get(path, "temporary")); // 清理目录
Files.createDirectories(dirPath); Files.createDirectories(dirPath);
clearTemporaryDirectory(Paths.get(path, "temporary")); // 清理目录
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("创建文件夹失败: " + e.getMessage(), e); throw new RuntimeException("创建文件夹失败: " + e.getMessage(), e);
} }
@ -116,14 +111,8 @@ public class HtmlToPdfConverter {
} }
} }
} }
MultipartFile multipartFile = getMultipartFile(pdfFile);
// 在此处删除创建的 PDF 文件
boolean deleted = pdfFile.delete();
if (!deleted) {
log.error("删除文件失败: " + pdfFile.getAbsolutePath());
} return getMultipartFile(pdfFile);
return multipartFile;
} }
private static MultipartFile getMultipartFile(File file) throws IOException { private static MultipartFile getMultipartFile(File file) throws IOException {

Loading…
Cancel
Save