# importing required modules
from pypdf import PdfReader

# creating a pdf reader object
reader = PdfReader('All_in_One_CCM.pdf')

# printing number of pages in pdf file
#print(len(reader.pages))
outputLst = []
pageIndx = 0
txtIdx = 0

for pages in reader.pages:
    page = reader.pages[pageIndx]
    text = page.extract_text()
    text = text.splitlines()
    outputLst += text
    pageIndx += 1

text = outputLst
while txtIdx < len(text):
    while text[txtIdx].isupper() and not text[txtIdx].startswith("CHAPTER"):
        print(text[txtIdx])
        if text[txtIdx].endswith("ORC") or text[txtIdx].endswith("CCC"):
            txtIdx += 1
            break
        else:
            txtIdx += 1

        while not text[txtIdx].startswith("_____________ did"):
            print("\t" + text[txtIdx])
            txtIdx += 1

        while not text[txtIdx].startswith("Note") or text[txtIdx].startswith("ORC") or text[txtIdx].startswith("CCC"):
            print("\t\t" + text[txtIdx])
            txtIdx += 1

    else:
        txtIdx += 1

