Documentation
¶
Overview ¶
Package writer handles writing DOCX files as ZIP archives containing XML documents. It provides the ZipWriter for creating properly structured Office Open XML packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NumberingPart ¶
NumberingPart represents numbering.xml data that should be preserved in the DOCX package.
type PreservedParts ¶ added in v2.2.1
type PreservedParts struct {
Headers map[string][]byte // Original headers (e.g., "header1.xml" -> bytes)
DocRels []byte // Original word/_rels/document.xml.rels
ContentTypes []byte // Original [Content_Types].xml
Additional map[string][]byte // Additional parts (comments, footnotes, customXml, etc.)
Themes map[string][]byte // Original theme parts
FontTable []byte // Original fontTable.xml
Settings []byte // Original settings.xml
WebSettings []byte // Original webSettings.xml
CustomProperties []byte // Original docProps/custom.xml
RootRels []byte // Original _rels/.rels
}
PreservedParts holds all parts that should be written verbatim from the original document. This enables complete round-trip fidelity when reading and saving documents.
type ZipWriter ¶
type ZipWriter struct {
// contains filtered or unexported fields
}
ZipWriter writes a .docx file to an io.Writer.
func (*ZipWriter) WriteDocument ¶
func (zw *ZipWriter) WriteDocument(doc *xmlstructs.Document, rels *xmlstructs.Relationships, coreProps *xmlstructs.CoreProperties, appProps *xmlstructs.AppProperties, styles *xmlstructs.Styles, media []*manager.MediaFile, headers map[string]*xmlstructs.Header, footers map[string]*xmlstructs.Footer, numbering *NumberingPart, preservedStyles []byte, preserved *PreservedParts) error
WriteDocument writes a complete .docx document structure. If preservedStyles is provided (non-nil), it will be written verbatim instead of serializing styles. If preserved is provided, those parts will be written verbatim for complete round-trip fidelity.