diff --git a/Changes b/Changes index 54022f6..f8f2aa9 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Version 2.4 (to come) o Vendored in tiny_json from Yoshihiro Imai via Jan Furuse +o New -labels-progress option to improve page labels interface Version 2.3 (patchlevel 1, December 2019) diff --git a/cpdf.ml b/cpdf.ml index 5deba24..376cbfe 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -4174,6 +4174,10 @@ let page1 labels = let add_page_labels pdf progress style prefix startval range = let ranges = map extremes (ranges_of_range [] [] range) and labels = Pdfpagelabels.read pdf in + assert (length ranges > 0); + let startval_additions = + 0 :: map (fun x -> x - fst (List.hd ranges) - 1) (List.tl (List.map fst ranges)) + in let labels = if not (page1 labels) then ref @@ -4184,16 +4188,17 @@ let add_page_labels pdf progress style prefix startval range = else ref labels in - iter - (function (s, e) -> + iter2 + (fun (s, e) addition -> let label = {Pdfpagelabels.labelstyle = style; Pdfpagelabels.labelprefix = prefix; Pdfpagelabels.startpage = s; - Pdfpagelabels.startvalue = startval} + Pdfpagelabels.startvalue = startval + addition} in labels := Pdfpagelabels.add_label (Pdfpage.endpage pdf) !labels label e) - ranges; + ranges + startval_additions; Pdfpagelabels.write pdf !labels (* Parse the new content to make sure syntactically ok, append diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index c4c811e..d9eecb7 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 638a338..93a0042 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -34,7 +34,7 @@ Command Line Toolkit} \vspace{12mm} {\Huge User Manual}\\ -Version 2.3 (October 2019) +Version 2.4 (? 2020) \vspace{25mm} @@ -58,7 +58,7 @@ Version 2.3 (October 2019) \noindent For bug reports, feature requests and comments, email\\ \texttt{contact@coherentgraphics.co.uk} \vspace*{\fill} -\noindent\copyright 2019 Coherent Graphics Limited. All rights reserved. ISBN 978-0957671140 +\noindent\copyright 2020 Coherent Graphics Limited. All rights reserved. ISBN 978-0957671140 \smallgap \noindent Adobe, Acrobat, Adobe PDF, Adobe Reader and PostScript are @@ -1828,7 +1828,7 @@ given page range. \vspace{1.5mm} \small\noindent\verb!cpdf -add-page-labels in.pdf -o out.pdf!\\ \noindent\verb! [-label-style