public class ImageRenderer
extends java.lang.Object
URL
, #renderToImage(String,String)
and one
for rendering a File
, #renderToImage(java.io.File,String)
You can use this utility from the command line by passing in the URL or file location as first parameter, and output file path as second parameter:
java -cp %classpath% org.xhtmlrenderer.simple.ImageRenderer![]()
If the second parameters is not provided, a PNG-format image will be created in the same directory as the source (if source is a file) or as a temp file in the standard temp directory; the output file name will be printed out in either case.
Image width must always be supplied; height is determined automatically.
PDFRenderer
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_WIDTH |
Constructor and Description |
---|
ImageRenderer() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args)
Renders a file or URL to an image file.
|
static java.awt.image.BufferedImage |
renderImageToOutput(java.lang.String url,
FSImageWriter fsw,
java.lang.String path,
int width)
Renders a document at a given URL and writes it out using the FSImageWriter provided (e.g.
|
static java.awt.image.BufferedImage |
renderToImage(java.io.File inFile,
java.lang.String path,
int width)
Renders the XML file as an image file at the target location.
|
static java.awt.image.BufferedImage |
renderToImage(java.io.File inFile,
java.lang.String path,
int width,
int height)
Renders the XML file as an image file at the target location.
|
static java.awt.image.BufferedImage |
renderToImage(java.lang.String url,
java.lang.String path,
int width)
Renders the XML file at the given URL as an image file at the target location.
|
static java.awt.image.BufferedImage |
renderToImage(java.lang.String url,
java.lang.String path,
int width,
int height)
Renders the XML file at the given URL as an image file at the target location.
|
public static final int DEFAULT_WIDTH
public static java.awt.image.BufferedImage renderToImage(java.lang.String url, java.lang.String path, int width) throws java.io.IOException
url
- url for the XML file to renderpath
- path to the PDF file to createwidth
- Width in pixels to which the document should be constrained.java.io.IOException
- if the input URL, or output path location is invalidpublic static java.awt.image.BufferedImage renderToImage(java.lang.String url, java.lang.String path, int width, int height) throws java.io.IOException
url
- url for the XML file to renderpath
- path to the PDF file to createwidth
- Width in pixels to which the document should be constrained.height
- Height in pixels to which the document should be constrained.java.io.IOException
- if the input URL, or output path location is invalidpublic static java.awt.image.BufferedImage renderToImage(java.io.File inFile, java.lang.String path, int width) throws java.io.IOException
inFile
- XML file to renderpath
- path to the image file to createwidth
- Width in pixels to which the document should be constrained.java.io.IOException
- if the input URL, or output path location is invalidpublic static java.awt.image.BufferedImage renderToImage(java.io.File inFile, java.lang.String path, int width, int height) throws java.io.IOException
inFile
- XML file to renderpath
- path to the image file to createwidth
- Width in pixels to which the document should be constrained.height
- Height in pixels to which the document should be constrained.java.io.IOException
- if the input URL, or output path location is invalidpublic static java.awt.image.BufferedImage renderImageToOutput(java.lang.String url, FSImageWriter fsw, java.lang.String path, int width) throws java.io.IOException
url
- fsw
- path
- width
- java.io.IOException
public static void main(java.lang.String[] args) throws java.io.IOException
args
- see descjava.io.IOException
- if source could not be read, or if image path is invalid