fixed member image not being saved on first speech export

This commit is contained in:
s5260822 2025-03-22 19:25:41 +01:00
parent 359d057a9b
commit f3bf22f197

View file

@ -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<Path>() {