Export to png and pdf option
ambagasdowa opened this issue · 5 comments
There is posible to have this feature ?
Context
there will be nice to export directly from smcat
im doing it with pipe to rsvg-convert
smcat file.smcat | rsvg-convert | img-viewer
Proposed Behavior
add png and pdf export option with -o switch in smcat cli
Considered alternatives
im using this
rsvg-convert
i found a lib in node
rsvg
hi @ambagasdowa - thanks for raising this issue. It's possible to emit png (and maybe even pdf) with the options already available in the underlying render engine (GraphViz). In state-machine-cat it means a bit of code shuffling to support a binary output format - I'll put it on the backlog.
You can already emulate exactly what the output will be with:
smcat yourdiagram.smcat --output-type dot --output-to - | dot -T png > yourdiagram.png
Hi @ambagasdowa I've published a beta on npm (state-machine-cat@10.1.0-beta-1
- shasum ba8f7e03e0d45ea65bc8ae88e2fc3891585aa081
) that outputs png
and pdf
- provided you use the command line version, and the command line version has the native GraphViz dot at its disposal.
What that version this should work:
smcat yourdiagram.smcat --output-type png --output-to yourdiagram.png
It still needs additional unit tests and error handling for when the fallback engine (viz.js) needs to be used because graphviz dot isn't available, but it's functional.
Could you let me know how it works for you?
Hi @ambagasdowa thanks for confirming :-). I've added non-regression tests & handling for the fall back for GraphViz - so I'm going to merge the PR and release a new version.
published as part of state-machine-cat@10.1.0