2026-06-12 11:58:47 +00:00
|
|
|
# main.py
|
2026-06-13 02:03:58 +00:00
|
|
|
import asyncio
|
2026-06-13 02:57:45 +00:00
|
|
|
from docling.document_converter import DocumentConverter
|
2026-06-12 11:58:47 +00:00
|
|
|
|
2026-06-13 02:57:45 +00:00
|
|
|
async def dump_docling_output():
|
|
|
|
|
file_path = "aula_int_plus_1_glos_en_alfa.pdf"
|
|
|
|
|
output_path = "docling_output.md"
|
2026-06-12 11:58:47 +00:00
|
|
|
|
2026-06-13 02:57:45 +00:00
|
|
|
print(f"🔄 Docling is analyzing structural layout for '{file_path}'...")
|
2026-06-12 11:58:47 +00:00
|
|
|
|
2026-06-13 02:57:45 +00:00
|
|
|
try:
|
|
|
|
|
converter = DocumentConverter()
|
|
|
|
|
result = converter.convert(file_path)
|
|
|
|
|
markdown_text = result.document.export_to_markdown()
|
|
|
|
|
|
|
|
|
|
# Save the exact output to a file in your project root
|
|
|
|
|
with open(output_path, "w", encoding="utf-8") as f:
|
|
|
|
|
f.write(markdown_text)
|
|
|
|
|
|
|
|
|
|
print(f"📝 Success! Raw Docling layout exported cleanly to: {output_path}")
|
|
|
|
|
print("👀 Open this file in VS Code to see exactly how the text flows.")
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"❌ Docling processing failed: {e}")
|
2026-06-12 11:58:47 +00:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2026-06-13 02:57:45 +00:00
|
|
|
asyncio.run(dump_docling_output())
|