Compressed and Encrypted metadata now dealt with ok
This commit is contained in:
parent
e3f2006c92
commit
19b9d56c5a
2
cpdf.ml
2
cpdf.ml
|
@ -1285,7 +1285,7 @@ let get_metadata pdf =
|
|||
| Some root ->
|
||||
match Pdf.lookup_direct pdf "/Metadata" root with
|
||||
| Some ((Pdf.Stream _) as s) ->
|
||||
Pdf.getstream s;
|
||||
Pdfcodec.decode_pdfstream pdf s;
|
||||
begin match s with
|
||||
| Pdf.Stream {contents = (_, Pdf.Got data)} -> Some data
|
||||
| _ -> assert false
|
||||
|
|
|
@ -545,11 +545,13 @@ let rec decrypt_if_necessary (_, _, _, user_pw, owner_pw) op pdf =
|
|||
end;
|
||||
if not (Pdfcrypt.is_encrypted pdf) then pdf else
|
||||
match Pdfcrypt.decrypt_pdf_owner owner_pw pdf with
|
||||
| Some pdf -> pdf
|
||||
| Some pdf ->
|
||||
Printf.printf "Managed to decrypt with owner password"; pdf
|
||||
| _ ->
|
||||
Printf.printf "Couldn't decrypt with owner password %s\n" owner_pw;
|
||||
match Pdfcrypt.decrypt_pdf user_pw pdf with
|
||||
| Some pdf, permissions ->
|
||||
Printf.printf "Managed to decrypt with user password\n";
|
||||
if operation_allowed permissions op
|
||||
then pdf
|
||||
else soft_error "User password cannot give permission for this operation"
|
||||
|
|
Loading…
Reference in New Issue