Changeset 13
- Timestamp:
- 10/19/09 15:27:52 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/PdfGenerator.java
r7 r13 24 24 25 25 public class PdfGenerator { 26 26 27 public static void generatePdf(ExerciseSheet exercisesheet, String path, 27 28 boolean copyFile, boolean makeExerciseInsteadOfSolution) { … … 71 72 String lecturersString = ""; 72 73 boolean firstRun = true; 74 75 // build lecturer placeholder string 73 76 for (Lecturer lecturer : lecturers) { 74 77 if (!firstRun) 75 78 lecturersString += ", "; 76 lecturersString += lecturer.toString() ;79 lecturersString += lecturer.toString().trim(); 77 80 firstRun = false; 78 81 } … … 80 83 lecturersString = "!NO LECTURERS FOUND!"; 81 84 85 // concatenate exercises or solution to one content 82 86 ArrayList<Exercise> exercises = exercisesheet.getExercises(); 83 87 String exercisesString = ""; … … 94 98 } 95 99 100 // declare execercise to be an examination or exercise 101 // TODO: dirty 96 102 String examorunit = ""; 97 103 … … 102 108 } 103 109 110 // replace placeholders in generated text file 104 111 String templatePath = ExerciseSVN.SVNpath; 105 112 templatePath = templatePath.replace('\\','/'); … … 123 130 + Matcher.quoteReplacement(deliveryDate) + "$2"); 124 131 132 // write temporary .tex file to temp directory 125 133 FileOutputStream ofstream = new FileOutputStream(latexFile); 126 134 BufferedWriter odstream = new BufferedWriter( … … 128 136 odstream.write(template); 129 137 odstream.close(); 138 139 // call pdflatex to generate to the pdf file 140 // TODO: check if linux conditional is necessary 130 141 ProcessBuilder pb; 131 142 if (Util.isLinux()) … … 134 145 pb = new ProcessBuilder(cmd); 135 146 136 // pb.directory(latexFile.getParentFile());137 138 147 Process p = pb.start(); 139 140 148 Scanner s = new Scanner(p.getInputStream()).useDelimiter("\n"); 141 149 while (s.hasNext()) { … … 143 151 } 144 152 145 // try { 146 // p.waitFor(); 147 // } catch (InterruptedException e) { 148 // // TODO Auto-generated catch block 149 // e.printStackTrace(); 150 // } 153 // copy resultfile to "tempPDFfileforPreview.pdf" in temp directory 154 File f = new File(path); 155 File sourceFile = new File(latexFile.getAbsolutePath().replaceAll( 156 ".tex$", ".pdf")); 157 FileUtils.copyFile(sourceFile, f); 151 158 152 File f = new File(path); 153 154 FileUtils.copyFile(new File(latexFile.getAbsolutePath().replaceAll( 155 ".tex$", ".pdf")), f); 156 159 // copy file to svn working copy if flag is set 157 160 if (copyFile) 158 161 FileUtils.copyFile(f, new File(ExerciseSVN.SVNpath 159 162 + "exercisesheets/" + f.getName())); 160 163 164 // remove temporary files 165 File tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".aux")); 166 tmpFile.delete(); 167 tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".log")); 168 tmpFile.delete(); 169 tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".out")); 170 tmpFile.delete(); 171 tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".pdf")); 172 tmpFile.delete(); 173 latexFile.delete(); 174 161 175 } catch (IOException e) { 162 176 e.printStackTrace(); 163 // } catch (InterruptedException e) {164 // // TODO Auto-generated catch block165 // e.printStackTrace();166 177 } 167 178 }
Note: See TracChangeset
for help on using the changeset viewer.