public class ImageRenderer extends 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.docx4j.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| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_WIDTH |
| 构造器和说明 |
|---|
ImageRenderer() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
main(String[] args)
Renders a file or URL to an image file.
|
static BufferedImage |
renderImageToOutput(String url,
FSImageWriter fsw,
String path,
int width)
Renders a document at a given URL and writes it out using the FSImageWriter provided (e.g. to a file
or outputstream).
|
static BufferedImage |
renderToImage(File inFile,
String path,
int width)
Renders the XML file as an image file at the target location.
|
static BufferedImage |
renderToImage(File inFile,
String path,
int width,
int height)
Renders the XML file as an image file at the target location.
|
static BufferedImage |
renderToImage(String url,
String path,
int width)
Renders the XML file at the given URL as an image file at the target location.
|
static BufferedImage |
renderToImage(String url,
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 BufferedImage renderToImage(String url, String path, int width) throws 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.IOException - if the input URL, or output path location is invalidpublic static BufferedImage renderToImage(String url, String path, int width, int height) throws 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.IOException - if the input URL, or output path location is invalidpublic static BufferedImage renderToImage(File inFile, String path, int width) throws IOException
inFile - XML file to renderpath - path to the image file to createwidth - Width in pixels to which the document should be constrained.IOException - if the input URL, or output path location is invalidpublic static BufferedImage renderToImage(File inFile, String path, int width, int height) throws 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.IOException - if the input URL, or output path location is invalidpublic static BufferedImage renderImageToOutput(String url, FSImageWriter fsw, String path, int width) throws IOException
url - fsw - path - width - IOExceptionpublic static void main(String[] args) throws IOException
args - see descIOException - if source could not be read, or if image path is invalidCopyright © 2019. All Rights Reserved.