docx

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XMLNS_W = `http://schemas.openxmlformats.org/wordprocessingml/2006/main`
	XMLNS_R = `http://schemas.openxmlformats.org/officeDocument/2006/relationships`
)
View Source
const (
	NS_A   = "http://schemas.openxmlformats.org/drawingml/2006/main"
	NS_WP  = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
	NS_PIC = "http://schemas.openxmlformats.org/drawingml/2006/picture"
)
View Source
const (
	XMLNS         = `http://schemas.openxmlformats.org/package/2006/relationships`
	REL_HYPERLINK = `http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`
	REL_IMAGE     = `http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`

	REL_TARGETMODE = "External"
)
View Source
const (
	TEMP_REL = `` /* 601-byte string literal not displayed */

	TEMP_DOCPROPS_APP  = `` /* 276-byte string literal not displayed */
	TEMP_DOCPROPS_CORE = `` /* 363-byte string literal not displayed */
	TEMP_CONTENT       = `` /* 1117-byte string literal not displayed */

	TEMP_WORD_STYLE = `` /* 1743-byte string literal not displayed */

	TEMP_WORD_THEME_THEME = `` /* 9767-byte string literal not displayed */

	TEMP_WORD_STYLE_TNR = `` /* 1792-byte string literal not displayed */

)
View Source
const (
	HYPERLINK_STYLE = "a1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AExt

type AExt struct {
	Cx int64 `xml:"cx,attr"`
	Cy int64 `xml:"cy,attr"`
}

type AvLst

type AvLst struct{}

type Blip

type Blip struct {
	Embed string `xml:"r:embed,attr"`
}

type BlipFill

type BlipFill struct {
	Blip    *Blip    `xml:"a:blip"`
	Stretch *Stretch `xml:"a:stretch"`
}

type Body

type Body struct {
	XMLName   xml.Name `xml:"w:body"`
	Paragraph []*Paragraph

	SectPr *SectPr `xml:"w:sectPr,omitempty"`
}

type Bold

type Bold struct {
	XMLName xml.Name `xml:"w:b"`
}

type Break

type Break struct {
	XMLName xml.Name `xml:"w:br"`
	Type    string   `xml:"w:type,attr,omitempty"`
}

type CNvPicPr

type CNvPicPr struct{}

type CNvPr

type CNvPr struct {
	ID   int    `xml:"id,attr"`
	Name string `xml:"name,attr"`
}

type Color

type Color struct {
	XMLName xml.Name `xml:"w:color"`
	Val     string   `xml:"w:val,attr"`
}

type DocPr

type DocPr struct {
	ID   int    `xml:"id,attr"`
	Name string `xml:"name,attr"`
}

type DocRelation

type DocRelation struct {
	XMLName      xml.Name        `xml:"Relationships"`
	Xmlns        string          `xml:"xmlns,attr"`
	Relationship []*RelationShip `xml:"Relationship"`
}

type Document

type Document struct {
	XMLName xml.Name `xml:"w:document"`
	XMLW    string   `xml:"xmlns:w,attr"`
	XMLR    string   `xml:"xmlns:r,attr"`
	Body    *Body
}

type Drawing

type Drawing struct {
	XMLName xml.Name `xml:"w:drawing"`
	Inline  *Inline  `xml:"wp:inline"`
}

type Extent

type Extent struct {
	Cx int64 `xml:"cx,attr"`
	Cy int64 `xml:"cy,attr"`
}

type File

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

func NewFile

func NewFile() *File

func (*File) AddParagraph

func (f *File) AddParagraph() *Paragraph

func (*File) Save

func (f *File) Save(path string) (err error)

func (*File) SetMarginsMM

func (f *File) SetMarginsMM(top, right, bottom, left int)

func (*File) SetPageSizeA4

func (f *File) SetPageSizeA4()

func (*File) UseTimesNewRomanDefault

func (f *File) UseTimesNewRomanDefault()

func (*File) Write

func (f *File) Write(writer io.Writer) (err error)

type FillRect

type FillRect struct{}

type Graphic

type Graphic struct {
	XMLName     xml.Name     `xml:"a:graphic"`
	GraphicData *GraphicData `xml:"a:graphicData"`
}

type GraphicData

type GraphicData struct {
	XMLName xml.Name `xml:"a:graphicData"`
	Uri     string   `xml:"uri,attr"`
	Pic     *Pic     `xml:"pic:pic"`
}
type Hyperlink struct {
	XMLName xml.Name `xml:"w:hyperlink"`
	ID      string   `xml:"r:id,attr"`
	Run     Run
}

type Inline

type Inline struct {
	XMLName  xml.Name `xml:"wp:inline"`
	XmlnsWp  string   `xml:"xmlns:wp,attr,omitempty"`
	Extent   *Extent  `xml:"wp:extent"`
	DocPr    *DocPr   `xml:"wp:docPr"`
	Graphic  *Graphic `xml:"a:graphic"`
	XmlnsA   string   `xml:"xmlns:a,attr,omitempty"`
	XmlnsPic string   `xml:"xmlns:pic,attr,omitempty"`
}

type Italic

type Italic struct {
	XMLName xml.Name `xml:"w:i"`
}

type Justification

type Justification struct {
	XMLName xml.Name `xml:"w:jc"`
	Val     string   `xml:"w:val,attr"`
}

type NvPicPr

type NvPicPr struct {
	CNvPr    *CNvPr    `xml:"pic:cNvPr"`
	CNvPicPr *CNvPicPr `xml:"pic:cNvPicPr"`
}

type Off

type Off struct {
	X int64 `xml:"x,attr"`
	Y int64 `xml:"y,attr"`
}

type Paragraph

type Paragraph struct {
	XMLName xml.Name             `xml:"w:p"`
	PPr     *ParagraphProperties `xml:"w:pPr,omitempty"`
	Data    []interface{}
	// contains filtered or unexported fields
}

func (*Paragraph) AddAnyImageAuto added in v1.1.0

func (p *Paragraph) AddAnyImageAuto(data []byte, ext string, maxWidthPx int) *Drawing

func (*Paragraph) AddBreak

func (p *Paragraph) AddBreak()

func (*Paragraph) AddImage

func (p *Paragraph) AddImage(data []byte, ext string, widthPx, heightPx int) *Drawing

func (*Paragraph) AddImageAuto

func (p *Paragraph) AddImageAuto(data []byte, ext string, maxWidthPx int) *Drawing

func (*Paragraph) AddImageWithCaption

func (p *Paragraph) AddImageWithCaption(data []byte, ext string, widthPx, heightPx int, caption string)

func (*Paragraph) AddLabelValue

func (p *Paragraph) AddLabelValue(label, value string)
func (p *Paragraph) AddLink(text string, link string) *Hyperlink

func (*Paragraph) AddMultilineText

func (p *Paragraph) AddMultilineText(text string)

func (*Paragraph) AddPageBreak

func (p *Paragraph) AddPageBreak()

func (*Paragraph) AddText

func (p *Paragraph) AddText(text string) *Run

func (*Paragraph) AlignCenter

func (p *Paragraph) AlignCenter() *Paragraph

func (*Paragraph) AlignLeft

func (p *Paragraph) AlignLeft() *Paragraph

func (*Paragraph) AlignRight

func (p *Paragraph) AlignRight() *Paragraph

func (*Paragraph) Justify

func (p *Paragraph) Justify() *Paragraph

type ParagraphProperties

type ParagraphProperties struct {
	XMLName       xml.Name       `xml:"w:pPr"`
	Justification *Justification `xml:"w:jc,omitempty"`
}

type PgMar

type PgMar struct {
	Top    int `xml:"w:top,attr"`
	Right  int `xml:"w:right,attr"`
	Bottom int `xml:"w:bottom,attr"`
	Left   int `xml:"w:left,attr"`
}

type PgSz

type PgSz struct {
	W      int    `xml:"w:w,attr"`
	H      int    `xml:"w:h,attr"`
	Orient string `xml:"w:orient,attr,omitempty"`
}

type Pic

type Pic struct {
	XMLName  xml.Name  `xml:"pic:pic"`
	NvPicPr  *NvPicPr  `xml:"pic:nvPicPr"`
	BlipFill *BlipFill `xml:"pic:blipFill"`
	SpPr     *SpPr     `xml:"pic:spPr"`
}

type PrstGeom

type PrstGeom struct {
	Prst  string `xml:"prst,attr"`
	AvLst *AvLst `xml:"a:avLst"`
}

type RelationShip

type RelationShip struct {
	XMLName    xml.Name `xml:"Relationship"`
	ID         string   `xml:"Id,attr"`
	Type       string   `xml:"Type,attr"`
	Target     string   `xml:"Target,attr"`
	TargetMode string   `xml:"TargetMode,attr,omitempty"`
}

type Run

type Run struct {
	XMLName       xml.Name       `xml:"w:r"`
	RunProperties *RunProperties `xml:"w:rPr,omitempty"`
	InstrText     string         `xml:"w:instrText,omitempty"`
	Text          *Text

	Drawing *Drawing `xml:"w:drawing,omitempty"`
}

func (*Run) Bold

func (r *Run) Bold() *Run

func (*Run) Color

func (r *Run) Color(color string) *Run

func (*Run) Font

func (r *Run) Font(name string) *Run

func (*Run) Italic

func (r *Run) Italic() *Run

func (*Run) Size

func (r *Run) Size(size int) *Run

func (*Run) Underline

func (r *Run) Underline() *Run

type RunFonts

type RunFonts struct {
	XMLName  xml.Name `xml:"w:rFonts"`
	Ascii    string   `xml:"w:ascii,attr,omitempty"`
	HAnsi    string   `xml:"w:hAnsi,attr,omitempty"`
	CS       string   `xml:"w:cs,attr,omitempty"`
	EastAsia string   `xml:"w:eastAsia,attr,omitempty"`
}

type RunProperties

type RunProperties struct {
	XMLName  xml.Name  `xml:"w:rPr"`
	Color    *Color    `xml:"w:color,omitempty"`
	Size     *Size     `xml:"w:sz,omitempty"`
	RunStyle *RunStyle `xml:"w:rStyle,omitempty"`

	RFonts    *RunFonts  `xml:"w:rFonts,omitempty"`
	Bold      *Bold      `xml:"w:b,omitempty"`
	Italic    *Italic    `xml:"w:i,omitempty"`
	Underline *Underline `xml:"w:u,omitempty"`
}

type RunStyle

type RunStyle struct {
	XMLName xml.Name `xml:"w:rStyle"`
	Val     string   `xml:"w:val,attr"`
}

type SectPr

type SectPr struct {
	XMLName xml.Name `xml:"w:sectPr"`
	PgSz    *PgSz    `xml:"w:pgSz,omitempty"`
	PgMar   *PgMar   `xml:"w:pgMar,omitempty"`
}

type Size

type Size struct {
	XMLName xml.Name `xml:"w:sz"`
	Val     int      `xml:"w:val,attr"`
}

type SpPr

type SpPr struct {
	Xfrm     *Xfrm     `xml:"a:xfrm"`
	PrstGeom *PrstGeom `xml:"a:prstGeom"`
}

type Stretch

type Stretch struct {
	FillRect *FillRect `xml:"a:fillRect"`
}

type Text

type Text struct {
	XMLName  xml.Name `xml:"w:t"`
	XMLSpace string   `xml:"xml:space,attr,omitempty"`
	Text     string   `xml:",chardata"`
}

type Underline

type Underline struct {
	XMLName xml.Name `xml:"w:u"`
	Val     string   `xml:"w:val,attr,omitempty"`
}

type Xfrm

type Xfrm struct {
	Off *Off  `xml:"a:off"`
	Ext *AExt `xml:"a:ext"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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