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 ->
|
| Some root ->
|
||||||
match Pdf.lookup_direct pdf "/Metadata" root with
|
match Pdf.lookup_direct pdf "/Metadata" root with
|
||||||
| Some ((Pdf.Stream _) as s) ->
|
| Some ((Pdf.Stream _) as s) ->
|
||||||
Pdf.getstream s;
|
Pdfcodec.decode_pdfstream pdf s;
|
||||||
begin match s with
|
begin match s with
|
||||||
| Pdf.Stream {contents = (_, Pdf.Got data)} -> Some data
|
| Pdf.Stream {contents = (_, Pdf.Got data)} -> Some data
|
||||||
| _ -> assert false
|
| _ -> assert false
|
||||||
|
|
|
@ -545,11 +545,13 @@ let rec decrypt_if_necessary (_, _, _, user_pw, owner_pw) op pdf =
|
||||||
end;
|
end;
|
||||||
if not (Pdfcrypt.is_encrypted pdf) then pdf else
|
if not (Pdfcrypt.is_encrypted pdf) then pdf else
|
||||||
match Pdfcrypt.decrypt_pdf_owner owner_pw pdf with
|
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;
|
Printf.printf "Couldn't decrypt with owner password %s\n" owner_pw;
|
||||||
match Pdfcrypt.decrypt_pdf user_pw pdf with
|
match Pdfcrypt.decrypt_pdf user_pw pdf with
|
||||||
| Some pdf, permissions ->
|
| Some pdf, permissions ->
|
||||||
|
Printf.printf "Managed to decrypt with user password\n";
|
||||||
if operation_allowed permissions op
|
if operation_allowed permissions op
|
||||||
then pdf
|
then pdf
|
||||||
else soft_error "User password cannot give permission for this operation"
|
else soft_error "User password cannot give permission for this operation"
|
||||||
|
|
Loading…
Reference in New Issue