Skip to content

Instantly share code, notes, and snippets.

@stefan2904
Last active October 23, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefan2904/e7ee97716685281461f3e470bd4ed6f6 to your computer and use it in GitHub Desktop.
Save stefan2904/e7ee97716685281461f3e470bd4ed6f6 to your computer and use it in GitHub Desktop.
draw.io / diagrams.net batch exporter
#!/bin/bash
# Get desktop-app (which includes CLI) from http://get.diagrams.net
NUM_PAGES=4
DRAWIO_FILE="cdn-setup1"
#set -o xtrace
for ((page=0; page<NUM_PAGES; page++))
do
idx="$(($page+1))"
PAGENAME=`xpath -e "string(/mxfile/diagram[$idx]/@name)" -q $DRAWIO_FILE.drawio`
echo $PAGENAME
# OUTNAME="$DRAWIO_FILE-$PAGENAME.pdf"
OUTNAME="$DRAWIO_FILE-Slide$page.pdf"
drawio --export \
--format pdf \
--crop \
--transparent \
--page-index $page \
--output $OUTNAME \
$DRAWIO_FILE.drawio
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment