Package org.xhtmlrenderer.simple
Class PDFRenderer
- java.lang.Object
-
- org.xhtmlrenderer.simple.PDFRenderer
-
public class PDFRenderer extends java.lang.Object
PDFRenderer supports headless rendering of XHTML documents, outputting to PDF format. There are two static utility methods, one for rendering aURL
,renderToPDF(String, String)
and one for rendering aFile
,renderToPDF(File, String)
You can use this utility from the command line by passing in the URL or file location as first parameter, and PDF path as second parameter:
java -cp %classpath% org.xhtmlrenderer.simple.PDFRenderer
- Author:
- Pete Brant, Patrick Wright
-
-
Constructor Summary
Constructors Constructor Description PDFRenderer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
Renders a file or URL to a PDF.static void
renderToPDF(java.io.File file, java.lang.String pdf)
Renders the XML file as a PDF file at the target location.static void
renderToPDF(java.io.File file, java.lang.String pdf, java.lang.Character pdfVersion)
Renders the XML file as a PDF file at the target location.static void
renderToPDF(java.lang.String url, java.lang.String pdf)
Renders the XML file at the given URL as a PDF file at the target location.static void
renderToPDF(java.lang.String url, java.lang.String pdf, java.lang.Character pdfVersion)
Renders the XML file at the given URL as a PDF file at the target location.
-
-
-
Method Detail
-
renderToPDF
public static void renderToPDF(java.lang.String url, java.lang.String pdf) throws java.io.IOException, com.lowagie.text.DocumentException
Renders the XML file at the given URL as a PDF file at the target location.- Parameters:
url
- url for the XML file to renderpdf
- path to the PDF file to create- Throws:
java.io.IOException
- if the URL or PDF location is invalidcom.lowagie.text.DocumentException
- if an error occurred while building the Document.
-
renderToPDF
public static void renderToPDF(java.lang.String url, java.lang.String pdf, java.lang.Character pdfVersion) throws java.io.IOException, com.lowagie.text.DocumentException
Renders the XML file at the given URL as a PDF file at the target location.- Parameters:
url
- url for the XML file to renderpdf
- path to the PDF file to createpdfVersion
- version of PDF to output; null uses default version- Throws:
java.io.IOException
- if the URL or PDF location is invalidcom.lowagie.text.DocumentException
- if an error occurred while building the Document.
-
renderToPDF
public static void renderToPDF(java.io.File file, java.lang.String pdf) throws java.io.IOException, com.lowagie.text.DocumentException
Renders the XML file as a PDF file at the target location.- Parameters:
file
- XML file to renderpdf
- path to the PDF file to create- Throws:
java.io.IOException
- if the file or PDF location is invalidcom.lowagie.text.DocumentException
- if an error occurred while building the Document.
-
renderToPDF
public static void renderToPDF(java.io.File file, java.lang.String pdf, java.lang.Character pdfVersion) throws java.io.IOException, com.lowagie.text.DocumentException
Renders the XML file as a PDF file at the target location.- Parameters:
file
- XML file to renderpdf
- path to the PDF file to createpdfVersion
- version of PDF to output; null uses default version- Throws:
java.io.IOException
- if the file or PDF location is invalidcom.lowagie.text.DocumentException
- if an error occurred while building the Document.
-
main
public static void main(java.lang.String[] args) throws java.io.IOException, com.lowagie.text.DocumentException
Renders a file or URL to a PDF. Command line use: first argument is URL or file path, second argument is path to PDF file to generate.- Parameters:
args
- see desc- Throws:
java.io.IOException
- if source could not be read, or if PDF path is invalidcom.lowagie.text.DocumentException
- if an error occurs while building the document
-
-