mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-04-15 10:48:00 +02:00
more
This commit is contained in:
parent
0aa141d908
commit
e74f0c32d3
16
cpdftweak.ml
16
cpdftweak.ml
@ -231,9 +231,6 @@ let append_page_content_page fast s before pdf n page =
|
|||||||
let append_page_content s before fast range pdf =
|
let append_page_content s before fast range pdf =
|
||||||
Cpdfpage.process_pages (Cpdfutil.ppstub (append_page_content_page fast s before pdf)) pdf range
|
Cpdfpage.process_pages (Cpdfutil.ppstub (append_page_content_page fast s before pdf)) pdf range
|
||||||
|
|
||||||
|
|
||||||
(* 1. Extend remove_dict_entry with search term
|
|
||||||
2. Implement replace_dict_entry by analogy to remove_dict_entry *)
|
|
||||||
let rec dict_entry_single_object f pdf = function
|
let rec dict_entry_single_object f pdf = function
|
||||||
| (Pdf.Dictionary d) -> f (Pdf.recurse_dict (dict_entry_single_object f pdf) d)
|
| (Pdf.Dictionary d) -> f (Pdf.recurse_dict (dict_entry_single_object f pdf) d)
|
||||||
| (Pdf.Stream {contents = (Pdf.Dictionary dict, data)}) ->
|
| (Pdf.Stream {contents = (Pdf.Dictionary dict, data)}) ->
|
||||||
@ -279,6 +276,19 @@ let print_dict_entry pdf key =
|
|||||||
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
||||||
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict
|
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict
|
||||||
|
|
||||||
|
(* For cpdflib. *)
|
||||||
|
let get_dict_entries pdf key =
|
||||||
|
let es = ref [] in
|
||||||
|
let f d =
|
||||||
|
match Pdf.lookup_direct pdf key d with
|
||||||
|
| Some v -> es := Cpdfjson.json_of_object ~clean_strings:true pdf (fun _ -> ()) false false v::!es; d
|
||||||
|
| None -> d
|
||||||
|
in
|
||||||
|
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
||||||
|
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict;
|
||||||
|
let arr = `List (rev !es) in
|
||||||
|
(Pdfio.bytes_of_string (Cpdfyojson.Safe.to_string arr))
|
||||||
|
|
||||||
let remove_clipping_ops pdf resources content =
|
let remove_clipping_ops pdf resources content =
|
||||||
let ops = Pdfops.parse_operators pdf resources content in
|
let ops = Pdfops.parse_operators pdf resources content in
|
||||||
let rec process a = function
|
let rec process a = function
|
||||||
|
@ -24,6 +24,9 @@ val replace_dict_entry : Pdf.t -> string -> Pdf.pdfobject -> Pdf.pdfobject optio
|
|||||||
(** Print a dictionary entry. *)
|
(** Print a dictionary entry. *)
|
||||||
val print_dict_entry : Pdf.t -> string -> unit
|
val print_dict_entry : Pdf.t -> string -> unit
|
||||||
|
|
||||||
|
(** Get dictionary entries in JSON format *)
|
||||||
|
val get_dict_entries : Pdf.t -> string -> Pdfio.bytes
|
||||||
|
|
||||||
(** Remove clipping. *)
|
(** Remove clipping. *)
|
||||||
val remove_clipping : Pdf.t -> int list -> Pdf.t
|
val remove_clipping : Pdf.t -> int list -> Pdf.t
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user