Solved! Go to Solution.
import arcpy, os, sys, string
from os import path as p
from arcpy import mapping as m
#Make parameters for people to choose mxd and folder of PDFs to compare
mxdList = arcpy.GetParameterAsText(0).split(";")
pdf_path = arcpy.GetParameterAsText(1)
#Use Search Cursor to go through Attribuite Table to get Sheet number info
count = 0
mxd_dict = {}
for mapDoc in mxdList:
arcpy.AddMessage(mapDoc)
mxd = arcpy.mapping.MapDocument(mapDoc)
max_list = []
for lyr in m.ListLayers(mxd):
try:
rows = arcpy.SearchCursor(lyr)
for row in rows:
max_list.append(row.Sheet_ID)
count += 1
sheet_count = max(max_list)
mxd_name = p.basename(mapDoc).split('.')[0]
mxd_dict[mxd_name] = sheet_count
except:
pass
arcpy.AddMessage (count)
pdf_dict = {}
pdf_list = []
arcpy.env.workspace = ws = pdf_path
for pdf_ in arcpy.ListFiles('*.pdf'):
pdf_list.append(pdf_.split('.')[0].rstrip('0123456789'))
unique = list(set(pdf_list))
count2 = 0
for pdf in unique:
for doc in arcpy.ListFiles('%s*.pdf' % pdf):
page_list = []
doc_ = doc.split('.')[0].rstrip('0123456789')
for key in mxd_dict.keys():
if doc_ == key:
page_list.append(int(''.join([i for i in doc if i.isdigit()])))
page_count = max(page_list)
count2 += 1
pdf_dict[doc_] = page_count
arcpy.AddMessage (count2)
for pdf in unique:
print 'MXD:\t%s\tSheet Count:\t%s'%(pdf, mxd_dict[pdf])
arcpy.AddMessage('MXD:\t%s\tSheet Count:\t%s'%(pdf, mxd_dict[pdf]))
print 'PDF:\t%s\tPage Count:\t%s'%(pdf, pdf_dict[pdf])
arcpy.AddMessage('PDF:\t%s\tPage Count:\t%s'%(pdf, pdf_dict[pdf]))
if count == count2:
arcpy.AddMessage('\n"%s.mxd" Sheet Count Matches Number of Pages in %s.pdf\n' %(pdf,pdf))
print '\n"%s.mxd" Sheet Count Matches Number of Pages in %s.pdf\n' %(pdf,pdf)
else:
arcpy.AddMessage('\n"%s.mxd" Sheet Count Does Not Match Number of Pages in %s.pdf\n' %(pdf,pdf))
print '\n"%s.mxd" Sheet Count Does Not Match Number of Pages in %s.pdf\n' %(pdf,pdf)