mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
Plumb through -preserve-actions
This commit is contained in:
@ -218,8 +218,8 @@ let process_string encoding s =
|
|||||||
| Cpdfmetadata.Raw -> s
|
| Cpdfmetadata.Raw -> s
|
||||||
|
|
||||||
(* List the bookmarks in the given range to the given output *)
|
(* List the bookmarks in the given range to the given output *)
|
||||||
let list_bookmarks ~json encoding range pdf output =
|
let list_bookmarks ~json ~json_preserve_actions encoding range pdf output =
|
||||||
let bookmarks = Pdfmarks.read_bookmarks ~preserve_actions:false pdf in
|
let bookmarks = Pdfmarks.read_bookmarks ~preserve_actions:(json && json_preserve_actions) pdf in
|
||||||
let refnums = Pdf.page_reference_numbers pdf in
|
let refnums = Pdf.page_reference_numbers pdf in
|
||||||
let rangetable = hashset_of_list range in
|
let rangetable = hashset_of_list range in
|
||||||
let range_is_all = range = ilist 1 (Pdfpage.endpage pdf) in
|
let range_is_all = range = ilist 1 (Pdfpage.endpage pdf) in
|
||||||
|
@ -12,7 +12,7 @@ val add_bookmarks : json:bool -> bool -> Pdfio.input -> Pdf.t -> Pdf.t
|
|||||||
(** [list_bookmarks encoding range pdf output] lists the bookmarks to the given
|
(** [list_bookmarks encoding range pdf output] lists the bookmarks to the given
|
||||||
output in the format specified in cpdfmanual.pdf. In the new JSON format if
|
output in the format specified in cpdfmanual.pdf. In the new JSON format if
|
||||||
chosen. *)
|
chosen. *)
|
||||||
val list_bookmarks : json:bool -> Cpdfmetadata.encoding -> int list -> Pdf.t -> Pdfio.output -> unit
|
val list_bookmarks : json:bool -> json_preserve_actions:bool -> Cpdfmetadata.encoding -> int list -> Pdf.t -> Pdfio.output -> unit
|
||||||
|
|
||||||
(** Get bookmarks in JSON format. *)
|
(** Get bookmarks in JSON format. *)
|
||||||
val get_bookmarks_json : Pdf.t -> Pdfio.bytes
|
val get_bookmarks_json : Pdf.t -> Pdfio.bytes
|
||||||
|
@ -576,7 +576,8 @@ type args =
|
|||||||
mutable rast_downsample : bool;
|
mutable rast_downsample : bool;
|
||||||
mutable replace_stream_with : string;
|
mutable replace_stream_with : string;
|
||||||
mutable output_unit : Pdfunits.t;
|
mutable output_unit : Pdfunits.t;
|
||||||
mutable dot_leader : bool}
|
mutable dot_leader : bool;
|
||||||
|
mutable preserve_actions : bool}
|
||||||
|
|
||||||
let args =
|
let args =
|
||||||
{op = None;
|
{op = None;
|
||||||
@ -726,7 +727,8 @@ let args =
|
|||||||
rast_downsample = false;
|
rast_downsample = false;
|
||||||
replace_stream_with = "";
|
replace_stream_with = "";
|
||||||
output_unit = Pdfunits.PdfPoint;
|
output_unit = Pdfunits.PdfPoint;
|
||||||
dot_leader = false}
|
dot_leader = false;
|
||||||
|
preserve_actions = false}
|
||||||
|
|
||||||
(* Do not reset original_filename or cpdflin or was_encrypted or
|
(* Do not reset original_filename or cpdflin or was_encrypted or
|
||||||
was_decrypted_with_owner or recrypt or producer or creator or path_to_* or
|
was_decrypted_with_owner or recrypt or producer or creator or path_to_* or
|
||||||
@ -862,7 +864,8 @@ let reset_arguments () =
|
|||||||
args.rast_downsample <- false;
|
args.rast_downsample <- false;
|
||||||
args.replace_stream_with <- "";
|
args.replace_stream_with <- "";
|
||||||
args.output_unit <- Pdfunits.PdfPoint;
|
args.output_unit <- Pdfunits.PdfPoint;
|
||||||
args.dot_leader <- false
|
args.dot_leader <- false;
|
||||||
|
args.preserve_actions <- false
|
||||||
|
|
||||||
(* Prefer a) the one given with -cpdflin b) a local cpdflin, c) otherwise assume
|
(* Prefer a) the one given with -cpdflin b) a local cpdflin, c) otherwise assume
|
||||||
installed at a system place *)
|
installed at a system place *)
|
||||||
@ -2281,6 +2284,9 @@ let specs =
|
|||||||
("-list-bookmarks-json",
|
("-list-bookmarks-json",
|
||||||
Arg.Unit setlistbookmarksjson,
|
Arg.Unit setlistbookmarksjson,
|
||||||
" List Bookmarks in JSON format");
|
" List Bookmarks in JSON format");
|
||||||
|
("-preserve-actions",
|
||||||
|
Arg.Unit (fun () -> args.preserve_actions <- true),
|
||||||
|
" Preserve actions when listing bookmarks");
|
||||||
("-remove-bookmarks",
|
("-remove-bookmarks",
|
||||||
Arg.Unit (setop RemoveBookmarks),
|
Arg.Unit (setop RemoveBookmarks),
|
||||||
" Remove bookmarks from a file");
|
" Remove bookmarks from a file");
|
||||||
@ -3985,7 +3991,7 @@ let go () =
|
|||||||
| (_, pagespec, _, _, _, _)::_, _ ->
|
| (_, pagespec, _, _, _, _)::_, _ ->
|
||||||
let pdf = get_single_pdf args.op true in
|
let pdf = get_single_pdf args.op true in
|
||||||
let range = parse_pagespec_allow_empty pdf pagespec in
|
let range = parse_pagespec_allow_empty pdf pagespec in
|
||||||
Cpdfbookmarks.list_bookmarks ~json:args.format_json args.encoding range pdf (Pdfio.output_of_channel stdout);
|
Cpdfbookmarks.list_bookmarks ~json:args.format_json ~json_preserve_actions:args.preserve_actions args.encoding range pdf (Pdfio.output_of_channel stdout);
|
||||||
flush stdout
|
flush stdout
|
||||||
| _ -> error "list-bookmarks: bad command line"
|
| _ -> error "list-bookmarks: bad command line"
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user