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