Skip to content

Instantly share code, notes, and snippets.

@hghwng
Created August 29, 2019 07:03
Show Gist options
  • Save hghwng/0acde28e5f0bcc9517937eaa0528410c to your computer and use it in GitHub Desktop.
Save hghwng/0acde28e5f0bcc9517937eaa0528410c to your computer and use it in GitHub Desktop.
Converts PDF to PowerPoint. Fonts embedded.
#!/bin/bash -e
vectorize() {
input="$(realpath "$1")"
output="$(realpath "$2")"
mkdir -p _vectorize
cd _vectorize
echo "1. pdf to pages"
pdfseparate "$input" '%d.pdf'
echo "2. pages to svg (text -> outline)"
for i in *.pdf; do
pdf2svg "$i" "$i".svg
done;
echo "3. svg to pages"
(for i in *.svg; do
echo "$i" --export-pdf "$i.pdf"
done;) | inkscape --shell
echo "4. pages to pdf"
pdfunite $(ls *.svg.pdf | sort -n) "$output"
rm *.pdf *.svg;
cd ..
rmdir _vectorize
}
for input in "$@"; do
input="$(realpath "$input")"
vectorized="${input%*.pdf}_vectorize.pdf"
output="${input%*.pdf}.pptx"
vectorize "$input" "$vectorized"
libreoffice --infilter="impress_pdf_import" "$vectorized"
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment