You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
474 B

import fitz
doc = fitz.open(r'C:\git\spark-lesson\reference\sources\cenrs-book.pdf')
output = []
for i in range(len(doc)):
text = doc[i].get_text()
if text.strip():
output.append(f'=== PAGE {i+1} ===')
output.append(text)
full = '\n'.join(output)
with open(r'C:\git\spark-lesson\reference\sources\bazelyan-raizer-lightning-physics-2000.txt', 'w', encoding='utf-8') as f:
f.write(full)
print(f'Extracted {len(full)} chars from {len(doc)} pages')