def critical_info(): '''Gathers and returns the nessecary information to start the task''' path = os.getcwd() input_path = os.path.join(path, 'practice_files/The Emperor.pdf') in_pdf = pfr(file(input_path, 'rb')) out_pdf = pfw() return path, in_pdf, out_pdf
def get_pdf_info(fn): fp = pfr(open(fn, 'rb')) file_info = fp.getDocumentInfo() clean_info = {} for di in file_info: try: clean_info[ di[1:] ] = file_info[di] print "[Info for %s]" % (fn) print clean_info except UnicodeEncodeError as e: ## http://docs.python.org/2/library/exceptions.html#exception-hierarchy print "[Error] busted -> %s \n %s" % (fn, e) raise # returns a dictionary with several key:value pairs. return clean_info
def get_watermark(path): '''Fetches the watermark, as a PDF.''' watermark_path = os.path.join(path, 'practice_files/top secret.pdf') watermark = pfr(file(watermark_path, 'rb')) return watermark