more
This commit is contained in:
parent
cd4060c98e
commit
32e4359a24
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -2736,6 +2736,7 @@ that the media box is unchanged.
|
||||||
\vspace{2.5mm}
|
\vspace{2.5mm}
|
||||||
\noindent Impose a document two-up, keeping the existing page size.
|
\noindent Impose a document two-up, keeping the existing page size.
|
||||||
|
|
||||||
|
\vspace{2.5mm}
|
||||||
\small\verb!cpdf -twoup-stack in.pdf -o out.pdf!
|
\small\verb!cpdf -twoup-stack in.pdf -o out.pdf!
|
||||||
|
|
||||||
\vspace{2.5mm}
|
\vspace{2.5mm}
|
||||||
|
|
65
cpdfpage.ml
65
cpdfpage.ml
|
@ -2,41 +2,36 @@ open Pdfutil
|
||||||
open Cpdferror
|
open Cpdferror
|
||||||
|
|
||||||
(* When we transfor a page by wrapping in an [Op_cm], we must also
|
(* When we transfor a page by wrapping in an [Op_cm], we must also
|
||||||
invert any /Matrix entries in pattern dictionaries, including inside xobjects *)
|
change any /Matrix entries in pattern dictionaries, including inside xobjects *)
|
||||||
let rec change_pattern_matrices_resources pdf tr resources =
|
let rec change_pattern_matrices_resources pdf tr resources =
|
||||||
try
|
begin match Pdf.lookup_direct pdf "/XObject" resources with
|
||||||
begin match Pdf.lookup_direct pdf "/XObject" resources with
|
| Some (Pdf.Dictionary elts) ->
|
||||||
| Some (Pdf.Dictionary elts) ->
|
iter
|
||||||
iter
|
(fun (k, v) ->
|
||||||
(fun (k, v) ->
|
match v with
|
||||||
match v with
|
| Pdf.Indirect i -> change_pattern_matrices_xobject pdf tr k v i
|
||||||
| Pdf.Indirect i -> change_pattern_matrices_xobject pdf tr k v i
|
| _ -> raise (Pdf.PDFError "change_pattern_matrices_page"))
|
||||||
| _ -> raise (Pdf.PDFError "change_pattern_matrices_page"))
|
elts
|
||||||
elts
|
| _ -> ()
|
||||||
| _ -> ()
|
end;
|
||||||
end;
|
begin match Pdf.lookup_direct pdf "/Pattern" resources with
|
||||||
begin match Pdf.lookup_direct pdf "/Pattern" resources with
|
| Some (Pdf.Dictionary patterns) ->
|
||||||
| Some (Pdf.Dictionary patterns) ->
|
let entries =
|
||||||
let entries =
|
map
|
||||||
map
|
(fun (name, p) ->
|
||||||
(fun (name, p) ->
|
Printf.printf "Changing matrices of pattern %s\n" name;
|
||||||
Printf.printf "Changing matrices of pattern %s\n" name;
|
let old_pattern = Pdf.direct pdf p in
|
||||||
let old_pattern = Pdf.direct pdf p in
|
let new_pattern =
|
||||||
let new_pattern =
|
let existing_tr = Pdf.parse_matrix pdf "/Matrix" old_pattern in
|
||||||
let existing_tr = Pdf.parse_matrix pdf "/Matrix" old_pattern in
|
let new_tr = Pdftransform.matrix_compose tr existing_tr in
|
||||||
let new_tr = Pdftransform.matrix_compose tr existing_tr in
|
Pdf.add_dict_entry old_pattern "/Matrix" (Pdf.make_matrix new_tr)
|
||||||
Pdf.add_dict_entry old_pattern "/Matrix" (Pdf.make_matrix new_tr)
|
in
|
||||||
in
|
name, Pdf.Indirect (Pdf.addobj pdf new_pattern))
|
||||||
name, Pdf.Indirect (Pdf.addobj pdf new_pattern))
|
patterns
|
||||||
patterns
|
in
|
||||||
in
|
Pdf.add_dict_entry resources "/Pattern" (Pdf.Dictionary entries)
|
||||||
Pdf.add_dict_entry resources "/Pattern" (Pdf.Dictionary entries)
|
| _ -> resources
|
||||||
| _ -> resources
|
end
|
||||||
end
|
|
||||||
with
|
|
||||||
Pdftransform.NonInvertable ->
|
|
||||||
Printf.eprintf "Warning: noninvertible matrix\n%!";
|
|
||||||
resources
|
|
||||||
|
|
||||||
and change_pattern_matrices_xobject pdf tr k v i =
|
and change_pattern_matrices_xobject pdf tr k v i =
|
||||||
match Pdf.lookup_direct pdf "/Subtype" v with
|
match Pdf.lookup_direct pdf "/Subtype" v with
|
||||||
|
@ -643,7 +638,7 @@ let stamp relative_to_cropbox position topline midline fast scale_to_fit isover
|
||||||
let new_marks = map (Cpdfbookmarks.change_bookmark changetable) marks in
|
let new_marks = map (Cpdfbookmarks.change_bookmark changetable) marks in
|
||||||
Pdfmarks.add_bookmarks new_marks changed
|
Pdfmarks.add_bookmarks new_marks changed
|
||||||
|
|
||||||
(* Combine pages from two PDFs. For now, assume equal length. *)
|
(* Combine pages from two PDFs. For now, assume equal length. FIXME: Why? *)
|
||||||
|
|
||||||
(* If [over] has more pages than [under], chop the excess. If the converse, pad
|
(* If [over] has more pages than [under], chop the excess. If the converse, pad
|
||||||
[over] to the same length *)
|
[over] to the same length *)
|
||||||
|
|
Loading…
Reference in New Issue