More apparatus for -stamp-as-xobject
This commit is contained in:
parent
2e8683dfa1
commit
e6afa6e8f2
19
cpdf.ml
19
cpdf.ml
|
@ -2533,10 +2533,23 @@ let stamp relative_to_cropbox position topline midline fast scale_to_fit isover
|
||||||
let new_marks = map (change_bookmark changetable) marks in
|
let new_marks = map (change_bookmark changetable) marks in
|
||||||
Pdfmarks.add_bookmarks new_marks changed
|
Pdfmarks.add_bookmarks new_marks changed
|
||||||
|
|
||||||
let add_page_as_xobject pdf page name =
|
let add_page_as_xobject pdf range page name =
|
||||||
|
let xobject_data = bytes_of_string "0 0 m 0 100 l 100 100 l 100 0 l f" in
|
||||||
|
let xobject_dict =
|
||||||
|
["/Type", Pdf.Name "/XObject";
|
||||||
|
"/Subtype", Pdf.Name "/Form";
|
||||||
|
"/BBox", Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real 1000.; Pdf.Real 1000.];
|
||||||
|
"/Resources", Pdf.Dictionary [];
|
||||||
|
"/Length", Pdf.Integer (bytes_size xobject_data);
|
||||||
|
]
|
||||||
|
in
|
||||||
|
let xobject =
|
||||||
|
Pdf.Stream {contents = (Pdf.Dictionary xobject_dict, Pdf.Got xobject_data)}
|
||||||
|
in
|
||||||
|
let xobject_objnum = Pdf.addobj pdf xobject in
|
||||||
pdf
|
pdf
|
||||||
|
|
||||||
let stamp_as_xobject pdf over =
|
let stamp_as_xobject pdf range over =
|
||||||
let prefix = Pdfpage.shortest_unused_prefix pdf in
|
let prefix = Pdfpage.shortest_unused_prefix pdf in
|
||||||
Pdfpage.add_prefix over prefix;
|
Pdfpage.add_prefix over prefix;
|
||||||
let marks = Pdfmarks.read_bookmarks pdf in
|
let marks = Pdfmarks.read_bookmarks pdf in
|
||||||
|
@ -2573,7 +2586,7 @@ let stamp_as_xobject pdf over =
|
||||||
let new_marks = map (change_bookmark changetable) marks in
|
let new_marks = map (change_bookmark changetable) marks in
|
||||||
let pdf = Pdfmarks.add_bookmarks new_marks changed in
|
let pdf = Pdfmarks.add_bookmarks new_marks changed in
|
||||||
let name = "/X0" in
|
let name = "/X0" in
|
||||||
(add_page_as_xobject pdf over_page name, name)
|
(add_page_as_xobject pdf range over_page name, name)
|
||||||
|
|
||||||
(* Combine pages from two PDFs. For now, assume equal length. *)
|
(* Combine pages from two PDFs. For now, assume equal length. *)
|
||||||
|
|
||||||
|
|
2
cpdf.mli
2
cpdf.mli
|
@ -458,5 +458,5 @@ val ocg_rename : string -> string -> Pdf.t -> unit
|
||||||
|
|
||||||
val ocg_order_all : Pdf.t -> unit
|
val ocg_order_all : Pdf.t -> unit
|
||||||
|
|
||||||
val stamp_as_xobject : Pdf.t -> Pdf.t -> Pdf.t * string
|
val stamp_as_xobject : Pdf.t -> int list -> Pdf.t -> Pdf.t * string
|
||||||
|
|
||||||
|
|
|
@ -4504,8 +4504,9 @@ let go () =
|
||||||
| x -> pdfread_pdf_of_file None None x
|
| x -> pdfread_pdf_of_file None None x
|
||||||
in
|
in
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
|
let range = parse_pagespec pdf (get_pagespec ()) in
|
||||||
let pdf, xobj_name =
|
let pdf, xobj_name =
|
||||||
Cpdf.stamp_as_xobject pdf stamp_pdf
|
Cpdf.stamp_as_xobject pdf range stamp_pdf
|
||||||
in
|
in
|
||||||
Printf.printf "%s\n" xobj_name;
|
Printf.printf "%s\n" xobj_name;
|
||||||
flush stdout;
|
flush stdout;
|
||||||
|
|
Loading…
Reference in New Issue