blob: 454d0ec4a8006d53ec748c610b0c11b9963ad318 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#! /usr/bin/perl -w
# Program to add page label information to the PDF output file. I have not
# found a way of automatically discovering the number of frontmatter pages
# in the document. It is therefore taken as an argument to be inserted into the
# next statement.
$add = "/PageLabels << /Nums [ 0 << /S /r >>\n" .
" $ARGV[0] << /S /D >>\n" .
" ]\n" .
" >>\n";
$extra = length $add;
$before = 0;
while (<STDIN>)
{
print;
$before += length($_);
last if $_ =~ "^<< /Type /Catalog";
}
print $add;
while (<STDIN>)
{
print;
last if $_ =~ /^xref$/;
}
while (<STDIN>)
{
if (/^(\d{10}) (.*)/)
{
my($was) = $1;
my($rest) = $2;
printf "%010d $rest\n", $was + (($was > $before)? $extra : 0);
}
elsif (/^startxref/)
{
print;
$_ = <STDIN>;
if (/^(\d+)/)
{
print $1 + $extra, "\n";
}
else
{
print;
}
}
else
{
print;
}
}
# End
|