summaryrefslogtreecommitdiff
path: root/doc/doc-docbook/PageLabelPDF
diff options
context:
space:
mode:
Diffstat (limited to 'doc/doc-docbook/PageLabelPDF')
-rwxr-xr-xdoc/doc-docbook/PageLabelPDF61
1 files changed, 61 insertions, 0 deletions
diff --git a/doc/doc-docbook/PageLabelPDF b/doc/doc-docbook/PageLabelPDF
new file mode 100755
index 000000000..aa144e208
--- /dev/null
+++ b/doc/doc-docbook/PageLabelPDF
@@ -0,0 +1,61 @@
+#! /usr/bin/perl -w
+
+# $Cambridge: exim/doc/doc-docbook/PageLabelPDF,v 1.1 2006/02/01 11:01:01 ph10 Exp $
+
+# 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 screwed in as 12 in the next statement.
+
+$add = "/PageLabels << /Nums [ 0 << /S /r >>\n" .
+ " 12 << /S /D >>\n" .
+ " ]\n" .
+ " >>\n";
+
+$extra = length $add;
+
+$before = 0;
+while (<>)
+ {
+ print;
+ $before += length($_);
+ last if $_ =~ "^<< /Type /Catalog";
+ }
+
+print $add;
+
+while (<>)
+ {
+ print;
+ last if $_ =~ /^xref$/;
+ }
+
+while (<>)
+ {
+ if (/^(\d{10}) (.*)/)
+ {
+ my($was) = $1;
+ my($rest) = $2;
+ printf "%010d $rest\n", $was + (($was > $before)? $extra : 0);
+ }
+ elsif (/^startxref/)
+ {
+ print;
+ $_ = <>;
+ if (/^(\d+)/)
+ {
+ print $1 + $extra, "\n";
+ }
+ else
+ {
+ print;
+ }
+ }
+ else
+ {
+ print;
+ }
+ }
+
+# End
+
+