more
This commit is contained in:
parent
e1b1950d3b
commit
84453105ba
6
Changes
6
Changes
|
@ -1,7 +1,9 @@
|
||||||
2.5 (Upcoming 2022)
|
2.5 (Upcoming 2022)
|
||||||
|
|
||||||
o -debug-force now properly documented as -decrypt-force
|
o New operation -impose for document imposition
|
||||||
o Switch to Yojson
|
o New option -collate to collate page during merges
|
||||||
|
o Option -debug-force now properly documented as -decrypt-force
|
||||||
|
o Switch to Yojson for faster/better JSON input/output
|
||||||
o Can read as well as write PDFs in JSON format with -j
|
o Can read as well as write PDFs in JSON format with -j
|
||||||
o Environment variable CPDF_REPRODUCIBLE_DATES for testing
|
o Environment variable CPDF_REPRODUCIBLE_DATES for testing
|
||||||
o Environment variable CPDF_DEBUG for -debug
|
o Environment variable CPDF_DEBUG for -debug
|
||||||
|
|
22
cpdf.ml
22
cpdf.ml
|
@ -2860,22 +2860,32 @@ let impose_pages n x y columns rtl btt center margin spacing linewidth mediabox'
|
||||||
|
|
||||||
(* FIXME impose to use cropbox by default? See what happens with cropbox above. Clarify? Also point to hardbox. *)
|
(* FIXME impose to use cropbox by default? See what happens with cropbox above. Clarify? Also point to hardbox. *)
|
||||||
let impose ~x ~y ~fit ~columns ~rtl ~btt ~center ~margin ~spacing ~linewidth ~fast pdf =
|
let impose ~x ~y ~fit ~columns ~rtl ~btt ~center ~margin ~spacing ~linewidth ~fast pdf =
|
||||||
Printf.printf
|
(*Printf.printf
|
||||||
"impose: x = %f, y = %f, fit = %b, columns = %b, rtl = %b, btt = %b, center = %b, margin = %f, spacing = %f, linewidth = %f, fast = %b\n"
|
"impose: x = %f, y = %f, fit = %b, columns = %b, rtl = %b, btt = %b, center = %b, margin = %f, spacing = %f, linewidth = %f, fast = %b\n"
|
||||||
x y fit columns rtl btt center margin spacing linewidth fast;
|
x y fit columns rtl btt center margin spacing linewidth fast;*)
|
||||||
let n = int_of_float x * int_of_float y in
|
let endpage = Pdfpage.endpage pdf in
|
||||||
|
let ix = int_of_float x in
|
||||||
|
let iy = int_of_float y in
|
||||||
|
let n, ix, iy =
|
||||||
|
if ix = 0 && iy = 0 then error "impose-xy: both dimensions cannot be zero" else
|
||||||
|
if ix = 0 then (endpage, endpage, 1)
|
||||||
|
else if iy = 0 then (endpage, 1, endpage)
|
||||||
|
else (ix * iy, ix, iy)
|
||||||
|
in
|
||||||
let firstpage = hd (Pdfpage.pages_of_pagetree pdf) in
|
let firstpage = hd (Pdfpage.pages_of_pagetree pdf) in
|
||||||
let mediabox' =
|
let mediabox' =
|
||||||
if fit then Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real x; Pdf.Real y] else
|
if fit then Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real x; Pdf.Real y] else
|
||||||
let _, _, w, h = Pdf.parse_rectangle firstpage.Pdfpage.mediabox in
|
let _, _, w, h = Pdf.parse_rectangle firstpage.Pdfpage.mediabox in
|
||||||
Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real (w *. x); Pdf.Real (h *. y)]
|
if x = 0.0 then Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real (w *. float_of_int endpage); Pdf.Real h]
|
||||||
|
else if y = 0.0 then Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real w; Pdf.Real (h *. float_of_int endpage)]
|
||||||
|
else Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real (w *. x); Pdf.Real (h *. y)]
|
||||||
in
|
in
|
||||||
let pagenums = ilist 1 (Pdfpage.endpage pdf) in
|
let pagenums = ilist 1 endpage in
|
||||||
let pdf = upright pagenums pdf in
|
let pdf = upright pagenums pdf in
|
||||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||||
let pagesets = splitinto n pages in
|
let pagesets = splitinto n pages in
|
||||||
let renumbered = map (Pdfpage.renumber_pages pdf) pagesets in
|
let renumbered = map (Pdfpage.renumber_pages pdf) pagesets in
|
||||||
let pages' = map (impose_pages n x y columns rtl btt center margin spacing linewidth mediabox' fast pdf) renumbered in
|
let pages' = map (impose_pages n (float_of_int ix) (float_of_int iy) columns rtl btt center margin spacing linewidth mediabox' fast pdf) renumbered in
|
||||||
let changes = map (fun x -> (x, (x + (n - 1)) / n)) pagenums in
|
let changes = map (fun x -> (x, (x + (n - 1)) / n)) pagenums in
|
||||||
Pdfpage.change_pages ~changes true pdf pages'
|
Pdfpage.change_pages ~changes true pdf pages'
|
||||||
|
|
||||||
|
|
|
@ -4033,6 +4033,7 @@ let go () =
|
||||||
| Some Impose fit ->
|
| Some Impose fit ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let x, y = Cpdfcoord.parse_coordinate pdf args.coord in
|
let x, y = Cpdfcoord.parse_coordinate pdf args.coord in
|
||||||
|
if not fit && (x < 0.0 || y < 0.0) then error "Negative imposition parameters not allowed." else
|
||||||
write_pdf false
|
write_pdf false
|
||||||
(Cpdf.impose x y fit args.impose_columns args.impose_rtl args.impose_btt args.impose_center
|
(Cpdf.impose x y fit args.impose_columns args.impose_rtl args.impose_btt args.impose_center
|
||||||
args.impose_margin args.impose_spacing args.impose_linewidth args.fast pdf)
|
args.impose_margin args.impose_spacing args.impose_linewidth args.fast pdf)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%Document the new JSON format, -j and new -output-json options
|
%Document the new JSON format, -j and new -output-json options
|
||||||
%Document -decrypt-force
|
%Document -decrypt-force
|
||||||
%Document -collate
|
%Document -collate
|
||||||
%Document -impose and friends
|
%Document -impose and friends (inc. 0-w, 0-h for long ones)
|
||||||
|
|
||||||
\documentclass{book}
|
\documentclass{book}
|
||||||
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf etc.
|
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf etc.
|
||||||
|
|
Loading…
Reference in New Issue