24 lines
649 B
Python
24 lines
649 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Script to examine the raw text extraction from failing PDFs.
|
|
"""
|
|
|
|
from PyPDF2 import PdfReader
|
|
import os
|
|
|
|
# Test the first failing PDF
|
|
pdf_path = '134d5916-1c71-47da-a24c-0ead74f8f8e2.pdf'
|
|
|
|
if os.path.exists(pdf_path):
|
|
reader = PdfReader(pdf_path)
|
|
if len(reader.pages) > 0:
|
|
text = reader.pages[0].extract_text()
|
|
print(f"Raw text from {pdf_path}:")
|
|
print(repr(text))
|
|
print("\nFormatted text:")
|
|
print(text)
|
|
print("\nLines:")
|
|
for i, line in enumerate(text.split('\n')):
|
|
print(f"{i+1}: {repr(line)}")
|
|
else:
|
|
print(f"PDF file {pdf_path} not found") |