Code for cpdflib

This commit is contained in:
John Whitington 2022-01-16 18:39:42 +00:00
parent 844b58f78b
commit c263b807ad
2 changed files with 7 additions and 1 deletions

View File

@ -262,7 +262,10 @@ let list_bookmarks ~json encoding range pdf output =
(output_string_of_target pdf fastrefnums mark.Pdfmarks.target))) (output_string_of_target pdf fastrefnums mark.Pdfmarks.target)))
inrange inrange
(* o is the stamp, u is the main pdf page *) let get_bookmarks_json pdf =
let o, br = Pdfio.input_output_of_bytes (20 * 1024) in
list_bookmarks ~json:true Cpdfmetadata.UTF8 (ilist 1 (Pdfpage.endpage pdf)) pdf o;
Pdfio.extract_bytes_from_input_output o br
(* Split at bookmarks *) (* Split at bookmarks *)

View File

@ -14,6 +14,9 @@ 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 -> Cpdfmetadata.encoding -> int list -> Pdf.t -> Pdfio.output -> unit
(** Get bookmarks in JSON format. *)
val get_bookmarks_json : Pdf.t -> Pdfio.bytes
(** [name_of_spec encoding marks pdf splitlevel spec n filename startpage (** [name_of_spec encoding marks pdf splitlevel spec n filename startpage
endpage] expands a bookmark specifiation filename. *) endpage] expands a bookmark specifiation filename. *)
val name_of_spec : Cpdfmetadata.encoding -> val name_of_spec : Cpdfmetadata.encoding ->