Skip to content

Commit

Permalink
Added allow_printing and allow_commenting parameters to encrypt GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
sfneal committed Aug 16, 2018
1 parent e207ebf commit c1bd3b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 9 additions & 6 deletions pdfconduit/utils/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def encrypt():

def header():
return [[gui.Text('HPA Design', size=(30, 1), font=("Helvetica", 25), text_color='blue')],
[gui.Text('PDF Encrypt utility', size=(30, 1), font=("Helvetica", 25), text_color='blue')],
[gui.Text('PDF Encryption utility', size=(30, 1), font=("Helvetica", 25), text_color='blue')],
[gui.Text('version: ' + __version__, size=(30, 1), font=("Helvetica", 16), text_color='blue')],
[_line()]]

Expand Down Expand Up @@ -75,7 +75,7 @@ def settings(p):
# Source
[gui.Text('Source', font=('Helvetica', 15), justification='left')],
[gui.Text('Source PDF file', size=(label_w, 1), auto_size_text=False), gui.InputText(p['pdf']),
gui.FileBrowse(file_types=(("PDF Files", "*.pdf"),)),
gui.FileBrowse(button_text='File', file_types=(("PDF Files", "*.pdf"),)),
gui.SimpleButton('Folder')],

[_line()],
Expand All @@ -85,7 +85,7 @@ def settings(p):
[gui.Text('User Password', size=(label_w, 1), auto_size_text=False), gui.InputText()],
[gui.Text('Owner Password', size=(label_w, 1), auto_size_text=False), gui.InputText()],
[gui.Checkbox('128 bit encryption', default=True)],
[gui.Checkbox('Print only', default=True)],
[gui.Checkbox('Allow Printing', default=True), gui.Checkbox('Allow Commenting', default=False)],
]
layout = []
layout.extend(header())
Expand All @@ -101,7 +101,8 @@ def settings(p):
'user_pw': user_pw,
'owner_pw': owner_pw,
'128bit': values[3],
'print_only': values[4],
'allow_printing': values[4],
'allow_commenting': values[5],
}
if button == 'Folder':
params = folder(params)
Expand All @@ -113,7 +114,8 @@ def settings(p):
'user_pw': '',
'owner_pw': '',
'128bit': True,
'print_only': True,
'allow_printing': True,
'allow_commenting': False,
}

p = settings(p)
Expand All @@ -125,7 +127,8 @@ def settings(p):
p['pdf'] = [os.path.join(src_dir, pdf) for pdf in os.listdir(src_dir) if pdf.endswith('.pdf')]

for pdf in p['pdf']:
e = Encrypt(pdf, p['user_pw'], p['owner_pw'], bit128=p['128bit'], allow_printing=p['print_only'])
e = Encrypt(pdf, p['user_pw'], p['owner_pw'], bit128=p['128bit'], allow_printing=p['allow_printing'],
allow_commenting=p['allow_commenting'])
return str(e)

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions tests/test_encrypt_P.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def main():
owner_pw = 'foo'
user_pw = 'baz'

# _range = [-(x + 50) for x in range(0, 1852)[::100]]
_range = [-1852]
_range = [-(x + 50) for x in range(0, 1852)[::100]]
print(_range)
for i in _range:
with ActiveTimer(i):
Expand Down

0 comments on commit c1bd3b1

Please sign in to comment.