writer

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractNum

type AbstractNum struct {
	ID         int
	MultiLevel bool
	Levels     []Level
	Name       string
}

AbstractNum defines an abstract numbering definition

func (*AbstractNum) GenerateXML

func (an *AbstractNum) GenerateXML() string

GenerateXML generates XML for an abstract numbering definition

type AppProperties

type AppProperties struct {
	// contains filtered or unexported fields
}

AppProperties represents the generator for docProps/app.xml

func (*AppProperties) Byte

func (ap *AppProperties) Byte() ([]byte, error)

Byte generates the XML content for docProps/app.xml

func (*AppProperties) Path

func (ap *AppProperties) Path() string

Path returns the ZIP path for app properties

func (*AppProperties) WriteTo

func (ap *AppProperties) WriteTo(w io.Writer) (int64, error)

WriteTo writes the XML to an io.Writer (implements io.WriterTo).

type AppPropertiesXML

type AppPropertiesXML struct {
	XMLName xml.Name `xml:"Properties"`
	Xmlns   string   `xml:"xmlns,attr"`
	XmlnsVt string   `xml:"xmlns:vt,attr"`

	Application          string `xml:"Application,omitempty"`
	AppVersion           string `xml:"AppVersion,omitempty"`
	DocSecurity          int    `xml:"DocSecurity"`
	Lines                int    `xml:"Lines"`
	Paragraphs           int    `xml:"Paragraphs"`
	Words                int    `xml:"Words"`
	Characters           int    `xml:"Characters"`
	CharactersWithSpaces int    `xml:"CharactersWithSpaces"`
	Pages                int    `xml:"Pages"`
	Company              string `xml:"Company,omitempty"`
	Manager              string `xml:"Manager,omitempty"`
	LinksUpToDate        bool   `xml:"LinksUpToDate"`
	ScaleCrop            bool   `xml:"ScaleCrop"`
	SharedDoc            bool   `xml:"SharedDoc"`
	HyperlinksChanged    bool   `xml:"HyperlinksChanged"`
	Template             string `xml:"Template,omitempty"`
	TotalTime            int    `xml:"TotalTime,omitempty"`
	HiddenSlides         int    `xml:"HiddenSlides,omitempty"`
	MMClips              int    `xml:"MMClips,omitempty"`
	Notes                int    `xml:"Notes,omitempty"`
	Slides               int    `xml:"Slides,omitempty"`
}

AppPropertiesXML defines the XML structure of docProps/app.xml

type ContentTypesWr

type ContentTypesWr struct {
	// contains filtered or unexported fields
}

ContentTypes represents the [Content_Types].xml part in a DOCX package.

func (*ContentTypesWr) Byte

func (ct *ContentTypesWr) Byte() ([]byte, error)

Byte serializes the ContentTypes struct to XML with an XML declaration.

func (*ContentTypesWr) Path

func (ct *ContentTypesWr) Path() string

Path returns the location of the content types file within the DOCX ZIP.

func (*ContentTypesWr) WriteTo

func (ct *ContentTypesWr) WriteTo(w io.Writer) (int64, error)

WriteTo writes the XML to an io.Writer (implements io.WriterTo).

type CoreProperties

type CoreProperties struct {
	*CorePropertiesXML
	// contains filtered or unexported fields
}

func (*CoreProperties) Byte

func (cr *CoreProperties) Byte() ([]byte, error)

func (*CoreProperties) Path

func (cp *CoreProperties) Path() string

func (*CoreProperties) WriteTo

func (cp *CoreProperties) WriteTo(w io.Writer) (int64, error)

type CorePropertiesXML

type CorePropertiesXML struct {
	XMLName       xml.Name `xml:"cp:coreProperties"`
	XmlnsCp       string   `xml:"xmlns:cp,attr"`
	XmlnsDc       string   `xml:"xmlns:dc,attr"`
	XmlnsDcterms  string   `xml:"xmlns:dcterms,attr"`
	XmlnsDcmitype string   `xml:"xmlns:dcmitype,attr"`
	XmlnsXsi      string   `xml:"xmlns:xsi,attr"`

	Title          string       `xml:"dc:title,omitempty"`
	Subject        string       `xml:"dc:subject,omitempty"`
	Creator        string       `xml:"dc:creator,omitempty"`
	Keywords       string       `xml:"cp:keywords,omitempty"`
	Description    string       `xml:"dc:description,omitempty"`
	LastModifiedBy string       `xml:"cp:lastModifiedBy,omitempty"`
	Revision       string       `xml:"cp:revision,omitempty"`
	Created        *TimeElement `xml:"dcterms:created"`
	Modified       *TimeElement `xml:"dcterms:modified"`
	Category       string       `xml:"cp:category,omitempty"`
	ContentStatus  string       `xml:"cp:contentStatus,omitempty"`
	Language       string       `xml:"dc:language,omitempty"`
	Version        string       `xml:"cp:version,omitempty"`
}

type Document

type Document struct {
	// contains filtered or unexported fields
}

func (*Document) Byte

func (d *Document) Byte() ([]byte, error)

func (*Document) Path

func (d *Document) Path() string

func (*Document) WriteTo

func (d *Document) WriteTo(w io.Writer) (int64, error)

type DocumentRelationship

type DocumentRelationship struct {
	types.Document
}

func (*DocumentRelationship) Byte

func (d *DocumentRelationship) Byte() ([]byte, error)

Byte generates the XML content for the document

func (*DocumentRelationship) Path

func (d *DocumentRelationship) Path() string

Path returns the path inside the .docx ZIP file

func (*DocumentRelationship) WriteTo

func (d *DocumentRelationship) WriteTo(w io.Writer) (int64, error)

WriteTo writes the document content to the given writer (implements io.WriterTo)

type Level

type Level struct {
	Level         int
	Start         int
	NumFormat     string // bullet, decimal, upperRoman, lowerRoman, upperLetter, lowerLetter, etc.
	LevelText     string
	LevelJc       string // left, center, right, justify
	PStyle        string
	IsLegalNum    bool
	Suffix        string // tab, space, nothing
	BulletChar    string // For bullet lists
	Font          string // Font for bullet
	IndentLeft    int    // In twips
	IndentHanging int    // In twips
}

Level defines a numbering level

func (*Level) GenerateXML

func (l *Level) GenerateXML() string

GenerateXML generates XML for a numbering level

type LevelOverride

type LevelOverride struct {
	Level         int
	StartOverride int
}

LevelOverride allows overriding specific levels

type Num

type Num struct {
	ID         int
	AbstractID int
	Overrides  []LevelOverride
}

Num defines a concrete numbering instance

func (*Num) GenerateXML

func (n *Num) GenerateXML() string

GenerateXML generates XML for a concrete numbering instance

type NumberingDefinitions

type NumberingDefinitions struct {
	AbstractNums []AbstractNum
	Nums         []Num
}

NumberingDefinitions contains all numbering definitions for the document

func (*NumberingDefinitions) Byte

func (num *NumberingDefinitions) Byte() ([]byte, error)

func (*NumberingDefinitions) Path

func (num *NumberingDefinitions) Path() string

func (*NumberingDefinitions) WriteTo

func (num *NumberingDefinitions) WriteTo(w io.Writer) (int64, error)

WriteTo writes the XML content to the given writer.

type Relationships

type Relationships struct {
	types.Document
}

Relationships represents the _rels/.rels file in a DOCX package.

func (*Relationships) Byte

func (r *Relationships) Byte() ([]byte, error)

Byte returns the full XML content for the _rels/.rels part.

func (*Relationships) Path

func (r *Relationships) Path() string

Path returns the location of the part inside the DOCX ZIP.

func (*Relationships) WriteTo

func (r *Relationships) WriteTo(w io.Writer) (int64, error)

WriteTo writes the XML content to the given writer.

type SaveOptions

type SaveOptions struct {
	CompressionLevel        int
	PrettyPrint             bool
	IncludeCustomProperties bool
	UpdateFields            bool
	Metadata                map[string]string
}

SaveOptions provides options for saving documents

func DefaultSaveOptions

func DefaultSaveOptions() SaveOptions

DefaultSaveOptions returns default save options

type StylesWr

type StylesWr struct {
	// contains filtered or unexported fields
}

func (*StylesWr) Byte

func (swr *StylesWr) Byte() ([]byte, error)

Byte

func (*StylesWr) Path

func (swr *StylesWr) Path() string

Path

func (*StylesWr) WriteTo

func (swr *StylesWr) WriteTo(w io.Writer) (int64, error)

WriteTo

type TimeElement

type TimeElement struct {
	XMLName xml.Name `xml:""`
	Type    string   `xml:"xsi:type,attr"`
	Value   string   `xml:",chardata"`
}

TimeElement represents a time element with xsi:type

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer handles writing documents to DOCX format

func NewWriter

func NewWriter(doc types.Document) *Writer

NewWriter creates a new writer for the document

func (*Writer) Write

func (w *Writer) Write(writer io.Writer) error

Write writes the document to an io.Writer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL