Commit 2b96fd74 authored by Joshua Priestley's avatar Joshua Priestley
Browse files

Fixes an issue with downloading PDFs

parent 13d53c0c
Pipeline #173208 passed with stages
in 3 minutes and 12 seconds
......@@ -40,7 +40,7 @@ public class MarkdownResultPage implements Page {
}
File getFile() throws IOException {
File markdown = File.createTempFile("result", ".md");
File markdown = new File("result.md");
// Header
FileWriter writer = new FileWriter(markdown);
writer.write("<h1>" + query + "<h1>");
......@@ -53,7 +53,7 @@ public class MarkdownResultPage implements Page {
writer.write("<p>" + answer + "</p>");
}
writer.flush();
writer.close();
return markdown;
}
......
......@@ -12,20 +12,21 @@ public class PDFResultPage extends MarkdownResultPage {
@Override
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("file/markdown");
File markdown = getFile();
String currentDir = System.getProperty("user.dir");
ProcessBuilder pb = new ProcessBuilder("pandoc", "-s", "-o",
currentDir + "/result.pdf", markdown.getAbsolutePath());
resp.setHeader("Content-Disposition", "Inline; filename=" + markdown.getName() + ".pdf");
ProcessBuilder pb = new ProcessBuilder("pandoc", markdown.getAbsolutePath(), "-o", "result.pdf");
Process p = pb.start();
try {
p.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(System.getProperty("user.dir"));
File pdf = new File(currentDir + "/result.pdf");
File pdf = new File("result.pdf");
outputStreams(pdf, resp);
......
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 to comment