Test cases / pdf

deft pdf decrypt

Remove a password you know

4 runs on real files, 2 tests on generated files, not shown. 0 failed.

Fixed cases

Generated files, compared with ground truth by tools other than deft.

a real file with an empty passwordPassed

It must print pages.

deft pdf decrypt protected.pdf -o out.pdf
deft pdf info out.pdf

Input

protected.pdf 5.5 KB · 1 page
Page 1

Output

out.pdf 4.7 KB · 1 page
Page 1
What it printed
ok pdf.decrypt protected.pdf -> out.pdf  5KB  0.01s
ok pdf.info out.pdf  1 page, letter, PDF 1.7
pages=1 version=1.7 width=612.0 height=792.0 paper=letter producer="Adobe Acrobat Pro (64-bit) 23.3.20244" images=0 fonts=0 forms=false

encrypted attachments are decrypted tooPassed

It must print 30 pages.

deft pdf decrypt attachments.pdf --password attachment -o out.pdf
deft pdf info out.pdf

Input

attachments.pdf 17.4 KB · 30 pages
Page 1Page 2Page 3

Output

out.pdf 12.8 KB · 30 pages
Page 1Page 2Page 3
What it printed
ok pdf.decrypt attachments.pdf -> out.pdf  13KB  0.01s
ok pdf.info out.pdf  30 pages, letter, PDF 1.7
pages=30 version=1.7 width=612.0 height=792.0 paper=letter images=0 fonts=1 forms=false
Automatic checks (1)
  • pdf_encrypted: encrypted = false, file = "out.pdf"

encrypted attachments without the password are refusedPassed

It must fail with INPUT_ENCRYPTED.

deft pdf decrypt attachments.pdf -o out.pdf --json

Input

attachments.pdf 17.4 KB · 30 pages
Page 1Page 2Page 3

Output

No output file. The result is what it printed.

What it printed
{"v":1,"ok":false,"op":"pdf.decrypt","items":[{"ok":false,"inputs":["attachments.pdf"],"outputs":[],"facts":{},"warnings":[],"error":{"code":"INPUT_ENCRYPTED","message":"the attachments of this PDF are encrypted, so its password cannot be removed without it","hint":"add --password <password>; only the attachments need it"}}],"elapsed_ms":3}

Real-file tasks

Real files and a plain-language job, from the agent benchmark. These are the reference answers, not an agent run.

Remove a password I knowPassed

locked.pdf has the password openpassword. Save an unprotected copy as unlocked.pdf.

deft pdf decrypt locked.pdf --password openpassword -o unlocked.pdf

Input

locked.pdf 12.5 KB

This PDF has no preview: it needs a password or cannot be read.

Output

unlocked.pdf 11.7 KB · 1 page
Page 1
Automatic checks (2)
  • pdf_pages: file = "unlocked.pdf", pages = 1
  • pdf_encrypted: file = "unlocked.pdf", encrypted = false