0

I need to print a bunch of text files. They are all pretty small and they fit okay on one text page if the font size is chosen adequately. How can I do this automatically?

I tried (find ... -exec ... for the full call, this is one document only )

lp o fit-to-page -o media=A4 text.txt

but this just prints text.txt on one page of A4.

lp -o cpi=16 -o lpi=12 -o media=A4 text.txt

does the job, but how do I "auto-detect" cpi and lpi?

4

1 に答える 1

0

次のコードスニペットは私のために仕事をします

#!/bin/sh
# 8,2677 x 11,6929 inch = A4
awk ' { if ( length > L ) { L=length} }END{ print L}' "$1" > width
awk ' { print NR } ' "$1" | tail -1 > height
cpiraw=`cat width`
echo "$cpiraw"
lpiraw=`cat height`
echo "$lpiraw"
cpi=$(((cpiraw/8+1)))
echo "$cpi"
lpi=$(((lpiraw/11+1)))
echo "$lpi"
lp -o cpi=$cpi -o lpi=$lpi -o media=A4 "$1"
rm width
rm height

私は決してUNIXシェルの専門家ではありません.誰かが「適切な」答えを思いついたら感謝します.

于 2014-05-21T12:04:07.480 に答える