Page label fixes + documentation

This commit is contained in:
John Whitington 2014-09-18 14:27:07 +01:00
parent 285863d6af
commit 91b81da679
5 changed files with 19 additions and 16 deletions

18
cpdf.ml
View File

@ -3256,20 +3256,20 @@ let page1 labels =
let add_page_labels pdf style prefix startval range =
let ranges = map extremes (ranges_of_range [] [] range)
and labels = Pdfpagelabels.read pdf in
(*Printf.printf "We have %i existing labels\n" (List.length labels);
Printf.printf "We have %i ranges to apply these labels to\n" (List.length ranges);*)
Printf.printf "We have %i existing labels\n" (List.length labels);
Printf.printf "We have %i ranges to apply these labels to\n" (List.length ranges);
let labels =
if not (page1 labels) then
ref
({Pdfpagelabels.labelstyle = Some Pdfpagelabels.DecimalArabic;
({Pdfpagelabels.labelstyle = Pdfpagelabels.DecimalArabic;
Pdfpagelabels.labelprefix = None;
Pdfpagelabels.startpage = 1;
Pdfpagelabels.startvalue = 1}::labels)
else
ref labels
in
(*Printf.printf "Before adding, we have these labels:\n";
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;*)
Printf.printf "Before adding, we have these labels:\n";
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;
iter
(function (s, e) ->
let label =
@ -3278,11 +3278,11 @@ let add_page_labels pdf style prefix startval range =
Pdfpagelabels.startpage = s;
Pdfpagelabels.startvalue = startval}
in
(*Printf.printf "We are adding this label:\n";
flprint (Pdfpagelabels.string_of_pagelabel label);*)
Printf.printf "We are adding this label:\n";
flprint (Pdfpagelabels.string_of_pagelabel label);
labels := Pdfpagelabels.add_label (Pdfpage.endpage pdf) !labels label e)
ranges;
(*Printf.printf "After adding, we have these labels:\n";
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;*)
Printf.printf "After adding, we have these labels:\n";
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;
Pdfpagelabels.write pdf !labels

View File

@ -399,7 +399,8 @@ val blank_document_paper : Pdfpaper.t -> int -> Pdf.t
(** {2 Page labels} *)
(** Add page labels. *)
val add_page_labels : Pdf.t -> Pdfpagelabels.labelstyle option -> string option -> int -> int list -> unit
val add_page_labels :
Pdf.t -> Pdfpagelabels.labelstyle -> string option -> int -> int list -> unit
(** {2 Miscellany} *)

View File

@ -255,7 +255,7 @@ type args =
mutable makenewid : bool;
mutable ismulti : bool;
mutable uprightstamp : bool;
mutable labelstyle : Pdfpagelabels.labelstyle option;
mutable labelstyle : Pdfpagelabels.labelstyle;
mutable labelprefix : string option;
mutable labeloffset : int option;
mutable squeeze : bool}
@ -338,7 +338,7 @@ let args =
makenewid = false;
ismulti = false;
uprightstamp = false;
labelstyle = None;
labelstyle = Pdfpagelabels.DecimalArabic;
labelprefix = None;
labeloffset = None;
squeeze = false}
@ -412,7 +412,7 @@ let reset_arguments () =
args.makenewid <- false;
args.ismulti <- false;
args.uprightstamp <- false;
args.labelstyle <- None;
args.labelstyle <- Pdfpagelabels.DecimalArabic;
args.labelprefix <- None;
args.labeloffset <- None;
args.squeeze <- false
@ -1213,9 +1213,10 @@ let setlabelstyle s =
| "LowercaseRoman" -> Pdfpagelabels.LowercaseRoman
| "UppercaseLetters" -> Pdfpagelabels.UppercaseLetters
| "LowercaseLetters" -> Pdfpagelabels.LowercaseLetters
| "NoLabelPrefixOnly" -> Pdfpagelabels.NoLabelPrefixOnly
| _ -> error "Unknown label style"
in
args.labelstyle <- Some style
args.labelstyle <- style
let setlabelprefix s =
args.labelprefix <- Some s

Binary file not shown.

View File

@ -1780,8 +1780,9 @@ It is possible to add \textit{page labels} to a document. These are not the prin
\texttt{DecimalArabic} & 1,2,3,4,5\ldots \\
\texttt{LowercaseRoman} & i,ii,iii,iv,v\ldots \\
\texttt{UppercaseRoman} & I,II,III,IV,V\ldots \\
\texttt{LowercaseLetters} & a,b,c,\ldots,z,aa,ab\ldots \\
\texttt{UppercaseLetters} & A,B,C,\ldots,Z,AA,AB\ldots \\
\texttt{LowercaseLetters} & a,b,c,\ldots,z,aa,bb\ldots \\
\texttt{UppercaseLetters} & A,B,C,\ldots,Z,AA,BB\ldots \\
\texttt{NoLabelPrefixOnly} & No number, but a prefix will be used if defined.
\end{tabular}
\vspace{4mm}