| 1 |
-- Booklet |
| 2 |
print("Booklet") |
| 3 |
-- We output an A4 booklet |
| 4 |
PageWidth = 595.27559 |
| 5 |
PageHeight = 841.88976 |
| 6 |
|
| 7 |
print("PageCount",PageCount) |
| 8 |
|
| 9 |
-- We assume that H > W |
| 10 |
-- Argh, we now can do better since we have "if" ;-) |
| 11 |
-- Scale = PageHeight / (2*SourceWidth) |
| 12 |
if(SourceWidth <= SourceHeight) |
| 13 |
then |
| 14 |
Scale = PageHeight / (2*SourceWidth) |
| 15 |
rot = 90 |
| 16 |
xof = SourceHeight |
| 17 |
yofRA = 0 |
| 18 |
yofRB = SourceWidth |
| 19 |
yofVA = 0 |
| 20 |
yofVB = SourceWidth |
| 21 |
else |
| 22 |
Scale = PageHeight / (2*SourceHeight) |
| 23 |
rot = 0 |
| 24 |
xof = 0; |
| 25 |
yofRA = 0 |
| 26 |
yofRB = SourceHeight |
| 27 |
yofVA = SourceHeight |
| 28 |
yofVB = 0 |
| 29 |
end |
| 30 |
|
| 31 |
do |
| 32 |
rest = PageCount % 4 |
| 33 |
totp = PageCount |
| 34 |
if rest ~= 0 |
| 35 |
then |
| 36 |
totp = totp + ( 4 - rest) |
| 37 |
end |
| 38 |
inc = 0 |
| 39 |
count = 0 |
| 40 |
imax = totp/4 |
| 41 |
while count < imax |
| 42 |
do |
| 43 |
-- We assume that podofoimpose will discard invalid records |
| 44 |
-- such as those with source page greater than PageCount |
| 45 |
-- print(totp, inc, rot, xof,yofRA, yofRA, yofVA, yofVB) |
| 46 |
-- Recto |
| 47 |
PushRecord(totp - inc , inc + 1 , rot, xof , yofRA) |
| 48 |
PushRecord(inc + 1 , inc + 1 , rot, xof , yofRB) |
| 49 |
-- Verso |
| 50 |
PushRecord(inc + 2 , inc + 2 , rot, xof , yofVA) |
| 51 |
PushRecord(totp-(inc + 1) , inc + 2 , rot, xof, yofVB) |
| 52 |
|
| 53 |
count = count + 1 |
| 54 |
inc = inc + 2 |
| 55 |
end |
| 56 |
end |