1. ผลิตภัณฑ์
  2.   Aspose.Words
  3.   Aspose.Words FOSS for Python

Aspose.Words FOSS สำหรับ Python

แปลงเอกสาร Word เป็น PDF, Markdown และข้อความจาก Python — ฟรีและโอเพนซอร์ส ไม่ต้องใช้ Microsoft Office

ไลบรารี Python แบบโอเพนซอร์สสำหรับการแปลงเอกสาร Word

Aspose.Words FOSS for Python เป็นไลบรารี Python ที่ได้รับอนุญาตแบบ MIT สำหรับการโหลดและแปลงเอกสาร Word. ไลบรารีนี้อ่านไฟล์ DOCX, DOC, RTF, TXT และ Markdown และส่งออกเป็น PDF, Markdown และข้อความธรรมดาโดยไม่ต้องใช้ Microsoft Office หรือรันไทม์ที่เป็นกรรมสิทธิ์ใดๆ

ไลบรารีนี้มีคลาส Document สำหรับโหลดไฟล์และเมธอด save() ที่รับค่าคงที่ SaveFormat หรืออ็อบเจ็กต์ตัวเลือกการบันทึกเช่น PdfSaveOptions และ MarkdownSaveOptions เพื่อควบคุมการส่งออกอย่างละเอียด

ติดตั้งด้วยคำสั่ง pip install aspose-words-foss>=26.4.0. ไลบรารีนี้ต้องการ Python 3.10 หรือใหม่กว่าและมีการพึ่งพา olefile, fpdf2, และ pydantic. ไลบรารีนี้ได้รับอนุญาตแบบ MIT และเป็นโอเพนซอร์สเต็มรูปแบบบน GitHub.

Document Conversion

  • Multi-format input: Load documents from DOCX, DOC, RTF, TXT, and Markdown formats via the Document class.
  • PDF export: Convert any input document to PDF using SaveFormat.PDF or PdfSaveOptions.
  • Markdown export: Export to Markdown with SaveFormat.MARKDOWN or MarkdownSaveOptions.
  • Text extraction: Extract plain text content from documents using Document.get_text().
  • Plain text export: Save documents as plain text using SaveFormat.TEXT.

Where Aspose.Words FOSS Can Be Used

  • Document pipelines: Convert uploaded Word documents to PDF in backend services.
  • Content extraction: Extract text from DOCX or DOC files for indexing and search.
  • Format migration: Batch-convert legacy DOC/RTF archives to modern Markdown or PDF.
  • CI/CD automation: Generate PDF reports from Markdown or DOCX templates in build pipelines.

Save Options and Customization

  • PdfSaveOptions: Control PDF output settings when converting documents to PDF.
  • MarkdownSaveOptions: Configure Markdown-specific export options.
  • SaveFormat constants: Use SaveFormat.MARKDOWN, SaveFormat.PDF, and SaveFormat.TEXT for quick conversion.
  • Document readers: Dedicated readers for DOC, RTF, TXT, and Markdown input formats.

Developer Experience

Aspose.Words FOSS installs with pip install aspose-words-foss. Runtime dependencies (olefile, fpdf2, pydantic) are installed automatically.

The API is straightforward: load a Document from a file path, then call save() with a target path and format. For advanced control, pass a save-options object instead of a format constant. The library is MIT-licensed, open-source on GitHub, and requires Python 3.10 or later.

Convert DOCX to Markdown

Load a Word document and save it as Markdown in two lines of code.

import aspose.words_foss as aw

doc = aw.Document("input.docx")  # or .doc, .rtf, .txt, .md
doc.save("output.md", aw.SaveFormat.MARKDOWN)

Convert DOCX to PDF

Export a Word document to PDF format.

import aspose.words_foss as aw

doc = aw.Document("input.docx")
doc.save("output.pdf", aw.SaveFormat.PDF)

Extract Text from a Document

Read all text content from a Word document.

import aspose.words_foss as aw

doc = aw.Document("input.docx")
text = doc.get_text()

คำถามที่พบบ่อย

What license does Aspose.Words FOSS for Python use?

Aspose.Words FOSS for Python is released under the MIT license. You can use, modify, and distribute it in commercial and personal projects.

How do I install Aspose.Words FOSS for Python?

Install via pip with pip install aspose-words-foss>=26.4.0. Requires Python 3.10 or later.

Which document formats are supported?

The library reads DOCX, DOC, RTF, TXT, and Markdown files and exports to PDF, Markdown, and plain text.

How do I convert a DOCX file to PDF?

Load with Document("input.docx") and call doc.save("output.pdf", SaveFormat.PDF).

  

ทรัพยากรสนับสนุนและการเรียนรู้

 ภาษาไทย