Refine upright warning

This commit is contained in:
John Whitington 2024-01-24 18:40:20 +00:00
parent 8b9a2c70ac
commit b2d931da18
4 changed files with 13 additions and 2 deletions

View File

@ -3381,8 +3381,8 @@ let collate (names, pdfs, ranges) =
split3 (rev !nis)
let warn_prerotate range pdf =
if not args.prerotate && not (Cpdfpage.allupright range pdf) then
Pdfe.log "Some pages in the range have non-zero rotation or non (0,0)-based mediabox. \
if not args.prerotate && not (Cpdfpage.alluprightonly range pdf) then
Pdfe.log "Some pages in the range have non-zero rotation. \
Consider adding -prerotate or pre-processing with -upright. \
To silence this warning use -no-warn-rotate\n"

View File

@ -17,6 +17,8 @@
%Document -obj - check enc
%Document -merge-no-struct-trees in merge and collate
%Document -shift-boxes
%Document that -scale-to-fit prefers the cropbox
%Document in -scale-to-fit that hardbox exists
%Document that -scale-to-fit may have -top bottom left right
\documentclass{book}
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,

View File

@ -409,6 +409,12 @@ let allupright range pdf =
in
not (mem false (map page_is_upright (select_pages range pdf)))
(* Same, but don't care about mediabox origin. This is for -scale-to-fit, now that
it is ok with nonzero origins. *)
let alluprightonly range pdf =
let page_is_upright page = page.Pdfpage.rotate = Pdfpage.Rotate0 in
not (mem false (map page_is_upright (select_pages range pdf)))
let upright_transform pdf page =
let rotate =
Pdfpage.int_of_rotation page.Pdfpage.rotate

View File

@ -116,5 +116,8 @@ val copy_box : string -> string -> bool -> Pdf.t -> int list -> Pdf.t
(** True if all pages are "upright" i.e no rotation and (0,0)-based. *)
val allupright : int list -> Pdf.t -> bool
(** True if all pages are "upright" i.e no rotation. *)
val alluprightonly : int list -> Pdf.t -> bool
(** When a page is transformed, its patterns must be too. *)
val change_pattern_matrices_page : Pdf.t -> Pdftransform.transform_matrix -> Pdfpage.t -> Pdfpage.t