Added support for listing bookmarks with full destinations

This commit is contained in:
John Whitington 2017-11-04 14:18:02 +00:00
parent 4eab7ebdd7
commit 51e7689fd1
2 changed files with 13 additions and 4 deletions

13
cpdf.ml
View File

@ -1167,6 +1167,14 @@ let remove_metadata pdf =
rootnum}
(* List bookmarks *)
let output_string_of_target pdf fastrefnums x =
match Pdfdest.pdfobject_of_destination x with
| Pdf.Array (Pdf.Indirect targetobjnum::more) ->
let a =
Pdf.Array (Pdf.Integer (Pdfpage.pagenumber_of_target ~fastrefnums pdf x)::more)
in
"\"" ^ Pdfwrite.string_of_pdf a ^ "\""
| _ -> ""
(* List the bookmarks, optionally deunicoding the text, in the given range to the given output *)
let list_bookmarks encoding range pdf output =
@ -1214,11 +1222,12 @@ let list_bookmarks encoding range pdf output =
iter
(function mark ->
output.Pdfio.output_string
(Printf.sprintf "%i \"%s\" %i %s\n"
(Printf.sprintf "%i \"%s\" %i %s %s\n"
mark.Pdfmarks.level
(process_string mark.Pdfmarks.text)
(Pdfpage.pagenumber_of_target ~fastrefnums pdf mark.Pdfmarks.target)
(if mark.Pdfmarks.isopen then "open" else "")))
(if mark.Pdfmarks.isopen then "open" else "")
(output_string_of_target pdf fastrefnums mark.Pdfmarks.target)))
inrange
(* o is the stamp, u is the main pdf page *)

View File

@ -2,8 +2,8 @@
let demo = false
let noncomp = false
let major_version = 2
let minor_version = 2
let version_date = "(patchlevel 1, build of 1st September 2017)"
let minor_version = 3
let version_date = "(devel, build of 4th November 2017)"
open Pdfutil
open Pdfio