Thanks Carlos for the tip.
With these utils I’ve managed to create a CUPS printer, which will create a booklet of the printed document in PDF format and will deliver it by e-mail. Perhaps others can use it as well.
Using these 2 snippets, it shouldn’t take more than a few minutes to set it up.
CUPS printer definition (just append this to the /etc/cups/printers.conf file)
<Printer email_as_booklet>
Info Generic with driver with driver Generic postscript printer
DeviceURI pipe://usr/local/bin/email_as_booklet
State Idle
StateTime 1282132922
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
And this is the script /usr/local/bin/email_as_booklet
#!/bin/bash
Hard-coded domain name of the recepient
DOMAIN="@localhost"
Let the local mailer daemon figure out the domain name
DOMAIN=""
Send all prints to this specific user
#RECEPIENT=joe
send the mail to the provided by CUPS, this user has submitted the job
RECEPIENT="$PIPE_BACKEND_ARGV2"
MSGTEXT="Dear $RECEPIENT,
This is the automated CUPS booklet printing facility.
Please find in the attachment your print formatted as a book
Regards,
CUPS
"
========= Don’t touch the script below this line, =============
========= unless you know what you’re doing =============
TMP=/tmp
OUTPUTTMP=$TMP/$$.ps
OUTPUTPS=$TMP/$$.booklet.ps
OUTPUTPDF=$TMP/$$.booklet.pdf
LOG=$TMP/$$.log
echo “Command line: “$@”” >> $LOG
env >> $LOG
cat - > “$OUTPUTTMP”
psbook “$OUTPUTTMP” | psnup -2 > “$OUTPUTPS”
ps2pdf “$OUTPUTPS” “$OUTPUTPDF”
for f in “$OUTPUTPDF” “$OUTPUTPS” “$LOG”
for f in “$OUTPUTPDF”
do
-f “$f” ] && ATTACHMENTS="$ATTACHMENTS -a $f"
done
mailx
$ATTACHMENTS
-s “CUPS booklet printer: job $PIPE_BACKEND_ARGV1 by $PIPE_BACKEND_ARGV2: $PIPE_BACKEND_ARGV3”
${RECEPIENT}${DOMAIN} <<EOF
$MSGTEXT
EOF
rm “$OUTPUTPS” “$OUTPUTTMP” “$OUTPUTPDF”
**Don’t forget to **
chmod a+x /usr/local/bin/email_as_booklet
**Don’t forget to restart CUPS… **
/etc/init.d/cups restart