Index: /trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/PdfGenerator.java
===================================================================
--- /trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/PdfGenerator.java	(revision 12)
+++ /trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/PdfGenerator.java	(revision 13)
@@ -24,4 +24,5 @@
 
 public class PdfGenerator {
+	
 	public static void generatePdf(ExerciseSheet exercisesheet, String path,
 			boolean copyFile, boolean makeExerciseInsteadOfSolution) {
@@ -71,8 +72,10 @@
 			String lecturersString = "";
 			boolean firstRun = true;
+			
+			// build lecturer placeholder string
 			for (Lecturer lecturer : lecturers) {
 				if (!firstRun)
 					lecturersString += ", ";
-				lecturersString += lecturer.toString();
+				lecturersString += lecturer.toString().trim();
 				firstRun = false;
 			}
@@ -80,4 +83,5 @@
 				lecturersString = "!NO LECTURERS FOUND!";
 
+			// concatenate exercises or solution to one content
 			ArrayList<Exercise> exercises = exercisesheet.getExercises();
 			String exercisesString = "";
@@ -94,4 +98,6 @@
 			}
 
+			// declare execercise to be an examination or exercise
+			// TODO: dirty
 			String examorunit = "";
 
@@ -102,4 +108,5 @@
 			}
 
+			// replace placeholders in generated text file
 			String templatePath = ExerciseSVN.SVNpath;
 			templatePath = templatePath.replace('\\','/');
@@ -123,4 +130,5 @@
 					+ Matcher.quoteReplacement(deliveryDate) + "$2");
 
+			// write temporary .tex file to temp directory
 			FileOutputStream ofstream = new FileOutputStream(latexFile);
 			BufferedWriter odstream = new BufferedWriter(
@@ -128,4 +136,7 @@
 			odstream.write(template);
 			odstream.close();
+
+			// call pdflatex to generate to the pdf file
+			// TODO: check if linux conditional is necessary
 			ProcessBuilder pb;
 			if (Util.isLinux())
@@ -134,8 +145,5 @@
 				pb = new ProcessBuilder(cmd);
 
-			// pb.directory(latexFile.getParentFile());
-
 			Process p = pb.start();
-
 			Scanner s = new Scanner(p.getInputStream()).useDelimiter("\n");
 			while (s.hasNext()) {
@@ -143,25 +151,28 @@
 			}
 
-			// try {
-			// p.waitFor();
-			// } catch (InterruptedException e) {
-			// // TODO Auto-generated catch block
-			// e.printStackTrace();
-			// }
+			// copy resultfile to "tempPDFfileforPreview.pdf" in temp directory
+			File f = new File(path);
+			File sourceFile = new File(latexFile.getAbsolutePath().replaceAll(
+					".tex$", ".pdf"));
+			FileUtils.copyFile(sourceFile, f);
 
-			File f = new File(path);
-
-			FileUtils.copyFile(new File(latexFile.getAbsolutePath().replaceAll(
-					".tex$", ".pdf")), f);
-
+			// copy file to svn working copy if flag is set
 			if (copyFile)
 				FileUtils.copyFile(f, new File(ExerciseSVN.SVNpath
 						+ "exercisesheets/" + f.getName()));
 
+			// remove temporary files
+			File tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".aux"));
+			tmpFile.delete();
+			tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".log"));
+			tmpFile.delete();
+			tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".out"));
+			tmpFile.delete();
+			tmpFile = new File(latexFile.getAbsolutePath().replace(".tex", ".pdf"));
+			tmpFile.delete();
+			latexFile.delete();
+			
 		} catch (IOException e) {
 			e.printStackTrace();
-			// } catch (InterruptedException e) {
-			// // TODO Auto-generated catch block
-			// e.printStackTrace();
 		}
 	}
