استخدام الحالات لـ Aspose.Words FOSS لPython
Aspose.Words FOSS for Python is a pure Python library for reading and converting Word documents without Microsoft Office. The following use cases illustrate where the library fits into real-world Python applications.
تحويل الوثيقة
تحويل بين DOCX، DOC، RTF، TXT، Markdown، و PDF:
import aspose.words_foss as aw
doc = aw.Document("input.docx")
doc.save("output.pdf")
doc.save("output.md")يعمل هذا النموذج على أي مزيج من تنسيقات الإدخال والخروج المدعومة.
نص استخراج
استخراج النص المسطح من مستندات Word للتصنيف أو البحث أو أنابيب NLP:
import aspose.words_foss as aw
doc = aw.Document("contract.docx")
text = doc.get_text()
# Feed to search index, NLP model, or text analysisمعالجة Batch
إجراء دليل من الوثائق في سيناريو واحد:
import aspose.words_foss as aw
from pathlib import Path
for src in Path("incoming/").glob("*.docx"):
doc = aw.Document(str(src))
doc.save(str(src.with_suffix(".pdf")))معالجة مستندات الخادم-Side
اقرأ المستندات التي تم تحميلها في تطبيق الويب دون ملفات مؤقتة:
import aspose.words_foss as aw
def process_upload(stream):
doc = aw.Document(stream)
return {
"sections": len(doc.sections),
"text_preview": doc.get_text()[:200]
}الأثر في شكل الهجرة
أسرار التراث Word 97-2003 .doc ملفات إلى DOCX أو PDF الحديثة:
import aspose.words_foss as aw
doc = aw.Document("legacy.doc")
doc.save("modern.docx")
doc.save("archive.pdf")