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