Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

correction | 10 comments | Create New Account
Click here to return to the 'correction' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Authored by: snuggles on Dec 14, '09 02:10:55PM
Commenter "slur" is correct in noting that I was mistaken about gs being part of the default Mac OS X installation; it's clearly not. On my system, it's found under '/usr/local/bin' and probably ended up there when I installed MacTeX many months ago. Fortunately, the fix actually simplifies things a bit: replace gs with the BSD command pstopdf, which really is part of Mac OS X (or Snow Leopard, at least). The simple version then becomes:
enscript --word-wrap -p - "$1" | pstopdf -i -o "$2"
And the longer version becomes:

MOD_TIME_EPOCH=`stat -f %m $1`
MOD_TIME_FMT=`date -r $MOD_TIME_EPOCH +'%a %e %b %Y @ %R %Z' | sed 's/ [ ]*/ /g'`
FULL_NAME=`php -r "echo realpath('$1');"`

mkdir -p $HOME/.enscript

# Create temporary "fancy header" file for enscipt.
cat > $HOME/.enscript/tmp_txt2pdf.hdr <<EOF
% -- code follows this line --
%Format: last_mod_timestr $MOD_TIME_FMT
%Format: pagestr page \$V$%/$=
%HeaderHeight: 30
%FooterHeight: 30
/Helvetica /helvetica-encoded MF
/Helvetica-10-Regular /helvetica-encoded findfont 10 scalefont def
/Helvetica-Bold /helvetica-bold-encoded MF
/Helvetica-10-Bold   /helvetica-bold-encoded findfont 10 scalefont def
/new_marg 4 def
/do_header {
    Helvetica-10-Bold setfont
    d_footer_x d_footer_w add pagestr stringwidth pop sub
    new_marg sub
    d_footer_y 7 add moveto pagestr show
    Helvetica-10-Bold setfont
    d_footer_x new_marg add d_footer_y 7 add moveto last_mod_timestr show
    Helvetica-10-Bold setfont
    d_header_x d_header_w 2 div add fname stringwidth pop 2 div sub
    d_header_y 16 add moveto fname show
} def

enscript --fancy-header=tmp_txt2pdf --word-wrap -p - "$FULL_NAME" | pstopdf -i -o "$2"

rm -f $HOME/.enscript/tmp_txt2pdf.hdr
It's worth noting that the seemingly superfluous % -- code follows this line -- seems to be a required part of enscript header files.

[ Reply to This | # ]