diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 21dc41e..ccebf63 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -3006,7 +3006,7 @@ let collate (names, pdfs, ranges) = split3 (rev !nis) let warn_prerotate range pdf = - if not (Cpdfpage.allupright range pdf) then + if not args.prerotate && not (Cpdfpage.allupright range pdf) then Printf.eprintf "Some pages in the range have non-zero rotation or non (0,0)-based mediabox. \ Consider adding -prerotate or pre-processing with -upright. \ To silence this warning use -no-warn-rotate\n%!" @@ -3684,6 +3684,7 @@ let go () = | StandardFont f -> Some f | OtherFont f -> None (* it's in fontname *) in + warn_prerotate range pdf; let pdf = if args.prerotate then prerotate range pdf else pdf and filename = @@ -3757,8 +3758,16 @@ let go () = in write_pdf false pdf | Some (CombinePages over) -> - write_pdf false - (Cpdfpage.combine_pages args.fast (get_single_pdf args.op false) (pdfread_pdf_of_file None None over) false false true) + let underpdf = get_single_pdf args.op false in + let overpdf = pdfread_pdf_of_file None None over in + warn_prerotate (parse_pagespec underpdf "all") underpdf; + warn_prerotate (parse_pagespec overpdf "all") overpdf; + write_pdf false + (Cpdfpage.combine_pages + args.fast + (prerotate (parse_pagespec underpdf "all") underpdf) + (prerotate (parse_pagespec overpdf "all") overpdf) + false false true) | Some Encrypt -> let pdf = get_single_pdf args.op false in let pdf = Cpdfsqueeze.recompress_pdf pdf diff --git a/cpdfpage.ml b/cpdfpage.ml index 37379c2..1eaff82 100644 --- a/cpdfpage.ml +++ b/cpdfpage.ml @@ -131,21 +131,6 @@ let change_boxes f pdf page = make_mediabox (f (Pdf.parse_rectangle page.Pdfpage.mediabox)); Pdfpage.rest = rest'} -(* Change a page's media box so its minimum x and y are 0, making other -operations simpler to think about. Any shift that is done is reflected in -other boxes (clip etc.) *) -let rectify_boxes ?(fast=false) pdf page = - let minx, miny, _, _ = - Pdf.parse_rectangle page.Pdfpage.mediabox - in - let f (iminx, iminy, imaxx, imaxy) = - iminx -. minx, iminy -. miny, imaxx -. minx, imaxy -. miny - in - let page = change_boxes f pdf page in - if minx <> 0. || miny <> 0. - then - begin let p, _, _ = shift_page ~fast [(-.minx),(-.miny)] pdf 1 page in p end - else page (* Scale contents *) let scale_page_contents ?(fast=false) scale position pdf pnum page = @@ -277,6 +262,22 @@ let transform_contents ?(fast=false) tr pdf page = Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest; Pdfpage.prepend_operators pdf [transform_op] ~fast page +(* Change a page's media box so its minimum x and y are 0, making other +operations simpler to think about. Any shift that is done is reflected in +other boxes (clip etc.) *) +let rectify_boxes ?(fast=false) pdf page = + let minx, miny, _, _ = + Pdf.parse_rectangle page.Pdfpage.mediabox + in + let f (iminx, iminy, imaxx, imaxy) = + iminx -. minx, iminy -. miny, imaxx -. minx, imaxy -. miny + in + let page = change_boxes f pdf page in + if minx <> 0. || miny <> 0. + then + begin let p, _, _ = shift_page ~fast [(-.minx),(-.miny)] pdf 1 page in p end + else page + let upright ?(fast=false) range pdf = if allupright range pdf then pdf else let upright_page _ pnum page =