Commit | Line | Data |
---|---|---|
9b371988 PH |
1 | #! /usr/bin/perl -w |
2 | ||
3 | # $Cambridge: exim/doc/doc-docbook/PageLabelPDF,v 1.1 2006/02/01 11:01:01 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 screwed in as 12 in the next statement. | |
8 | ||
9 | $add = "/PageLabels << /Nums [ 0 << /S /r >>\n" . | |
10 | " 12 << /S /D >>\n" . | |
11 | " ]\n" . | |
12 | " >>\n"; | |
13 | ||
14 | $extra = length $add; | |
15 | ||
16 | $before = 0; | |
17 | while (<>) | |
18 | { | |
19 | print; | |
20 | $before += length($_); | |
21 | last if $_ =~ "^<< /Type /Catalog"; | |
22 | } | |
23 | ||
24 | print $add; | |
25 | ||
26 | while (<>) | |
27 | { | |
28 | print; | |
29 | last if $_ =~ /^xref$/; | |
30 | } | |
31 | ||
32 | while (<>) | |
33 | { | |
34 | if (/^(\d{10}) (.*)/) | |
35 | { | |
36 | my($was) = $1; | |
37 | my($rest) = $2; | |
38 | printf "%010d $rest\n", $was + (($was > $before)? $extra : 0); | |
39 | } | |
40 | elsif (/^startxref/) | |
41 | { | |
42 | print; | |
43 | $_ = <>; | |
44 | if (/^(\d+)/) | |
45 | { | |
46 | print $1 + $extra, "\n"; | |
47 | } | |
48 | else | |
49 | { | |
50 | print; | |
51 | } | |
52 | } | |
53 | else | |
54 | { | |
55 | print; | |
56 | } | |
57 | } | |
58 | ||
59 | # End | |
60 | ||
61 |