|
|
@ -6,7 +6,7 @@ including restrictions on:
|
|
|
|
- copying text and images
|
|
|
|
- copying text and images
|
|
|
|
- printing the document
|
|
|
|
- printing the document
|
|
|
|
|
|
|
|
|
|
|
|
usage: pdf_unlock.py [-h] [-r] [-o] folder
|
|
|
|
usage: pdf_unlock [-h] [-r] [-o] folder
|
|
|
|
|
|
|
|
|
|
|
|
positional arguments:
|
|
|
|
positional arguments:
|
|
|
|
folder name of input folder
|
|
|
|
folder name of input folder
|
|
|
@ -21,23 +21,20 @@ Examples:
|
|
|
|
|
|
|
|
|
|
|
|
Search for pdfs inside 'pdf_folder', then create new unlocked versions
|
|
|
|
Search for pdfs inside 'pdf_folder', then create new unlocked versions
|
|
|
|
of the pdfs with the the suffix '-unlocked.pdf'.
|
|
|
|
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
|
|
|
|
Search for pdfs inside 'pdf_folder', then unlock the pdfs and overwrite
|
|
|
|
the original versions.
|
|
|
|
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,
|
|
|
|
Search recursively for pdfs inside 'pdf_folder' and all subfolders,
|
|
|
|
then unlock the pdfs and overwrite the original versions.
|
|
|
|
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 os
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import glob
|
|
|
|
import glob
|
|
|
|
import shutil
|
|
|
|
import shutil
|
|
|
|
import argparse
|
|
|
|
import argparse
|
|
|
@ -94,7 +91,7 @@ def isencrypted(pdf_name):
|
|
|
|
raise AttributeError('Could not read pdf info.')
|
|
|
|
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.
|
|
|
|
"""Rewrite pdf with Ghostscript, removing encryption.
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
Args:
|
|
|
@ -164,6 +161,12 @@ def main():
|
|
|
|
'--overwrite',
|
|
|
|
'--overwrite',
|
|
|
|
help='overwrite original files',
|
|
|
|
help='overwrite original files',
|
|
|
|
action='store_true')
|
|
|
|
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()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
# Get pdf files
|
|
|
|
# Get pdf files
|