import PyPDF2 reader = PyPDF2.PdfReader('sample.pdf')for page in range(len(reader.pages)): p = reader.pages[page] size = p.mediabox print(size.width, size.height)