Code Monkey home page Code Monkey logo

Comments (4)

simonbrowndotje avatar simonbrowndotje commented on August 16, 2024 1

In addition to making your workspace accessible without authentication (/share in the URL suggests that you've made the workspace public, which may be okay for your use case, but I'd generally advise caution doing this), you may find the image URL doesn't work as expected. The images behind those static URLs are not regenerated immediately when a workspace has been modified, so you will very likely see an older version at times. We've added the PNG export button to the embedded iframe.

That said, to answer the question of the issue title, "Is it possible to download a diagram as an svg/png through the web api?":

  1. No. The JSON based web API, and by extension the .NET client library, does not have the ability to download PNG versions of the diagrams.
  2. If you want to download the current diagram(s) as PNG files, via the command line, you'll need to use Puppeteer to start up a web browser in headless mode.

from dotnet.

simonbrowndotje avatar simonbrowndotje commented on August 16, 2024

Unfortunately not, because the diagrams are rendered client-side. You could potentially use the Scripting API via Puppeteer though.

from dotnet.

devantler avatar devantler commented on August 16, 2024

I made it work, by using a hyperlink with the download property.

<a url="https://structurizr.com/share/{workspaceId}/{diagramId}/images/{imageName}.png" download/>

This does not prompt for a download, as that is not supported by browsers (see this), but it does open the image in a new tab, so the rest is just to right click and save as image.

Thanks for sharing Puppeteer, I'll try to fiddle some with it to see if that makes for a better solution :-)

from dotnet.

devantler avatar devantler commented on August 16, 2024

Thanks, I did notice the images were not available at all times, and came to the same conclusion with regard to security issues.

Nice to hear you've added an export button. That solves my use case even better 👍

from dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.