embedded mode: Save as uncompressed XML

849 views
Skip to first unread message

Thiya

unread,
Mar 3, 2017, 5:07:51 AM3/3/17
to draw.io
Hello together,

I'm embedding draw.io to my own application and i need the diagramm to be saved as uncompressed XML.
I'm developing my application according to this example: https://github.com/jgraph/drawio-html5 (local Storage) but i need the Diagramm to be saved on my Server and not embedded as PNG.

All in all i got everything together, but i'm only able to get the Datas as compressed XML. I'm using this:
source.drawIoWindow.postMessage(JSON.stringify({action: 'export', format: 'xml', spinKey: 'saving'}), '*');

Is it supported to have uncompressed XML. And if yes, how can I adjust the line above to get uncompressed XML.

Thanks for every help :)

Gaudenz Alder

unread,
Mar 3, 2017, 12:50:48 PM3/3/17
to draw.io
No, uncompressed XML is not supported.

Zachary Beyer

unread,
Aug 7, 2018, 6:18:41 PM8/7/18
to draw.io
Were you ever able to accomplish something similar to this? 
I am interested in finding a solution to embedding the plain XML as an image so that I no longer need to export as an SVG to present diagrams in HTML (my query might not be related to yours—it's unclear).

Gaudenz Alder

unread,
Aug 7, 2018, 6:21:48 PM8/7/18
to draw.io
Have you tried savibg the file with an .svg suffix?

Marco Azzalini

unread,
Oct 19, 2018, 7:29:23 AM10/19/18
to draw.io
Hi Gaudenz, 
I am also trying to embed draw.io in my own webapp and to accomplish it I am following this tutorial:  Simple draw.io embedding walk-through (https://support.draw.io/pages/viewpage.action?pageId=8945851)
At the moment I am trying to read the (plain) xml sent back from editor when my user press Save button but I got always an image:  (data:image/svg+xml;base64,...)
Are you really telling us that there is no way to have the same behavior as  File|Export|Xml   command? 
If so, how can I integrate draw.io in my application, saving in my DB the xml graph as modified by the user?
Is it possible to export in other formats:compressed xml or similar ? If so, do I need to decompress it before loading? If so, how?

Please, let me know... I am stuck on this :-(

thank you very much
Best regards,
Marco

David Benson

unread,
Oct 19, 2018, 10:46:49 AM10/19/18
to draw.io
Use format: 'xml' and inflate the result?

Marco Azzalini

unread,
Oct 19, 2018, 11:38:37 AM10/19/18
to draw.io
Hi David, thank you for you reply.
Sorry, I am not a Javascript expert so probably I didn't catch your suggestion... I am already using xml as format with this POST

if (msg.event == 'save')
    postMessage(JSON.stringify({action: 'export', format: 'xml', spinKey: 'saving'}), '*');

but I receive an image, not xml. Do you mean that inside the image there is also the xml graph description? If so, how can I extract it
Can you detail me a little bit your idea?

thanks in advance,
MArco 

Marco Azzalini

unread,
Oct 23, 2018, 5:40:32 AM10/23/18
to draw.io
Hi David, could you give me some more details in how to get back diagram's xml from draw.io in embeded mode? Is it possible? 

thanks in advance,
Marco

David Benson

unread,
Oct 24, 2018, 1:36:37 AM10/24/18
to draw.io
I'm on holiday, I don't have time to create a complete example. If you create a complete example using something like codepen, it would be much quicker to debug.

Marco Azzalini

unread,
Oct 24, 2018, 5:32:30 AM10/24/18
to draw.io
Hi David. Thanks but  I don't need a complete working example. It would be sufficient to understand how to deal with the xml data coming from a 'save' message from embedded draw.io.
It is in the form <diagram id="1-2-3" name="Page-1">very-long-string</diagram>

I don't know what there is inside the 'very-long-string' ? Is it a base64/compressed/whatever version of my graph's xml? If so, is there a way to decode/inflate/whatever it and have back the graph's xml rappresentation:

<mxGraphModel dx="1038" dy="514" grid="1" gridSize="10" guides  ........... /></mxGraphModel>

to save it into my DB?

Thanks in advance,
Marco

Gaudenz Alder

unread,
Oct 24, 2018, 5:42:03 AM10/24/18
to draw.io
See the code for the decode button in https://jgraph.github.io/drawio-tools/tools/convert.html

Marco Azzalini

unread,
Oct 24, 2018, 6:00:52 AM10/24/18
to draw.io
Thanks Gaudenz!  This is VERY interesting and helpful !

MArco
Reply all
Reply to author
Forward
0 new messages