Work on making -scale-to-fit / nonzero box origins
This commit is contained in:
parent
128f9361ff
commit
66c42fc621
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -1465,7 +1465,7 @@ Y factors given. This scales both the page contents, and the page size itself. I
|
|||
\noindent Scale a file's pages to fit A4 portrait, scaling the page 90\% of its possible size.
|
||||
\end{framed}
|
||||
|
||||
\noindent NB: \texttt{-scale-to-fit} operates with respect to the media box not the crop box. If necessary, set the media box to be equal to the crop box first. In addition, \texttt{-scale-to-fit} presently requires that the origin of the media box be (0, 0). This can be assured by preprocessing with \texttt{-upright} (described elsewhere in this chapter) or by adding the \texttt{-prerotate} option to the command.
|
||||
\noindent NB: \texttt{-scale-to-fit} presently requires that the origin of the media box be (0, 0). This can be assured by preprocessing with \texttt{-upright} (described elsewhere in this chapter) or by adding the \texttt{-prerotate} option to the command.
|
||||
|
||||
The \texttt{-scale-contents} operation scales the contents about the center
|
||||
of the crop box (or, if absent, the media box), leaving the page dimensions
|
||||
|
|
|
@ -517,7 +517,6 @@ let scale_to_fit_pdf ?(fast=false) position input_scale xylist op pdf range =
|
|||
let x, y = List.nth xylist (pnum - 1) in
|
||||
let matrix =
|
||||
let (minx, miny, maxx, maxy) =
|
||||
(* Use cropbox if available *)
|
||||
Pdf.parse_rectangle
|
||||
pdf
|
||||
(match Pdf.lookup_direct pdf "/CropBox" page.Pdfpage.rest with
|
||||
|
@ -525,7 +524,7 @@ let scale_to_fit_pdf ?(fast=false) position input_scale xylist op pdf range =
|
|||
| None -> page.Pdfpage.mediabox)
|
||||
in
|
||||
if maxx <= 0. || maxy <= 0. then failwith "Zero-sized pages are invalid" else
|
||||
let fx = x /. maxx in let fy = y /. maxy in
|
||||
let fx = x /. (maxx -. minx) in let fy = y /. (maxy -. miny) in
|
||||
let scale = fmin fx fy *. input_scale in
|
||||
let trans_x =
|
||||
match position with
|
||||
|
@ -538,8 +537,11 @@ let scale_to_fit_pdf ?(fast=false) position input_scale xylist op pdf range =
|
|||
| Cpdfposition.Bottom _ -> 0.
|
||||
| _ -> (y -. (maxy *. scale)) /. 2.
|
||||
in
|
||||
let fixup_trans_x = -. (minx *. scale) /. 2. in
|
||||
let fixup_trans_y = -. (miny *. scale) /. 2. in
|
||||
(Pdftransform.matrix_of_transform
|
||||
[Pdftransform.Translate (trans_x, trans_y);
|
||||
[Pdftransform.Translate (fixup_trans_x, fixup_trans_y);
|
||||
Pdftransform.Translate (trans_x, trans_y);
|
||||
Pdftransform.Scale ((0., 0.), scale, scale)])
|
||||
in
|
||||
let page =
|
||||
|
|
Loading…
Reference in New Issue