Page label fixes + documentation
This commit is contained in:
parent
285863d6af
commit
91b81da679
18
cpdf.ml
18
cpdf.ml
|
@ -3256,20 +3256,20 @@ let page1 labels =
|
||||||
let add_page_labels pdf style prefix startval range =
|
let add_page_labels pdf style prefix startval range =
|
||||||
let ranges = map extremes (ranges_of_range [] [] range)
|
let ranges = map extremes (ranges_of_range [] [] range)
|
||||||
and labels = Pdfpagelabels.read pdf in
|
and labels = Pdfpagelabels.read pdf in
|
||||||
(*Printf.printf "We have %i existing labels\n" (List.length labels);
|
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 ranges to apply these labels to\n" (List.length ranges);
|
||||||
let labels =
|
let labels =
|
||||||
if not (page1 labels) then
|
if not (page1 labels) then
|
||||||
ref
|
ref
|
||||||
({Pdfpagelabels.labelstyle = Some Pdfpagelabels.DecimalArabic;
|
({Pdfpagelabels.labelstyle = Pdfpagelabels.DecimalArabic;
|
||||||
Pdfpagelabels.labelprefix = None;
|
Pdfpagelabels.labelprefix = None;
|
||||||
Pdfpagelabels.startpage = 1;
|
Pdfpagelabels.startpage = 1;
|
||||||
Pdfpagelabels.startvalue = 1}::labels)
|
Pdfpagelabels.startvalue = 1}::labels)
|
||||||
else
|
else
|
||||||
ref labels
|
ref labels
|
||||||
in
|
in
|
||||||
(*Printf.printf "Before adding, we have these labels:\n";
|
Printf.printf "Before adding, we have these labels:\n";
|
||||||
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;*)
|
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;
|
||||||
iter
|
iter
|
||||||
(function (s, e) ->
|
(function (s, e) ->
|
||||||
let label =
|
let label =
|
||||||
|
@ -3278,11 +3278,11 @@ let add_page_labels pdf style prefix startval range =
|
||||||
Pdfpagelabels.startpage = s;
|
Pdfpagelabels.startpage = s;
|
||||||
Pdfpagelabels.startvalue = startval}
|
Pdfpagelabels.startvalue = startval}
|
||||||
in
|
in
|
||||||
(*Printf.printf "We are adding this label:\n";
|
Printf.printf "We are adding this label:\n";
|
||||||
flprint (Pdfpagelabels.string_of_pagelabel label);*)
|
flprint (Pdfpagelabels.string_of_pagelabel label);
|
||||||
labels := Pdfpagelabels.add_label (Pdfpage.endpage pdf) !labels label e)
|
labels := Pdfpagelabels.add_label (Pdfpage.endpage pdf) !labels label e)
|
||||||
ranges;
|
ranges;
|
||||||
(*Printf.printf "After adding, we have these labels:\n";
|
Printf.printf "After adding, we have these labels:\n";
|
||||||
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;*)
|
iter (fun x -> flprint (Pdfpagelabels.string_of_pagelabel x)) !labels;
|
||||||
Pdfpagelabels.write pdf !labels
|
Pdfpagelabels.write pdf !labels
|
||||||
|
|
||||||
|
|
3
cpdf.mli
3
cpdf.mli
|
@ -399,7 +399,8 @@ val blank_document_paper : Pdfpaper.t -> int -> Pdf.t
|
||||||
(** {2 Page labels} *)
|
(** {2 Page labels} *)
|
||||||
|
|
||||||
(** Add 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} *)
|
(** {2 Miscellany} *)
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ type args =
|
||||||
mutable makenewid : bool;
|
mutable makenewid : bool;
|
||||||
mutable ismulti : bool;
|
mutable ismulti : bool;
|
||||||
mutable uprightstamp : bool;
|
mutable uprightstamp : bool;
|
||||||
mutable labelstyle : Pdfpagelabels.labelstyle option;
|
mutable labelstyle : Pdfpagelabels.labelstyle;
|
||||||
mutable labelprefix : string option;
|
mutable labelprefix : string option;
|
||||||
mutable labeloffset : int option;
|
mutable labeloffset : int option;
|
||||||
mutable squeeze : bool}
|
mutable squeeze : bool}
|
||||||
|
@ -338,7 +338,7 @@ let args =
|
||||||
makenewid = false;
|
makenewid = false;
|
||||||
ismulti = false;
|
ismulti = false;
|
||||||
uprightstamp = false;
|
uprightstamp = false;
|
||||||
labelstyle = None;
|
labelstyle = Pdfpagelabels.DecimalArabic;
|
||||||
labelprefix = None;
|
labelprefix = None;
|
||||||
labeloffset = None;
|
labeloffset = None;
|
||||||
squeeze = false}
|
squeeze = false}
|
||||||
|
@ -412,7 +412,7 @@ let reset_arguments () =
|
||||||
args.makenewid <- false;
|
args.makenewid <- false;
|
||||||
args.ismulti <- false;
|
args.ismulti <- false;
|
||||||
args.uprightstamp <- false;
|
args.uprightstamp <- false;
|
||||||
args.labelstyle <- None;
|
args.labelstyle <- Pdfpagelabels.DecimalArabic;
|
||||||
args.labelprefix <- None;
|
args.labelprefix <- None;
|
||||||
args.labeloffset <- None;
|
args.labeloffset <- None;
|
||||||
args.squeeze <- false
|
args.squeeze <- false
|
||||||
|
@ -1213,9 +1213,10 @@ let setlabelstyle s =
|
||||||
| "LowercaseRoman" -> Pdfpagelabels.LowercaseRoman
|
| "LowercaseRoman" -> Pdfpagelabels.LowercaseRoman
|
||||||
| "UppercaseLetters" -> Pdfpagelabels.UppercaseLetters
|
| "UppercaseLetters" -> Pdfpagelabels.UppercaseLetters
|
||||||
| "LowercaseLetters" -> Pdfpagelabels.LowercaseLetters
|
| "LowercaseLetters" -> Pdfpagelabels.LowercaseLetters
|
||||||
|
| "NoLabelPrefixOnly" -> Pdfpagelabels.NoLabelPrefixOnly
|
||||||
| _ -> error "Unknown label style"
|
| _ -> error "Unknown label style"
|
||||||
in
|
in
|
||||||
args.labelstyle <- Some style
|
args.labelstyle <- style
|
||||||
|
|
||||||
let setlabelprefix s =
|
let setlabelprefix s =
|
||||||
args.labelprefix <- Some s
|
args.labelprefix <- Some s
|
||||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -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{DecimalArabic} & 1,2,3,4,5\ldots \\
|
||||||
\texttt{LowercaseRoman} & i,ii,iii,iv,v\ldots \\
|
\texttt{LowercaseRoman} & i,ii,iii,iv,v\ldots \\
|
||||||
\texttt{UppercaseRoman} & 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{LowercaseLetters} & a,b,c,\ldots,z,aa,bb\ldots \\
|
||||||
\texttt{UppercaseLetters} & A,B,C,\ldots,Z,AA,AB\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}
|
\end{tabular}
|
||||||
\vspace{4mm}
|
\vspace{4mm}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue