forked from shadow-box/Violent-Python-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-pdfRead.py
More file actions
32 lines (25 loc) · 770 Bytes
/
3-pdfRead.py
File metadata and controls
32 lines (25 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
# -*- coding: utf-8 -*-
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()