/** * Renders the XML file as an image file at the target location. Width must be provided, height is determined * automatically based on content and CSS. * * @param inFile XML file to render * @param path path to the image file to create * @param width Width in pixels to which the document should be constrained. * @param height Height in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(File inFile, String path, int width, int height) throws IOException { return renderToImage(inFile.toURI().toURL().toExternalForm(), path, width, height); }
/** * Renders a file or URL to an image file. Command line use: first * argument is URL or file path, second argument is path to image file to generate. * * @param args see desc * @throws java.io.IOException if source could not be read, or if image path is invalid */ public static void main(String[] args) throws IOException { if (args.length != 1) { usage("Incorrect argument list."); } String url = args[0]; if (url.indexOf("://") == -1) { // maybe it's a file File f = new File(url); if (f.exists()) { String output = f.getAbsolutePath(); output = output.substring(0, output.lastIndexOf(".")) + ".png"; System.out.println("Saving image to " + output); renderToImage(f, output, DEFAULT_WIDTH); } else { usage("File to render is not found: " + url); } } else { File out = File.createTempFile("fs", ".png"); System.out.println("Saving image to " + out.getAbsolutePath()); renderToImage(url, out.getAbsolutePath(), DEFAULT_WIDTH); } }
/** * Renders the XML file at the given URL as an image file at the target location. Width must be provided, * height is determined automatically based on content and CSS. * * @param url url for the XML file to render * @param path path to the PDF file to create * @param width Width in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(String url, String path, int width) throws IOException { return renderImageToOutput(url, new FSImageWriter(), path, width); }
/** * Renders a file or URL to an image file. Command line use: first * argument is URL or file path, second argument is path to image file to generate. * * @param args see desc * @throws java.io.IOException if source could not be read, or if image path is invalid */ public static void main(String[] args) throws IOException { if (args.length != 1) { usage("Incorrect argument list."); } String url = args[0]; if (url.indexOf("://") == -1) { // maybe it's a file File f = new File(url); if (f.exists()) { String output = f.getAbsolutePath(); output = output.substring(0, output.lastIndexOf(".")) + ".png"; System.out.println("Saving image to " + output); renderToImage(f, output, DEFAULT_WIDTH); } else { usage("File to render is not found: " + url); } } else { File out = File.createTempFile("fs", ".png"); System.out.println("Saving image to " + out.getAbsolutePath()); renderToImage(url, out.getAbsolutePath(), DEFAULT_WIDTH); } }
/** * Renders the XML file at the given URL as an image file at the target location. * * @param url url for the XML file to render * @param path path to the PDF file to create * @param width Width in pixels to which the document should be constrained. * @param height Height in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(String url, String path, int width, int height) throws IOException { return renderImageToOutput(url, new FSImageWriter(), path, width); }
/** * Renders the XML file at the given URL as an image file at the target location. Width must be provided, * height is determined automatically based on content and CSS. * * @param url url for the XML file to render * @param path path to the PDF file to create * @param width Width in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(String url, String path, int width) throws IOException { return renderImageToOutput(url, new FSImageWriter(), path, width); }
/** * Renders the XML file as an image file at the target location. Width must be provided, height is determined * automatically based on content and CSS. * * @param inFile XML file to render * @param path path to the image file to create * @param width Width in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(File inFile, String path, int width) throws IOException { return renderToImage(inFile.toURI().toURL().toExternalForm(), path, width); }
/** * Renders the XML file at the given URL as an image file at the target location. * * @param url url for the XML file to render * @param path path to the PDF file to create * @param width Width in pixels to which the document should be constrained. * @param height Height in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(String url, String path, int width, int height) throws IOException { return renderImageToOutput(url, new FSImageWriter(), path, width); }
/** * Renders the XML file as an image file at the target location. Width must be provided, height is determined * automatically based on content and CSS. * * @param inFile XML file to render * @param path path to the image file to create * @param width Width in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(File inFile, String path, int width) throws IOException { return renderToImage(inFile.toURI().toURL().toExternalForm(), path, width); }
/** * Renders the XML file as an image file at the target location. Width must be provided, height is determined * automatically based on content and CSS. * * @param inFile XML file to render * @param path path to the image file to create * @param width Width in pixels to which the document should be constrained. * @param height Height in pixels to which the document should be constrained. * * @throws java.io.IOException if the input URL, or output path location is invalid */ public static BufferedImage renderToImage(File inFile, String path, int width, int height) throws IOException { return renderToImage(inFile.toURI().toURL().toExternalForm(), path, width, height); }