I realise that the goal of this is probably to implement a TeX solution, but it really, really is easier after the document has been completed.
file=UITutorial.pdf; pdftk A=$file B=blank.pdf cat A1-end $(repeat $(( (4-(${$(pdfinfo $file| grep '^Pages:'):s/Pages://:s/ /})%4)%4 )) print -n "B1 ") output ${file:r}_4pgs.pdf
or if you prefer it spaced out a bit:
file=UITutorial.pdf; \
pdftk A=$file B=blank.pdf \
cat A1-end \
$(repeat $(( (4-(${$(pdfinfo $file| grep '^Pages:'):s/Pages://:s/ /})%4)%4 )) print -n "B1 ")\
output ${file:r}_4pgs.pdf
Works with zsh on Unix (Linux, MacOSX, ...), don't know if it would work with other shells. Needs blank.pdf to be a PDF consisting of a single blank page.
Explanation:
file=UITutorial.pdf; \
sets the file we'll use so that we only have to refer to it once
pdftk A=$file B=blank.pdf \
Our inputs will be our given file and the blank PDF.
cat A1-end \
The cat command says "Concatenate the following pages into our output" and the first set of pages are all of those from the main file.
$(repeat $(( (4-(${$(pdfinfo $file| grep '^Pages:'):s/Pages://:s/ /})%4)%4 )) print -n "B1 ")\
The second set is a bit more complicated. We find out how many pages our PDF has via the pdfinfo command. Then we take this modulo 4. We want to round up to the nearest multiple of 4 so we want to take 4 - <this number> except that if <this number> is already a multiple of 4 we don't want to add any. So we work out (4 - <pages>%4)%4. Then we insert into the page specification B1 that number of times. This says "Take page 1 from source B" (which was the blank one) and we do it the right number of times.
output ${file:r}_4pgs.pdf
Now we direct our output to <filename>_4pgs.pdf, where <filename> is what we originally specified but with the extension stripped off.