Hi,
I'm trying to manipulate the XML of the diagram on the server side in order to add some addtional info that will be shown in the default tooltip of some objects.
So far I've managed to decompress the XML with PHP and made all the updates needed.
I then compress the XML and send it to the client side, but the
draw.io viewer gives this eror message:
"Uncaught invalid distance too far back"
This is the PHP code I'm using to compress and encode the XML:
$a = urlencode(trim(explode("\n", $diagramXml->asXML(), 2)[1]));$b = gzdeflate($a, -1, ZLIB_ENCODING_RAW);
//Unsigned integer block size
$b = unpack("I*", $b);
//Convert to string
$compressedXml = base64_encode($this->bytesToString($b));
private function bytesToString($arr)
{
$str = '';
for ($i = 1; $i <= sizeof($arr); $i++) {
$char = '\u' . $arr[$i];
$str = $str . json_decode('"'.$char.'"');
}
return $str;
}
If I don't change the compressed XML on the server side all things are working so that excludes any client-server communication related issue.
Have been scratching my head around this for the past week without success... any help would be great!
Thanks in advance!