LoginSignup
0
1

More than 1 year has passed since last update.

pdfのdecrypt

Last updated at Posted at 2021-11-15

pdfminerを使用する際、Encyptされているpdfをそのまま入力するとエラーが出るので、事前にdecryptしておく必要がある。
パスワードが存在する場合は --password=パスワード とする。

decrypt_pdfs.py
import glob 
import os
from subprocess import call

encrypted_files = glob.glob(pdf_directory)
for file in encrypted_files:
    pdf_filename = os.path.basename(file)
    out = "./decrypted_PDFs/" +pdf_filename 
    call('qpdf --password=%s --decrypt %s %s' %('', file, out), shell=True)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1