Hacker News new | ask | show | jobs
by davidjgraph 1632 days ago
The headless hacking isn't needed, there's a headless chrome/puppeteer PDF generation [1], it what we use for PDF generation at app.diagrams.net.

There's also various docker images [2] including one for the image generations.

[1] https://github.com/jgraph/draw-image-export2 [2] https://github.com/jgraph/docker-drawio

2 comments

Hey David, thanks for draw.io/diagrams.net and I hope you liked the article!

I've found both of these before attempting any of this (I think you linked them to me on Twitter?), but was happy with neither of them: the point was to not depend on Docker, or Node, or have a solution that's Linux-only.

My solution integrates well with the rest of the pipeline that's all-Rust, and it works at least on Linux and Windows (macOS would probably be easy to support as well but I don't use it currently). It's very similar to `draw-image-export2` in spirit.

In my solution I made sure to ship a font I always use in diagrams (Iosevka) as a webfont, so I don't have to rely on fontconfig to find it - I'm not sure how that would work with either of the readily available solutions. And finally, I've left as a next step but: I am planning on keeping a Chrome instance running in the background (and an http server), and re-use it so there's less setup/teardown for each export.

Yes, I confess to enjoying a long hack to achieve an end goal, even if it's working around issues I helped to cause :).

But yes, I see the problem with docker, we don't actually use any of the docker images anywhere. Why is node a problem?

We are thinking about adding an option to make the SVG export go via PDF through inkscape to make the labels all SVG. The end SVG is actually smaller than the one we produce in initial testing.

Since you mentioned dark mode in the article, here are some ideas: https://github.com/jgraph/drawio-github/blob/master/DARK-MOD...
Do you know, does this also work in WSL nowadays. Some time ago I've tried to generate a PDF/SVG using mermaid.js' CLI and it failed miserably with a Chrome stacktrace.

Edit: I'd also like to point out that depending on Chrome just to support headless exports seems a bit much, but I've also got 32GB of ram to spare, so I might be fine.