For PDF: I made a Python script which uses PyPDF2
library: GitHub - artikrh/pdf-tool: A tool which offers PDF file encryption in command line and brute forcing them using a local wordlist.
Example usage:
$ python pdf-tool.py -d file.pdf -w /usr/share/wordlists/rockyou.txt