Better combine_resources

This commit is contained in:
John Whitington 2016-04-03 19:51:47 +01:00
parent f7bdca371b
commit 6feb3082aa
1 changed files with 7 additions and 8 deletions

15
cpdf.ml
View File

@ -621,15 +621,14 @@ let combine_pdf_resources pdf a b =
| Some (Pdf.Dictionary d) -> d
| _ -> []
in
key, Pdf.Dictionary (a_entries @ b_entries)
in
let unknown_keys_a =
lose (fun (k, _) -> mem k resource_keys) a_entries
in let unknown_keys_b =
lose (fun (k, _) -> mem k resource_keys) b_entries
in let combined_known_entries =
map combine_entries resource_keys
if a_entries = [] && b_entries = [] then
None
else
Some (key, Pdf.Dictionary (a_entries @ b_entries))
in
let unknown_keys_a = lose (fun (k, _) -> mem k resource_keys) a_entries in
let unknown_keys_b = lose (fun (k, _) -> mem k resource_keys) b_entries in
let combined_known_entries = option_map combine_entries resource_keys in
Pdf.Dictionary (unknown_keys_a @ unknown_keys_b @ combined_known_entries)
(* \section{Build PDF Presentations} *)