Skip to content

Instantly share code, notes, and snippets.

@WPettersson
Created July 8, 2020 08:37
Show Gist options
  • Save WPettersson/325a9e72edf5e9fbe3c6bbe3a699472f to your computer and use it in GitHub Desktop.
Save WPettersson/325a9e72edf5e9fbe3c6bbe3a699472f to your computer and use it in GitHub Desktop.
Takes a Xournalpp xopp file, finds the embedded PDF location, copies the embedded pdf to `pwd`, and updates the xopp file
#!/bin/bash
set -e
XOPP_RAW=$(mktemp)
gunzip -c "$1" > ${XOPP_RAW}
PDF_LOC=$(awk -F\" '/domain="absolute" filename/ {print $6}' ${XOPP_RAW})
cp ${PDF_LOC} .
NEW_LOC="$(pwd)/$(basename ${PDF_LOC})"
echo ${NEW_LOC}
sed "s!${PDF_LOC}!${NEW_LOC}!" -i ${XOPP_RAW}
gzip -c ${XOPP_RAW} > "$1"
rm ${XOPP_RAW}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment