This script generates combination from layered inkscape svg files. Layers have special IDs and inkscapes --export-id=$ID
option is used. First the svg is prepared for easier parsing by converting all spaces to newlines:
cat $SVG | \ sed 's/display:none/display:inline/g' | \ sed 's/ /\n/g' > $TMPSVG
Then for every ID containing the custom pattern ELEMENT-
a pdf is exported:
for ELEMENT in `grep "id=\"ELEMENT-" $TMPSVG | \ cut -d "\"" -f 2` do LINENUMBER=`grep -n $ELEMENT $TMPSVG | \ cut -d ":" -f 1 | tail -1`TMPPDF=$TMPDIR/tmp_${LINENUMBER}-${ELEMENT}.pdfinkscape -z --export-pdf=$TMPPDF \ --export-id=$ELEMENT \ --export-id-only \ --export-area-page \ $TMPSVG done
Layers, which are now pdf files, are reassembled taking one of each type, using pdftk. That’s the basic functionality, in practise it’s are little bit more complicated.