xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joris Kinable <deu...@gmail.com>
Subject generating png and pdf files
Date Wed, 13 Apr 2011 17:39:50 GMT

I have a mxGraphComponent which basically is a
javax.swing.JScrollPane. Objective is to print this mxGraphComponent
to a file in the following 3 formats: SVG, PDF, PNG. The images in the
.SVG and .PDF files should be scalable i.e. vectorized. The following
code works great for printing the .SVG file:

private void batikTest(mxGraphComponent graphComponent){
		// Get a DOMImplementation
        DOMImplementation domImpl =

        // Create an instance of org.w3c.dom.Document
        Document document = domImpl.createDocument(null, "svg", null);

        // Create an instance of the SVG Generator
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

        // Print to the SVG Graphics2D object

        boolean useCSS = false;

        Writer out;
		try {
			out=new FileWriter(new File(OUTPUTDIR+fileName+"_batik.SVG"));
			svgGenerator.stream(out, useCSS);
		} catch (Exception e) {
	System.out.println("Batik svg printed");

Is there a convenient way to generate the .PDF and .PNG files too
using this code? I can't really find how to do that within the code.
There is a description on how to externally convert the generated .SVG
file to a pdf (http://xmlgraphics.apache.org/batik/tools/rasterizer.html)
 but I would like to do this within the code, without having to call
an external tool.



To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message