Spire.Doc for Python

raw JSON →
14.4.2 verified Fri May 01 auth: no python

Spire.Doc for Python is a standalone Word Python API for creating, reading, manipulating, and converting Word documents (DOC, DOCX, RTF, etc.) without Microsoft Office. Version 14.4.2 is current; major version bumps occur roughly every 3-6 months, often introducing breaking changes in API paths.

pip install spire.doc
error ModuleNotFoundError: No module named 'spire.doc'
cause The package is installed as `spire.doc` but import is case-sensitive.
fix
Install using pip install spire.doc. Ensure no typos.
error AttributeError: module 'spire.doc' has no attribute 'Document'
cause Using old import pattern or missing correct import path.
fix
Use from spire.doc import Document (not from spire.doc import SpireDoc or import spire.doc).
error FileFormat' object has no attribute 'Docx2010'
cause Version-specific file format enums removed in v13+.
fix
Replace with FileFormat.Docx (without version number).
breaking From v12.0 onward, import paths changed significantly. Old patterns like `from spire.doc import *` or `from spire.doc.common import *` are deprecated.
fix Use explicit imports: `from spire.doc import Document, FileFormat, TextAlignment, etc.`
deprecated The methods `Document.SaveToFile()` with `FileFormat.Docx2010` and similar version-specific enums are deprecated in favor of generic `FileFormat.Docx`.
fix Replace with `FileFormat.Docx` or `FileFormat.Doc`.
gotcha The free version has a page/section limit (typically 3 pages). Exceeding causes silent truncation or exceptions.
fix Check with `doc.PageCount` in development or purchase a license to remove limitations.

Creates a simple Word document with one paragraph and saves as DOCX. No license file required for free tier (limited to sections/pages).

from spire.doc import Document, FileFormat

doc = Document()
section = doc.AddSection()
paragraph = section.AddParagraph()
paragraph.AppendText("Hello, Spire.Doc!")
doc.SaveToFile("output.docx", FileFormat.Docx)
doc.Close()