From f3bf22f197b45a3a7622ad32697c09c16f0b608b Mon Sep 17 00:00:00 2001 From: s5260822 Date: Sat, 22 Mar 2025 19:25:41 +0100 Subject: [PATCH] fixed member image not being saved on first speech export --- .../project/gruppe_05_1/export/TeXUtil.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/export/TeXUtil.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/export/TeXUtil.java index f337905..5e35068 100644 --- a/src/main/java/org/texttechnologylab/project/gruppe_05_1/export/TeXUtil.java +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/export/TeXUtil.java @@ -25,6 +25,7 @@ public class TeXUtil { private static String END_DOCUMENT = "\\end{document}"; public static String getSpeechToTexComponent(String speechId) { + createTempDir(); Speech speech = getSpeechByKey(speechId); Logger.debug("Speech ID: " + speechId); @@ -54,9 +55,7 @@ public class TeXUtil { public static String convertTexToBase64PDF(String tex) throws IOException, InterruptedException { // Create a temporary directory File tempDir = new File(TEMP_EXPORT_DIR); - if (!tempDir.exists()) { - tempDir.mkdir(); - } + createTempDir(); // Format tex string to UTF-8 tex = new String(tex.getBytes("UTF-8")); @@ -98,6 +97,13 @@ public class TeXUtil { return Base64.getEncoder().encodeToString(pdfBytes); } + public static void createTempDir() { + File tempDir = new File(TEMP_EXPORT_DIR); + if (!tempDir.exists()) { + tempDir.mkdirs(); + } + } + public static void deleteTeXTempDirContents() throws IOException { // Walk through the directory Files.walkFileTree(Path.of(TEMP_EXPORT_DIR), new SimpleFileVisitor() {