generating svg using the jquery library

0 votes
asked Aug 20, 2013 in Wanted features by anonymous
It looks like the current  version of the jquery library for PlantUML generates an image format as the default output. is there a way the output format can be changed to svg instead?

1 Answer

+1 vote
answered Aug 20, 2013 by anonymous
 
Best answer

I managed to get if fixed with a small hack in the jquery_plantuml.js file.

I modified the done_deflating function and the world is all beautiful. I paste the code below in case someone else finds it useful. This allows for SVG files to also be clickable from within the browser. The trick however is that the canvas loading the img should have "svg_canvas" as its id. Maybe a quick hack, but works fine.

function done_deflating(e) {

var done = 0;
$("img").each(function () {
  if (done==1) return;
  var u1 = $(this).attr("src");
  if (u1!=null) return;
  var u2 = $(this).attr("uml");
  if (u2=="") return;
  $(this).attr("uml", "");
  var svgObj = document.createElement('object');
  svgObj.setAttribute("type", "image/svg+xml");
  document.getElementById("svg_canvas").appendChild(svgObj);
  done = 1;
});
plantuml_runonce();
}
commented Feb 13, 2015 by anonymous
Hi, could you give an example here? I cant set the UML syntax to HTML doc
commented Feb 13, 2015 by anonymous
I got it ;), but my solution works only for one canvas.. any tips?

My solution
<object id="svg_canvas"></object> <img uml="xyz">
commented May 2, 2017 by nikhil (520 points)
This works fine.
Only issue I am facing is, when it is a http url its working. However when I give a file url (E:/test/Plantuml.html) then its not working on click.. you need to right click and open the link in new window only then it load the file. any idea on this?
...