I've recently renewed my frustration with pdflatex
when trying to include pdfs I've created in Illustrator with transparency. I finally have a "solution". Save the following in a file called fixpdftransp.sh
:
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage:"
echo " fixpdftransp input.pdf output.pdf"
return 1
fi
# This is known to work with:
# Included pdfs of compatibility >1.4
# Inkscape version 0.48.2 r9819 (Jul 15 2011)
# This is known not to work with:
# Included pdfs of compatibility 1.3
# Inkscape 0.48.3.1 r9886 (Aug 23 2013)
INKSCAPE="/Applications/Inkscape.app/Contents/Resources/bin/inkscape"
FORMATIN=".fixpdftransp-%09d.pdf"
FORMATOUT=".fixpdftransp-ink-%09d.pdf"
NUM_PAGES=`pdfinfo $1 | grep Pages: | sed -e "s/ *Pages: *//g"`
LIST=""
for i in $(seq 1 ${NUM_PAGES})
do
PAGE_NAME_IN=`printf $FORMATIN $i`
pdftk $1 cat $i output $PAGE_NAME_IN
echo "Creating $PAGE_NAME_IN"
PAGE_NAME_OUT=`printf $FORMATOUT $i`
echo "$INKSCAPE $PAGE_NAME_IN --export-pdf=$PAGE_NAME_OUT"
$INKSCAPE $PAGE_NAME_IN --export-pdf=$PAGE_NAME_OUT
LIST="$LIST $PAGE_NAME_OUT"
done
pdftk $LIST cat output $2
Notice you need a specific version of inkscape. I'm using whatever you download from their site today. Notably, this does not work with the inkscape from macports.
Save your included pdfs as PDF 1.4 or higher. Use pdflatex
to create a bad pdf and run this on your bad pdf:
./fixpdftransp.sh bad.pdf good.pdf
Update: Though this works on simple pdfs, inkscape seems to screw with the fonts and other images a lot. So, unfortunately resulting pdf is probably not usable.