Is it possible to get SVG as an object from Viewer? I only found using canvas._svg
but this is accessing private variable of canvas
. Is there any other way?
You may try Viewer#saveSVG
which serves exactly your purpose. The following should work:
var bpmnJS = new BpmnViewer(...);
bpmnJS.importXML(someXML);
bpmnJS.saveSVG(function(err, svg) {
// do stuff with the SVG
});
This is something that I want to avoid. I already have saveXML
that switches between modeler and viewer. Also, I’m not sure how this will affect SVG that is already rendered on the canvas.
Why would you like to avoid it?
Because currently I have code like this.
modelerEventBus.on("import.done", function () {
modeler.saveXML({format: false}, function (error, xml) {
viewer.importXML(xml, function () {
adjustWorkflowDiagramDimensions(viewer);
highlightAdHocWorkflowActiveTasks(viewer);
});
});
});
I don’t want to complicate even further this functions with saveSVG
All right then .