improved PDF export support (better Chapter titles)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / export / pdf / WikiPDFExporter.java
index 0b387dd..e97dd4d 100644 (file)
@@ -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);