Package com.xpn.xwiki.pdf.impl
Class PdfExportImpl
- java.lang.Object
-
- com.xpn.xwiki.pdf.impl.PdfExportImpl
-
- All Implemented Interfaces:
PdfExport
public class PdfExportImpl extends Object implements PdfExport
Default implementation for the PDF Export process, which uses XSLT transformations and Apache FOP to convert a Document into PDF, passing through HTML, valid XHTML, styled XHTML, and XSL-FO.- Version:
- $Id: 9f471406bc61fc62d427e8a7e1e3371b70578a56 $
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.xpn.xwiki.pdf.api.PdfExport
PdfExport.ExportType
-
-
Constructor Summary
Constructors Constructor Description PdfExportImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
applyXSLT(String xml, InputStream xslt)
Applies an XSLT transformation to an XML document.void
export(XWikiDocument doc, OutputStream out, PdfExport.ExportType type, XWikiContext context)
Export a wiki Document into PDF or RTF.void
exportHtml(String html, OutputStream out, PdfExport.ExportType type, XWikiContext context)
Convert an HTML document to PDF.void
exportToPDF(XWikiDocument doc, OutputStream out, XWikiContext context)
Export a wiki Document into PDF.protected void
exportXHTML(String xhtml, OutputStream out, PdfExport.ExportType type, XWikiContext context)
Convert a valid XHTML document into PDF.protected InputStream
getXslt(String propertyName, String fallbackFile, XWikiContext context)
Get an XSLT file.
-
-
-
Method Detail
-
exportToPDF
public void exportToPDF(XWikiDocument doc, OutputStream out, XWikiContext context) throws XWikiException
Description copied from interface:PdfExport
Export a wiki Document into PDF. SeePdfExport.export(XWikiDocument, OutputStream, ExportType, XWikiContext)
for more details about the conversion process.- Specified by:
exportToPDF
in interfacePdfExport
- Parameters:
doc
- the document to exportout
- where to write the resulting documentcontext
- the current request context- Throws:
XWikiException
- if the conversion fails for any reason- See Also:
PdfExport.export(XWikiDocument, OutputStream, ExportType, XWikiContext)
-
export
public void export(XWikiDocument doc, OutputStream out, PdfExport.ExportType type, XWikiContext context) throws XWikiException
Description copied from interface:PdfExport
Export a wiki Document into PDF or RTF. The content of the document is rendered into HTML using thepdf.vm
template, the resulting HTML is cleaned up into valid XHTML, and custom CSS is applied to it. The XHTML document is transformed into an XSL-FO document, which is finally processed using Apache FOP.- Specified by:
export
in interfacePdfExport
- Parameters:
doc
- the document to exportout
- where to write the resulting documenttype
- the type of the output: PDF or RTFcontext
- the current request context- Throws:
XWikiException
- if the conversion fails for any reason
-
exportHtml
public void exportHtml(String html, OutputStream out, PdfExport.ExportType type, XWikiContext context) throws XWikiException
Description copied from interface:PdfExport
Convert an HTML document to PDF. The HTML is cleaned up, and CSS style is applied to it.- Specified by:
exportHtml
in interfacePdfExport
- Parameters:
html
- the source document to transformout
- where to write the resulting documenttype
- the type of the output: PDF or RTFcontext
- the current request context- Throws:
XWikiException
- if the conversion fails for any reason
-
exportXHTML
protected void exportXHTML(String xhtml, OutputStream out, PdfExport.ExportType type, XWikiContext context) throws XWikiException
Convert a valid XHTML document into PDF. No further processing of the XHTML occurs.Note: This method is protected just allow other exporters to hook their code and use the PDF export infrastructure. This is just a temporary solution. The PDF export code needs to be redesigned because it has parts than can be reused for other export formats.
- Parameters:
xhtml
- the source document to transformout
- where to write the resulting documenttype
- the type of the output: PDF or RTFcontext
- the current request context- Throws:
XWikiException
- if the conversion fails for any reason
-
applyXSLT
protected String applyXSLT(String xml, InputStream xslt) throws XWikiException
Applies an XSLT transformation to an XML document.- Parameters:
xml
- the XML document to convertxslt
- the XSLT to apply- Returns:
- the converted document
- Throws:
XWikiException
- if the transformation fails for any reason
-
getXslt
protected InputStream getXslt(String propertyName, String fallbackFile, XWikiContext context)
Get an XSLT file.- Parameters:
propertyName
- the name of the xproperty from which to read the XSLT file. SeegetPDFTemplateProperty(String, XWikiContext)
for details on how this property is resolved. If the property doesn't point to any XSLT file then the fallback file parameter is used insteadfallbackFile
- the name of a resource file to use when no XSLT content was found using the passedpropertyName
context
- the current request context- Returns:
- the content of the XSLT as a byte stream
-
-