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.
14 lines
465 B
14 lines
465 B
import fitz
|
|
import sys
|
|
|
|
doc = fitz.open(r'C:\git\spark-lesson\reference\sources\ufn-2000-paper.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\ufn-2000-paper.txt', 'w', encoding='utf-8') as f:
|
|
f.write(full)
|
|
print(f'Extracted {len(full)} chars from {len(doc)} pages')
|