diff --git a/cpdf.ml b/cpdf.ml index b883ea6..cc5e978 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -2389,10 +2389,13 @@ let select_pages range pdf = (* Upright functionality *) -(* If all pages are already upright, do nothing to save time. *) +(* If all pages are already upright, and the mediabox is (0,0)-based, do nothing +to save time. *) let allupright range pdf = let page_is_upright page = - page.Pdfpage.rotate = Pdfpage.Rotate0 + page.Pdfpage.rotate = Pdfpage.Rotate0 && + (let (minx, miny, _, _) = Pdf.parse_rectangle page.Pdfpage.mediabox in + minx < 0.001 && miny < 0.001 && minx > ~-.0.001 && miny > ~-.0.001) in not (mem false (map page_is_upright (select_pages range pdf))) diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index 0ac3669..62919e9 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 6798304..f3fd82f 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -792,7 +792,7 @@ ninety degrees clockwise. Does not change the page dimensions. \label{upright} \noindent The \texttt{-upright} operation does whatever combination of \texttt{-rotate} and \texttt{-rotate-contents} is required to change the -rotation of the document to zero without altering its appearance. +rotation of the document to zero without altering its appearance. In addition, it makes sure the media box has its origin at (0,0), changing other boxes to compensate. \section{Flipping Pages} \index{flip pages}