Bookmark @B on splitting now dowes utf8, raw

This commit is contained in:
John Whitington 2019-07-07 12:55:15 +01:00
parent 9f981fb344
commit 2b8a334190
1 changed files with 14 additions and 13 deletions

View File

@ -2600,18 +2600,19 @@ let write_pdf ?(encryption = None) ?(is_decompress=false) mk_id pdf =
(* Returns empty string on failure. Should only be used in conjunction with (* Returns empty string on failure. Should only be used in conjunction with
split at bookmarks code, so should never fail, by definiton. *) split at bookmarks code, so should never fail, by definiton. *)
let remove_unsafe_characters s = let remove_unsafe_characters s =
let chars = if args.encoding = Cpdf.Raw then s else
lose let chars =
(function x -> lose
match x with (function x ->
'/' | '?' | '<' | '>' | '\\' | ':' | '*' | '|' | '\"' | '^' | '+' | '=' -> true match x with
| x when int_of_char x < 32 || int_of_char x > 126 -> true '/' | '?' | '<' | '>' | '\\' | ':' | '*' | '|' | '\"' | '^' | '+' | '=' -> true
| _ -> false) | x when int_of_char x < 32 || (int_of_char x > 126 && args.encoding <> Cpdf.Stripped) -> true
(explode s) | _ -> false)
in (explode s)
match chars with in
| '.'::more -> implode more match chars with
| chars -> implode chars | '.'::more -> implode more
| chars -> implode chars
let get_bookmark_name pdf marks splitlevel n _ = let get_bookmark_name pdf marks splitlevel n _ =
let refnums = Pdf.page_reference_numbers pdf in let refnums = Pdf.page_reference_numbers pdf in
@ -3503,7 +3504,7 @@ let bookmarks_open_to_level n pdf =
let marks = Pdfmarks.read_bookmarks pdf in let marks = Pdfmarks.read_bookmarks pdf in
let newmarks = let newmarks =
List.map List.map
(fun m -> {m with Pdfmarks.isopen = true(*m.Pdfmarks.level < n*)}) (fun m -> {m with Pdfmarks.isopen = m.Pdfmarks.level < n})
marks marks
in in
Pdfmarks.add_bookmarks newmarks pdf Pdfmarks.add_bookmarks newmarks pdf