Convert to command line application

master
Dan Howe 7 years ago
parent 4ea1f8b850
commit efd066bcfa

@ -1,6 +1,6 @@
# pdf-unlock #
# pdfunlock #
__pdf_unlock.py__ removes security features from pdfs, to allow unrestricted printing and copying of context.
**pdfunlock** removes security features from pdfs, to allow unrestricted printing and copying of context.
## Installation ##
@ -21,7 +21,8 @@ http://blog.alivate.com.au/poppler-windows
Then
```
pip install tqdm
git clone http://git.wrl.unsw.edu.au:3000/danh/pdfunlock.git
pip install -e pdfunlock
```
@ -31,14 +32,14 @@ pip install tqdm
Search for pdfs inside 'pdf_folder', then create new unlocked versions
of the pdfs with the the suffix '-unlocked.pdf':
`> python pdf_unlock.py pdf_folder`
`> pdfunlock pdf_folder`
Search for pdfs inside 'pdf_folder', then unlock the pdfs and overwrite
the original versions.
`> python pdf_unlock.py pdf_folder -o`
`> pdfunlock pdf_folder -o`
Search recursively for pdfs inside 'pdf_folder' and all subfolders,
then unlock the pdfs and overwrite the original versions.
`> python pdf_unlock.py pdf_folder -o -r`
`> pdfunlock pdf_folder -o -r`

@ -0,0 +1 @@
from .pdfunlock import main

@ -6,7 +6,7 @@ including restrictions on:
- copying text and images
- printing the document
usage: pdf_unlock.py [-h] [-r] [-o] folder
usage: pdf_unlock [-h] [-r] [-o] folder
positional arguments:
folder name of input folder
@ -21,23 +21,20 @@ Examples:
Search for pdfs inside 'pdf_folder', then create new unlocked versions
of the pdfs with the the suffix '-unlocked.pdf'.
> python pdf_unlock.py pdf_folder
> pdf_unlock pdf_folder
Search for pdfs inside 'pdf_folder', then unlock the pdfs and overwrite
the original versions.
> python pdf_unlock.py pdf_folder -o
> pdf_unlock pdf_folder -o
Search recursively for pdfs inside 'pdf_folder' and all subfolders,
then unlock the pdfs and overwrite the original versions.
> python pdf_unlock.py pdf_folder -o -r
> pdf_unlock pdf_folder -o -r
"""
__author__ = "D. Howe"
__version__ = "0.2.0"
__email__ = "d.howe@wrl.unsw.edu.au"
import os
import sys
import glob
import shutil
import argparse
@ -94,7 +91,7 @@ def isencrypted(pdf_name):
raise AttributeError('Could not read pdf info.')
def pdf_unlock(pdf_file, overwrite=False):
def pdfunlock(pdf_file, overwrite=False):
"""Rewrite pdf with Ghostscript, removing encryption.
Args:
@ -164,6 +161,12 @@ def main():
'--overwrite',
help='overwrite original files',
action='store_true')
# Print usage if no arguments are provided
if len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)
args = parser.parse_args()
# Get pdf files

@ -0,0 +1,11 @@
from setuptools import setup
setup(
name='pdfunlock',
version='0.3.0',
packages=['pdfunlock'],
install_requires=['tqdm'],
entry_points={'console_scripts':['pdfunlock = pdfunlock:main']},
author='Dan Howe',
author_email='d.howe@wrl.unsw.edu.au',
description='Remove security features from encrypted pdfs')
Loading…
Cancel
Save