Documentation
¶
Overview ¶
Package docxr provides functionality for reading, manipulating, and writing Word documents (DOCX).
Package docxr provides functionality for reading, manipulating, and writing Word documents (DOCX).
Package docxr provides functionality for reading, manipulating, and writing Word documents (DOCX).
Index ¶
Constants ¶
const ( WordDocument = "word/document.xml" WordHeader1 = "word/header1.xml" WordHeader2 = "word/header2.xml" WordHeader3 = "word/header3.xml" )
These constants define the paths to various XML files within a DOCX archive that are supported for templating and rendering by the docxr package.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Docx ¶
type Docx struct {
// contains filtered or unexported fields
}
Docx represents a Word document. It is used to read, manipulate, and write Word documents. It is not thread-safe.
func (*Docx) ReadFrom ¶
ReadFrom reads a DOCX document from the provided io.Reader. It returns the number of bytes read and an error, if any. Note: For non-seekable readers, the entire content is read into memory, which may be inefficient for very large files.
func (*Docx) ReadFromBytes ¶
ReadFromBytes reads a DOCX document from the provided byte slice. It returns an error if the byte slice cannot be parsed as a DOCX.
func (*Docx) ReadFromFile ¶
ReadFromFile reads a DOCX document from the specified file path. It returns an error if the file cannot be opened or read.
func (*Docx) Render ¶
Render applies the provided data to the document's templates. It processes all supported XML files within the DOCX (e.g., document.xml, headers, footers) and replaces template tags (e.g., `{{.FieldName}}`) with corresponding values from `data`. The `data` parameter can be any type that is compatible with Go's text/template package. It returns an error if templating fails.
func (*Docx) WriteTo ¶
WriteTo writes the current state of the DOCX document to the provided io.Writer. This includes both the templated content and original files. It returns the number of bytes written and an error, if any.
func (*Docx) WriteToFile ¶
WriteToFile writes the current state of the DOCX document to the specified file path. It returns an error if the file cannot be created or written to.

