Exporting draw.io images to LaTeX


I discovered and tweaked a nifty one-liner which allows me to take .drawio files generated by Draw.io and export them as clean vector-based .pdf files which I can then include in a LaTeX document:

#!/usr/bin/env sh

find . -name *.drawio -exec rm -f ../img/{}.pdf \; -exec /Applications/draw.io.app/Contents/MacOS/./draw.io --crop -x -o ../img/{}.pdf {} \;

This finds all .drawio files in the current directory . and runs the draw.io executable on them to crop to the image and export as a .pdf to the directory where all my images are stored ../img/. \includegraphics{...} can then render the image in my LaTeX document. Note that this is on macOS, using the desktop version of draw.io, hence the funny executable.