info.bliki.pdf
Class PDFGenerator

java.lang.Object
  extended by info.bliki.pdf.PDFGenerator

public class PDFGenerator
extends java.lang.Object

Create a PDF document from a wikipedia syntax string Uses the Flying Saucer Project and iText Open Source libraries for creating and manipulating PDF.


Field Summary
static java.lang.String FOOTER
           
static java.lang.String HEADER_TEMPLATE
           
 
Constructor Summary
PDFGenerator()
           
 
Method Summary
 void create(java.lang.String outputFileName, java.lang.String xhtmlText, java.lang.String headerTemplate, java.lang.String footer, java.lang.String titleText, java.lang.String cssStyleText)
          Create a PDF document from a given rendered XHTML text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER_TEMPLATE

public static final java.lang.String HEADER_TEMPLATE
See Also:
Constant Field Values

FOOTER

public static final java.lang.String FOOTER
See Also:
Constant Field Values
Constructor Detail

PDFGenerator

public PDFGenerator()
Method Detail

create

public void create(java.lang.String outputFileName,
                   java.lang.String xhtmlText,
                   java.lang.String headerTemplate,
                   java.lang.String footer,
                   java.lang.String titleText,
                   java.lang.String cssStyleText)
            throws java.io.IOException,
                   com.lowagie.text.DocumentException,
                   javax.xml.parsers.ParserConfigurationException,
                   javax.xml.parsers.FactoryConfigurationError,
                   org.xml.sax.SAXException
Create a PDF document from a given rendered XHTML text. Example:
 public void testPDF() {
        WikiModel wikiModel = new WikiModel("file:///c:/temp/${image}", "file:///c:/temp/${title}");
        String renderedXHTML = wikiModel.render("a wiki [[Test]] string");
        PDFGenerator gen = new PDFGenerator();
        try {
                gen.create("c:/temp/test.pdf", renderedXHTML, PDFGenerator.HEADER_TEMPLATE, PDFGenerator.FOOTER, "Big Test", "");
        } catch (Exception e) {
                e.printStackTrace();
        }
 }
 

Parameters:
outputFileName - the PDF output file name (example: c:/temp/test.pdf)
xhtmlText -
headerTemplate - where titleText and cssStyleText could be inserted (see PDFGenerator.HEADER_TEMPLATE as an example / use MessageFormat#format() format)
titleText - the title of the rendered wiki text
cssStyleText - CSS style text for manipulating the PDF rendering
Throws:
java.io.IOException
com.lowagie.text.DocumentException
java.io.IOException
com.lowagie.text.DocumentException
javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.FactoryConfigurationError
org.xml.sax.SAXException