Skip to content

Instantly share code, notes, and snippets.

@tdewin
Last active July 3, 2024 08:54
Show Gist options
  • Save tdewin/73ae79fcd01e2cead01ca94da8ca6eda to your computer and use it in GitHub Desktop.
Save tdewin/73ae79fcd01e2cead01ca94da8ca6eda to your computer and use it in GitHub Desktop.
Convert Inkscape diagram "cloud*.svg" to a compatible svg for powerpoint. Put lines with connector in a group with id "connectorgroup" to stroke them to path. Converts font to paths to keep size the same (and also share even if the target party does not have the font)
#!/bin/bash
PPTX="pptxcompat"
PNGP="pngout"
# stamps so we dont process unmodified files over and over again
VERTRACK="vertrack"
mkdir -p $VERTRACK
mkdir -p $PPTX
mkdir -p $PNGP
find . -depth 1 -name 'cloud*.svg' -print0 | while read -d $'\0' SVGF
do
SVGEXP="$PPTX/$SVGF.pptxcompat.svg"
VER=$(date -r $SVGF +"%s")
SVGBASE=$(basename $SVGF)
VERFILE=$(printf "%s/%s.%s.tr" $VERTRACK $SVGBASE $VER)
if [ -f "$VERFILE" ]; then
echo "Skipping $VERFILE"
else
touch $VERFILE
printf "Converting $SVGF $SVGEXP"
/Applications/Inkscape.app/Contents/MacOS/inkscape -o "$SVGEXP"\
--export-plain-svg\
--export-overwrite\
--actions="select-by-id:connectorgroup;object-stroke-to-path;selection-ungroup;select-all:all;page-fit-to-selection;select-all:all;selection-ungroup;"\
--export-text-to-path\
"$SVGF"
/Applications/Inkscape.app/Contents/MacOS/inkscape -o "$PNGP/$SVGF.png"\
--export-overwrite\
-b FFFFFF\
--export-margin=10\
"$SVGEXP"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment