jrmuizel / pdf-extract

A rust library for extracting content from pdfs
364 stars 73 forks source link

Add decryption functions and attempt decrypt if pdf is encrypted #82

Closed prscoelho closed 2 months ago

prscoelho commented 5 months ago

Fix #37 based on #59

This change adds extract_text_encrypted, extract_text_from_mem_encrypted and output_doc_encrypted.

Try to decrypt with empty password before calling output_doc and return early with error if encrypt("") returns an error.

output_doc still has a is_encrypted() check, as lopdf removes the Encrypt trailer after successfully decrypting.