more
This commit is contained in:
parent
2a3afc8f85
commit
3698f0425f
|
@ -3006,7 +3006,7 @@ let collate (names, pdfs, ranges) =
|
||||||
split3 (rev !nis)
|
split3 (rev !nis)
|
||||||
|
|
||||||
let warn_prerotate range pdf =
|
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. \
|
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. \
|
Consider adding -prerotate or pre-processing with -upright. \
|
||||||
To silence this warning use -no-warn-rotate\n%!"
|
To silence this warning use -no-warn-rotate\n%!"
|
||||||
|
@ -3684,6 +3684,7 @@ let go () =
|
||||||
| StandardFont f -> Some f
|
| StandardFont f -> Some f
|
||||||
| OtherFont f -> None (* it's in fontname *)
|
| OtherFont f -> None (* it's in fontname *)
|
||||||
in
|
in
|
||||||
|
warn_prerotate range pdf;
|
||||||
let pdf =
|
let pdf =
|
||||||
if args.prerotate then prerotate range pdf else pdf
|
if args.prerotate then prerotate range pdf else pdf
|
||||||
and filename =
|
and filename =
|
||||||
|
@ -3757,8 +3758,16 @@ let go () =
|
||||||
in
|
in
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| Some (CombinePages over) ->
|
| Some (CombinePages over) ->
|
||||||
write_pdf false
|
let underpdf = get_single_pdf args.op false in
|
||||||
(Cpdfpage.combine_pages args.fast (get_single_pdf args.op false) (pdfread_pdf_of_file None None over) false false true)
|
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 ->
|
| Some Encrypt ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let pdf = Cpdfsqueeze.recompress_pdf pdf
|
let pdf = Cpdfsqueeze.recompress_pdf pdf
|
||||||
|
|
31
cpdfpage.ml
31
cpdfpage.ml
|
@ -131,21 +131,6 @@ let change_boxes f pdf page =
|
||||||
make_mediabox (f (Pdf.parse_rectangle page.Pdfpage.mediabox));
|
make_mediabox (f (Pdf.parse_rectangle page.Pdfpage.mediabox));
|
||||||
Pdfpage.rest = rest'}
|
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 *)
|
(* Scale contents *)
|
||||||
let scale_page_contents ?(fast=false) scale position pdf pnum page =
|
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;
|
Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest;
|
||||||
Pdfpage.prepend_operators pdf [transform_op] ~fast page
|
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 =
|
let upright ?(fast=false) range pdf =
|
||||||
if allupright range pdf then pdf else
|
if allupright range pdf then pdf else
|
||||||
let upright_page _ pnum page =
|
let upright_page _ pnum page =
|
||||||
|
|
Loading…
Reference in New Issue