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

时间:2016-12-14 13:35:00

标签: javascript java php image-processing mxgraph

我在将mxGraph编辑器生成的xml导出到图像文件(png或jpg)时遇到问题

我尝试使用PHP示例代码,并且我收到了生成文件中的错误

<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 />

我使用的PHP代码是:

<?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();
?>

我也尝试过Java servlet,生成的图像总是空白的。

还有什么我可以尝试的吗? 我知道还有一个.NET sdk,但我想避免使用它。

感谢

0 个答案:

没有答案