SHOW:
|
|
- or go back to the newest paste.
| 1 | #! /usr/bin/env python | |
| 2 | ||
| 3 | """ attribution to book violent python. this is supposed to print meta to stdout, it doesn't. | |
| 4 | it doesn't throw exception, but doesn't print anything. still working on it.""" | |
| 5 | ||
| 6 | import pyPdf | |
| 7 | import optparse | |
| 8 | from pyPdf import PdfFileReader | |
| 9 | def printmeta(filename): | |
| 10 | pdfFile = PdfFileReader(file(filename, 'rb')) | |
| 11 | docInfo = pdfFile.getDocumentInfo() | |
| 12 | print '[*] PDF MetaData For: ' + str(filename) | |
| 13 | for metaItem in docInfo: | |
| 14 | print '[+] ' + metaItem + ':' + docInfo[metaItem] | |
| 15 | def main(): | |
| 16 | parser = optparse.OptionParser('usage %prog "+\
| |
| 17 | "-F <PDF file name>') | |
| 18 | parser.add_option('-F', dest='fileName', type='string',\
| |
| 19 | help='specify PDF file name') | |
| 20 | (options, args) = parser.parse_args() | |
| 21 | fileName = options.fileName | |
| 22 | if fileName == None: | |
| 23 | print parser.usage | |
| 24 | exit(0) | |
| 25 | else: | |
| 26 | printMeta(fileName) | |
| 27 | - | if __name__ == '__main__': |
| 27 | + | if __name__ == '__main__': |
| 28 | - | main() |
| 28 | + | main() |