Modified: 1764120 - Variables View doesn't show global vars in class context
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / export / pdf / WikiPDFExporter.java
index 0b387dd..4ba33df 100644 (file)
@@ -198,7 +198,7 @@ public final class WikiPDFExporter implements IRunnableWithProgress {
 
     List list = visitor.getList();
     Collections.sort(list, new IFileComparator());
-    IFile file;
+    IFile file = null;
 
     FileOutputStream os = null;
     String pdffilename = fPath.toString();
@@ -218,18 +218,24 @@ public final class WikiPDFExporter implements IRunnableWithProgress {
           file = (IFile) list.get(i);
           if (file.exists()) {
             monitor.subTask(WikiEditorPlugin.getResourceString("Export.exportFile") + file.getLocation());
-            System.out.println(file.getLocation().toString());
+            
             StringBuffer htmlBuffer = new StringBuffer();
             htmlBuffer.append("<html><head></head><body>");
 
             boolean noContent = CreatePageAction.createFragmentPage(file, htmlBuffer);
             htmlBuffer.append("</body></html>");
-            System.out.println(htmlBuffer.toString());
 
             if (!noContent) {
-              // TODO add the real title from corresponding *.xml file here:
-              Paragraph title = new Paragraph(file.getName(), FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC,
-                  new Color(0, 0, 255)));
+              System.out.println(file.getLocation().toString());
+              System.out.println(htmlBuffer.toString());
+              String fileName = file.getName();
+              fileName = fileName.replaceAll("_", " ");
+              int dotIndex = fileName.lastIndexOf('.');
+              if (dotIndex>0) {
+                fileName = fileName.substring(0,dotIndex);
+              }
+              Paragraph title = new Paragraph(fileName, FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC,
+                  Color.BLACK));
               Chapter chapter = new Chapter(title, chapterNumber++);
               document.add(chapter);
               appendArticle(document, htmlBuffer);
@@ -237,11 +243,16 @@ public final class WikiPDFExporter implements IRunnableWithProgress {
             monitor.worked(1);
           }
         } catch (Exception e) {
-          addError("PDF export exception", e);
+          String error = "PDF export exception: "+e.getMessage();
+          if (file!=null) {
+            error = file.getLocation().toString()+" - "+e.getMessage();
+          }
+          addError(error, e);
         }
       }
     } catch (Exception e) {
-      addError("PDF export exception", e);
+      String error = "PDF export exception: "+e.getMessage();
+      addError(error, e);
     } finally {
       document.close();
       if (pdfWriter != null) {