Dynamic Dynamic - 3 months ago 26
Python Question

PDF Encryption Using Python

The code below takes in a single pdf file and then encrypts it, What i want it to do is to take a directory containing pdf files and encrypt the files in that directory automatically, instead of specifying each file explicitly. Please help !

def main():
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input_pdf', required=True,
help='Input pdf file')
parser.add_argument('-p', '--user_password', required=True,
help='output CSV file')
parser.add_argument('-o', '--owner_password', default=None,
help='Owner Password')
args = parser.parse_args()
set_password(args.input_pdf, args.user_password, args.owner_password)

if __name__ == "__main__":

import glob
import os

for file in glob.glob('*.pdf'):
    set_password(file, upass, opass)