ajout de scripts pour impres...
|
1 |
#!/bin/bash |
2 | ||
3 |
pdf="$1" |
|
4 |
size=$(pdfinfo "$pdf" | awk '/^Page size:/{ |
|
5 |
a = $3 |
|
6 |
b = $5 |
|
massicotage de docs en paysa...
|
7 |
if (a >= 419 && a <= 421 && b >= 594 && b <= 596 ) print "a5 portrait" |
8 |
if (a >= 594 && a <= 596 && b >= 419 && b <= 421 ) print "a5 paysage" |
|
9 |
if (a >= 594 && a <= 596 && b >= 841 && b <= 843 ) print "a4 portrait" |
|
10 |
if (a >= 841 && a <= 843 && b >= 594 && b <= 596 ) print "a4 paysage" |
|
11 |
if (a >= 841 && a <= 843 && b >= 1189 && b <= 1191) print "a3 portrait" |
|
12 |
if (a >= 1189 && a <= 1191 && b >= 841 && b <= 843 ) print "a3 paysage" |
|
ajout de scripts pour impres...
|
13 |
}') |
14 |
pages=$(pdfinfo "$pdf" | awk '/Pages:/{print $2}') |
|
15 |
output=$(mktemp --dry-run /dev/shm/XXXXXXXX.pdf) |
|
16 |
recto=$(mktemp --directory /dev/shm/XXXXXXXX) |
|
17 |
verso=$(mktemp --directory /dev/shm/XXXXXXXX) |
|
18 | ||
massicotage de docs en paysa...
|
19 |
if test "${size% *}" != "a5"; then |
ajout de scripts pour impres...
|
20 |
gs -o $output -sDEVICE=pdfwrite -sPAPERSIZE=a5 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.6 "$pdf" |
21 |
else |
|
22 |
cp "$pdf" $output |
|
23 |
fi |
|
massicotage de docs en paysa...
|
24 |
if test "${size#* }" = "portrait"; then |
25 |
pdfjam --paper a4paper --nup '2x1' --landscape --outfile $recto -- "$output" 1 "$output" 1 |
|
26 |
else |
|
27 |
pdfjam --paper a4paper --nup '1x2' --no-landscape --outfile $recto -- "$output" 1 "$output" 1 |
|
28 |
fi |
|
ajout de scripts pour impres...
|
29 |
if test $pages -eq 2; then |
massicotage de docs en paysa...
|
30 |
if test "${size#* }" = "portrait"; then |
31 |
pdfjam --paper a4paper --nup '2x1' --landscape --outfile $verso -- "$output" 2 "$output" 2 |
|
32 |
else |
|
33 |
pdfjam --paper a4paper --nup '1x2' --no-landscape --outfile $verso -- "$output" 2 "$output" 2 |
|
34 |
fi |
|
ajout de scripts pour impres...
|
35 |
pdftk A=$(find $recto -name "*pdf") B=$(find $verso -name "*pdf") cat A B output "$output" |
36 |
else |
|
37 |
mv $(find $recto -name "*pdf") $output |
|
38 |
fi |
|
39 |
mv $output "${pdf%/*}/massicotable-${pdf##*/}" |
|
40 |
rm -fr $recto $verso $output |