-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathPDFMetaData.py
25 lines (21 loc) · 896 Bytes
/
PDFMetaData.py
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
# -*- encoding: utf-8 -*-
#class for obtain metadata info from pdf
import os
#pdf lib
from PyPDF2 import PdfFileReader, PdfFileWriter
class PDFMetaData:
def printMetaData(self):
for dirpath, dirnames, files in os.walk("pdfs"):
try:
for name in files:
ext = name.lower().rsplit('.', 1)[-1]
if ext in ['pdf']:
print "[+] Metadata for file: %s " %(dirpath+os.path.sep+name)
pdfFile = PdfFileReader(file(dirpath+os.path.sep+name, 'rb'))
docInfo = pdfFile.getDocumentInfo()
for metaItem in docInfo:
print '[+] ' + metaItem + ':' + docInfo[metaItem]
print "\n"
except Exception,e:
print "Error to Obtain PDF METADATA"
pass