Sep-02-2025, 08:02 PM
(This post was last modified: Sep-02-2025, 08:40 PM by deanhystad.)
Hey I am new to all this python stuff so this may be an obvious question. I am trying to process a .pdf into a list so can output it to a .pdf form. If someone could look at my code and let me know why my break statement is not working I would appreciate it!
# 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
deanhystad write Sep-02-2025, 08:40 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Attached Files
