mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-01-10 16:06:43 +01:00
Add JSON annotations function for cpdflib
This commit is contained in:
parent
4d87a90bdf
commit
844b58f78b
@ -94,6 +94,13 @@ let get_annotations encoding pdf =
|
|||||||
pages
|
pages
|
||||||
(ilist 1 (length pages)))
|
(ilist 1 (length pages)))
|
||||||
|
|
||||||
|
let get_annotations_json pdf =
|
||||||
|
let module J = Cpdfyojson.Safe in
|
||||||
|
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||||
|
let pagenums = indx pages in
|
||||||
|
let json = `List (flatten (map2 (annotations_json_page pdf) pages pagenums)) in
|
||||||
|
Pdfio.bytes_of_string (J.to_string json)
|
||||||
|
|
||||||
(* Equalise the page lengths of two PDFs by chopping or extending the first one.
|
(* Equalise the page lengths of two PDFs by chopping or extending the first one.
|
||||||
*)
|
*)
|
||||||
let equalise_lengths a b =
|
let equalise_lengths a b =
|
||||||
|
@ -6,6 +6,9 @@ val list_annotations : json:bool -> Cpdfmetadata.encoding -> Pdf.t -> unit
|
|||||||
(** Return the annotations as a (pagenumber, content) list *)
|
(** Return the annotations as a (pagenumber, content) list *)
|
||||||
val get_annotations : Cpdfmetadata.encoding -> Pdf.t -> (int * string) list
|
val get_annotations : Cpdfmetadata.encoding -> Pdf.t -> (int * string) list
|
||||||
|
|
||||||
|
(** Get annotations as JSON *)
|
||||||
|
val get_annotations_json : Pdf.t -> Pdfio.bytes
|
||||||
|
|
||||||
(** Copy the annotations on a given set of pages from a to b. b is returned. *)
|
(** Copy the annotations on a given set of pages from a to b. b is returned. *)
|
||||||
val copy_annotations : int list -> Pdf.t -> Pdf.t -> Pdf.t
|
val copy_annotations : int list -> Pdf.t -> Pdf.t -> Pdf.t
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user