如何将mxGraph生成的.XML导出到图像文件?

I'm having problems exporting the xml generating by the mxGraph editor to image file (png or jpg)

I tried using the PHP sample code and I'm getting errors like those in the generated file

<b>Notice</b>:  Undefined variable: bounds in <b>php/src/canvas/mxGdCanvas.php</b> on line <b>972</b><br />
<br />
<b>Warning</b>:  Creating default object from empty value in <b>php/src/canvas/mxGdCanvas.php</b> on line <b>972</b><br />
<br />
<b>Notice</b>:  Undefined property: stdClass::$width in <b>php/src/canvas/mxGdCanvas.php</b> on line <b>972</b><br />
<br />
<b>Notice</b>:  Undefined property: stdClass::$x in <b>php/src/canvas/mxGdCanvas.php</b> on line <b>973</b><br />
<br />
<b>Notice</b>:  Undefined property: stdClass::$y in <b>php/src/canvas/mxGdCanvas.php</b> on line <b>974</b><br />

The PHP code Im using is:

<?php
/**
 * Copyright (c) 2006, Gaudenz Alder
 */
include_once("../src/mxServer.php");

/**
 * Function: main
 *
 * Creates a graph using the API and converts it into a PNG image.
 */
function main()
{
    $format = "png";
    $filename = "diagrams/graphmodel.xml";
    $xml = file_get_contents($filename);

    $image = mxGraphViewImageReader::convert($xml, "#FFFFFF");

    header("Content-Type: image/png");
    echo mxUtils::encodeImage($image);
}

//mxConstants::$DEFAULT_FONTFAMILY = "ttf/verah.ttf";


main();
?>

I also tried the Java servlet and the image generated is always blank.

Is there anything else I could try? I know there is a .NET sdk as well, but I would like to avoid using it.

thanks