Downloading an image of the diagram

I’m trying to use makeImageData to generate an image that the user can download. It’s working fine in Chrome and FireFox but nothing is happening with IE. I don’t think it’s a problem with makeImageData, the function returns something that looks kind of sensible, but I’m just wondering the recommended approach for doing this, as I assume it’s what makeImageData is primarily for? I’m just assigning the return value to an anchor’s href after the user has clicked on it. HTML snippet is


  • Image
  • TypeScript snippet

        $("#model-image a").on("click", (e) => {
          var imageData = this.diagram.makeImageData();
          $("#model-image a").attr("href", imageData);

    Ah, it seems IE doesn’t support data URIs. Hmm

    Why can’t you set the src property of the Image instead of the href property of the anchor?

    I’m trying to let the user click a button which downloads the image rather than displaying the image. The li is a toolbar button with an image rather than being where the image will appear. Bad semantic HTML, slapped wrist…

    OK, so everything’s working now on all platforms, yes?

    No, I don’t think I can get it working in IE, but it’s not a GoJS issue. I think I will have to create the image and post it to the server and return it again as a download

    Oh, did you mean downloading in order to save as a local file, rather than just downloading as part of the rendering of the page? If so, I think you’re right.