Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- """ this was fixed from the previous version because pdf_meta.py had the if __name__ == '__main__': code inside the main function. That always needs to be in the document not in the function. Thanks Javantea =]
- There was also a typo printmeta(filename): should be printMeta(filename): If this still throws an exception
- check the indentation on the last main().
- usage:
- python pdf_meta.py -F <filename> #where <filename> is your pdf, dont use <>"""
- import pyPdf
- import optparse
- from pyPdf import PdfFileReader
- def printMeta(filename):
- pdfFile = PdfFileReader(file(filename, 'rb'))
- docInfo = pdfFile.getDocumentInfo()
- print '[*] PDF MetaData For: ' + str(filename)
- for metaItem in docInfo:
- print '[+] ' + metaItem + ':' + docInfo[metaItem]
- def main():
- parser = optparse.OptionParser('usage %prog "+\
- "-F <PDF file name>')
- parser.add_option('-F', dest='fileName', type='string',\
- help='specify PDF file name')
- (options, args) = parser.parse_args()
- fileName = options.fileName
- if fileName == None:
- print parser.usage
- exit(0)
- else:
- printMeta(fileName)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement