roundtripping of bookmarks done

This commit is contained in:
John Whitington 2019-07-07 14:20:43 +01:00
parent 2b8a334190
commit 3ec1628d7a
2 changed files with 8 additions and 7 deletions

14
cpdf.ml
View File

@ -1018,12 +1018,12 @@ let bookmark_of_data pdf i s i' isopen optionaldest =
None -> None ->
raise (Pdf.PDFError "bookmark_of_data: page obj num not found") raise (Pdf.PDFError "bookmark_of_data: page obj num not found")
| Some p -> | Some p ->
Pdfdest.read_destination Pdfdest.read_destination pdf (Pdf.Array (Pdf.Indirect p::more))
(Pdf.empty ())
(Pdf.Array (Pdf.Indirect p::more))
end end
| _ -> (* Need to deal with "null", "(string)", and "<<other thing like action" *)
raise (Pdf.PDFError "bookmark_of_data: dest") | Pdf.Null -> Pdfdest.NullDestination
| Pdf.String s -> Pdfdest.read_destination pdf (Pdf.String s)
| x -> Pdfdest.Action x
end end
| _ -> Pdfpage.target_of_pagenumber pdf i' | _ -> Pdfpage.target_of_pagenumber pdf i'
in in
@ -1296,11 +1296,11 @@ let list_bookmarks encoding range pdf output =
iter iter
(function mark -> (function mark ->
output.Pdfio.output_string output.Pdfio.output_string
(Printf.sprintf "%i \"%s\" %i %s %s\n" (Printf.sprintf "%i \"%s\" %i%s %s\n"
mark.Pdfmarks.level mark.Pdfmarks.level
(process_string mark.Pdfmarks.text) (process_string mark.Pdfmarks.text)
(calculate_page_number mark) (calculate_page_number mark)
(if mark.Pdfmarks.isopen then "open" else "") (if mark.Pdfmarks.isopen then " open" else "")
(output_string_of_target pdf fastrefnums mark.Pdfmarks.target))) (output_string_of_target pdf fastrefnums mark.Pdfmarks.target)))
inrange inrange

View File

@ -22,6 +22,7 @@
%FIXME: Document -gs gs -gs-embed-fonts %FIXME: Document -gs gs -gs-embed-fonts
%FIXME: Document -merge-add-bookmarks, -merge-add-bookmarks-use-titles %FIXME: Document -merge-add-bookmarks, -merge-add-bookmarks-use-titles
%FIXME: Document -bookmarks-open-to-level <n> %FIXME: Document -bookmarks-open-to-level <n>
%FIXME: Explain in key places that you probably want UTF8 a lot
\documentclass{book} \documentclass{book}
\usepackage{palatino} \usepackage{palatino}