info.bliki.pdf
Class PDFGenerator
java.lang.Object
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.
|
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 |
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
PDFGenerator
public PDFGenerator()
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 textcssStyleText - 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