diff --git a/cpdfdraw.ml b/cpdfdraw.ml index 0bf0b8d..4becb96 100644 --- a/cpdfdraw.ml +++ b/cpdfdraw.ml @@ -435,9 +435,14 @@ let draw ?(fast=false) ?(underneath=false) ~filename ~bates ~batespad range pdf if hd !chunks <> [] then pdf := draw_single ~fast ~underneath ~filename ~bates ~batespad fast !range !pdf (hd !chunks); chunks := tl !chunks; if !chunks <> [] then begin + (* If the range is just a single page, and there is a next page, move to it. Otherwise, + add a blank page at the end of the document. *) let endpage = Pdfpage.endpage !pdf in - pdf := Cpdfpad.padafter [endpage] !pdf; - range := [endpage + 1] + match !range with + | [x] when endpage > x -> range := [x + 1] + | _ -> + pdf := Cpdfpad.padafter [endpage] !pdf; + range := [endpage + 1] end done; !pdf diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index 5a39437..8919b4a 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index c18b0ef..c13fc8c 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -4619,7 +4619,7 @@ NB: To use \texttt{-embed-std14}, put it before \texttt{-draw}. \noindent\verb!-newpage! Move to a fresh page \end{framed}} -The drawing operation \texttt{-newpage} creates a fresh page of the same dimensions as the last page of the document, and sets the drawing range to just that page. For example: +If the drawing range is a single page, and the next page already exists, the drawing operation \texttt{-newpage} operation moves to the next page. Otherwise, it creates a fresh page of the same dimensions as the last page of the document, and sets the drawing range to just that page. For example: \begin{framed} \noindent\small\verb?cpdf -create-pdf AND -draw -bt -text "Page 1" -et?\\