Field constants
const ( FieldCurrentPage = "PAGE" FieldNumberOfPages = "NUMPAGES" FieldDate = "DATE" FieldCreateDate = "CREATEDATE" FieldEditTime = "EDITTIME" FieldPrintDate = "PRINTDATE" FieldSaveDate = "SAVEDATE" FieldTIme = "TIME" FieldTOC = "TOC" )
var ( // FootnoteTextStyleId is the style id used for footnote text. FootnoteTextStyleId = "FootnoteText" // EndnoteTextStyleId is the style id used for endnote text. EndnoteTextStyleId = "EndnoteText" )
AnchorDrawWrapOptions is options to set wrapPolygon for wrap text through and tight.
type AnchorDrawWrapOptions struct {
// contains filtered or unexported fields
}
func NewAnchorDrawWrapOptions() *AnchorDrawWrapOptions
NewAnchorDrawWrapOptions return anchor drawing options property.
func (option AnchorDrawWrapOptions) GetWrapPathLineTo() []*dml.CT_Point2D
GetWrapPathLineTo return wrapPath lineTo value.
func (option AnchorDrawWrapOptions) GetWrapPathStart() *dml.CT_Point2D
GetWrapPathStart return wrapPath start value.
func (option AnchorDrawWrapOptions) SetFollowImageShape(val bool)
SetFollowImageShape sets wrapPath to follow image shape, if nil return wrapPath that follow image size.
func (option AnchorDrawWrapOptions) SetWrapPathLineTo(coordinates []*dml.CT_Point2D)
SetWrapPathLineTo sets wrapPath lineTo value.
func (option AnchorDrawWrapOptions) SetWrapPathStart(coordinate *dml.CT_Point2D)
SetWrapPathStart sets wrapPath start value.
AnchoredDrawing is an absolutely positioned image within a document page.
type AnchoredDrawing struct {
// contains filtered or unexported fields
}
func (a AnchoredDrawing) GetImage() (common.ImageRef, bool)
GetImage returns the ImageRef associated with an AnchoredDrawing.
func (a AnchoredDrawing) GetSize() (w, h int64)
GetSize return the size of anchor on the page.
func (a AnchoredDrawing) SetAlignment(h wml.WdST_AlignH, v wml.WdST_AlignV)
SetAlignment positions an anchored image via alignment. Offset is incompatible with SetOffset, whichever is called last is applied.
func (a AnchoredDrawing) SetAllowOverlapAttr(val bool)
SetAllowOverlapAttr sets the allowOverlap attribute of anchor.
func (a AnchoredDrawing) SetBehindDoc(val bool)
SetBehindDoc sets the behindDoc attribute of anchor.
func (a AnchoredDrawing) SetHAlignment(h wml.WdST_AlignH)
SetHAlignment sets the horizontal alignment for an anchored image.
func (a AnchoredDrawing) SetLayoutInCell(val bool)
SetLayoutInCell sets the layoutInCell attribute of anchor.
func (a AnchoredDrawing) SetName(name string)
SetName sets the name of the image, visible in the properties of the image within Word.
func (a AnchoredDrawing) SetOffset(x, y measurement.Distance)
SetOffset sets the offset of the image relative to the origin, which by default this is the top-left corner of the page. Offset is incompatible with SetAlignment, whichever is called last is applied.
func (a AnchoredDrawing) SetOrigin(h wml.WdST_RelFromH, v wml.WdST_RelFromV)
SetOrigin sets the origin of the image. It defaults to ST_RelFromHPage and ST_RelFromVPage
func (a AnchoredDrawing) SetSize(w, h measurement.Distance)
SetSize sets the size of the displayed image on the page.
func (a AnchoredDrawing) SetTextWrapBehindText()
SetTextWrapBehindText sets the text wrap to behind text.
func (a AnchoredDrawing) SetTextWrapInFrontOfText()
SetTextWrapInFrontOfText sets the text wrap to in front of text.
func (a AnchoredDrawing) SetTextWrapNone()
SetTextWrapNone unsets text wrapping so the image can float on top of the text. When used in conjunction with X/Y Offset relative to the page it can be used to place a logo at the top of a page at an absolute position that doesn't interfere with text.
func (a AnchoredDrawing) SetTextWrapSquare(t wml.WdST_WrapText)
SetTextWrapSquare sets the text wrap to square with a given wrap type.
func (a AnchoredDrawing) SetTextWrapThrough(option *AnchorDrawWrapOptions)
SetTextWrapThrough sets the text wrap to through with a give wrap type.
func (a AnchoredDrawing) SetTextWrapTight(option *AnchorDrawWrapOptions)
SetTextWrapTight sets the text wrap to tight with a give wrap type.
func (a AnchoredDrawing) SetTextWrapTopAndBottom()
SetTextWrapTopAndBottom sets the text wrap to top and bottom.
func (a AnchoredDrawing) SetVAlignment(v wml.WdST_AlignV)
SetVAlignment sets the vertical alignment for an anchored image.
func (a AnchoredDrawing) SetXOffset(x measurement.Distance)
SetXOffset sets the X offset for an image relative to the origin.
func (a AnchoredDrawing) SetYOffset(y measurement.Distance)
SetYOffset sets the Y offset for an image relative to the origin.
func (a AnchoredDrawing) X() *wml.WdAnchor
X returns the inner wrapped XML type.
Bookmark is a bookmarked location within a document that can be referenced with a hyperlink.
type Bookmark struct {
// contains filtered or unexported fields
}
func (b Bookmark) Name() string
Name returns the name of the bookmark whcih is the document unique ID that identifies the bookmark.
func (b Bookmark) SetName(name string)
SetName sets the name of the bookmark. This is the name that is used to reference the bookmark from hyperlinks.
func (b Bookmark) X() *wml.CT_Bookmark
X returns the inner wrapped XML type.
Cell is a table cell within a document (not a spreadsheet)
type Cell struct {
// contains filtered or unexported fields
}
func (c Cell) AddParagraph() Paragraph
AddParagraph adds a paragraph to the table cell.
func (c Cell) AddTable() Table
AddTable adds a table to the table cell.
func (c Cell) Paragraphs() []Paragraph
Paragraphs returns the paragraphs defined in the cell.
func (c Cell) Properties() CellProperties
Properties returns the cell properties.
func (c Cell) X() *wml.CT_Tc
X returns the inner wrapped XML type.
CellBorders are the borders for an individual
type CellBorders struct {
// contains filtered or unexported fields
}
func (b CellBorders) SetAll(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetAll sets all of the borders to a given value.
func (b CellBorders) SetBottom(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetBottom sets the bottom border to a specified type, color and thickness.
func (b CellBorders) SetInsideHorizontal(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideHorizontal sets the interior horizontal borders to a specified type, color and thickness.
func (b CellBorders) SetInsideVertical(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideVertical sets the interior vertical borders to a specified type, color and thickness.
func (b CellBorders) SetLeft(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetLeft sets the left border to a specified type, color and thickness.
func (b CellBorders) SetRight(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetRight sets the right border to a specified type, color and thickness.
func (b CellBorders) SetTop(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetTop sets the top border to a specified type, color and thickness.
func (b CellBorders) X() *wml.CT_TcBorders
X returns the inner wrapped type
CellMargins are the margins for an individual cell.
type CellMargins struct {
// contains filtered or unexported fields
}
func (c CellMargins) SetBottom(d measurement.Distance)
SetBottom sets the cell bottom margin
func (c CellMargins) SetBottomPct(pct float64)
SetBottomPct sets the cell bottom margin
func (c CellMargins) SetLeft(d measurement.Distance)
SetLeft sets the cell left margin
func (c CellMargins) SetLeftPct(pct float64)
SetLeftPct sets the cell left margin
func (c CellMargins) SetRight(d measurement.Distance)
SetRight sets the cell right margin
func (c CellMargins) SetRightPct(pct float64)
SetRightPct sets the cell right margin
func (c CellMargins) SetStart(d measurement.Distance)
SetStart sets the cell start margin
func (c CellMargins) SetStartPct(pct float64)
SetStartPct sets the cell start margin
func (c CellMargins) SetTop(d measurement.Distance)
SetTop sets the cell top margin
func (c CellMargins) SetTopPct(pct float64)
SetTopPct sets the cell top margin
CellProperties are a table cells properties within a document.
type CellProperties struct {
// contains filtered or unexported fields
}
func (c CellProperties) Borders() CellBorders
Borders allows controlling individual cell borders.
func (c CellProperties) Margins() CellMargins
Margins allows controlling individual cell margins.
func (c CellProperties) SetColumnSpan(cols int)
SetColumnSpan sets the number of Grid Columns Spanned by the Cell. This is used to give the appearance of merged cells.
func (c CellProperties) SetShading(shd wml.ST_Shd, foreground, fill color.Color)
SetShading controls the cell shading.
func (c CellProperties) SetVerticalAlignment(align wml.ST_VerticalJc)
SetVerticalAlignment sets the vertical alignment of content within a table cell.
func (c CellProperties) SetVerticalMerge(mergeVal wml.ST_Merge)
SetVerticalMerge controls the vertical merging of cells.
func (c CellProperties) SetWidth(d measurement.Distance)
SetWidth sets the cell width to a specified width.
func (c CellProperties) SetWidthAuto()
SetWidthAuto sets the the cell width to automatic.
func (c CellProperties) SetWidthPercent(pct float64)
SetWidthPercent sets the cell to a width percentage.
func (c CellProperties) X() *wml.CT_TcPr
X returns the inner wrapped XML type.
Color controls the run or styles color.
type Color struct {
// contains filtered or unexported fields
}
func (c Color) SetColor(v color.Color)
SetColor sets a specific color or auto.
func (c Color) SetThemeColor(t wml.ST_ThemeColor)
SetThemeColor sets the color from the theme.
func (c Color) SetThemeShade(s uint8)
SetThemeShade sets the shade based off the theme color.
func (c Color) X() *wml.CT_Color
X returns the inner wrapped XML type.
DocText is an array of extracted text items which has some methods for representing extracted text.
type DocText struct { Items []TextItem // contains filtered or unexported fields }
func (d *DocText) Text() string
Text returns text from the document as one string separated with line breaks.
func (d *DocText) TextWithOptions(options ExtractTextOptions) string
TextWithOptions extract text with options.
Document is a text document that can be written out in the OOXML .docx format. It can be opened from a file on disk and modified, or created from scratch.
type Document struct { common.DocBase Settings Settings // document settings Numbering Numbering // numbering styles within the document Styles Styles // styles that are use and can be used within the document // contains filtered or unexported fields }
func New() *Document
New constructs an empty document that content can be added to.
func Open(filename string) (*Document, error)
Open opens and reads a document from a file (.docx).
func OpenTemplate(filename string) (*Document, error)
OpenTemplate opens a document, removing all content so it can be used as a template. Since Word removes unused styles from a document upon save, to create a template in Word add a paragraph with every style of interest. When opened with OpenTemplate the document's styles will be available but the content will be gone.
func Read(r io.ReaderAt, size int64) (*Document, error)
read reads a document from an io.Reader.
func (d *Document) AddFooter() Footer
AddFooter creates a Footer associated with the document, but doesn't add it to the document for display.
func (d *Document) AddHeader() Header
AddHeader creates a header associated with the document, but doesn't add it to the document for display.
func (d Document) AddHyperlink(url string) common.Hyperlink
AddHyperlink adds a hyperlink to a document. Adding the hyperlink to a document and setting it on a cell is more efficient than setting hyperlinks directly on a cell.
func (d *Document) AddImage(i common.Image) (common.ImageRef, error)
AddImage adds an image to the document package, returning a reference that can be used to add the image to a run and place it in the document contents.
func (d *Document) AddParagraph() Paragraph
AddParagraph adds a new paragraph to the document body.
func (d *Document) AddTable() Table
AddTable adds a new table to the document body.
func (d *Document) AddWatermarkPicture(imageRef common.ImageRef) WatermarkPicture
AddWatermarkPicture adds new watermark picture to document.
func (d *Document) AddWatermarkText(text string) WatermarkText
AddWatermarkText adds new watermark text to the document.
func (d0 *Document) Append(d1orig *Document) error
Append appends a document d0 to a document d1. All settings, headers and footers remain the same as in the document d0 if they exist there, otherwise they are taken from the d1.
func (d *Document) AppendNode(node Node)
AppendNode append node to document element.
func (d *Document) BodySection() Section
BodySection returns the default body section used for all preceding paragraphs until the previous Section. If there is no previous sections, the body section applies to the entire document.
func (d Document) Bookmarks() []Bookmark
Bookmarks returns all of the bookmarks defined in the document.
func (d *Document) Close() error
Close closes the document, removing any temporary files that might have been created when opening a document.
func (d *Document) Copy() (*Document, error)
Copy makes a deep copy of the document by saving and reading it back. It can be useful to avoid sharing common data between two documents.
func (d *Document) DocRels() common.Relationships
DocRels returns document relationship.
func (d *Document) Endnote(id int64) Endnote
Endnote returns the endnote based on the ID; this can be used nicely with the run.IsEndnote() functionality.
func (d *Document) Endnotes() []Endnote
Endnotes returns the endnotes defined in the document.
func (d *Document) ExtractText() *DocText
ExtractText returns text from the document as a DocText object.
func (d *Document) FontTable() *wml.Fonts
FontTable returns document fontTable element.
func (d *Document) Footers() []Footer
Footers returns the footers defined in the document.
func (d *Document) Footnote(id int64) Footnote
Footnote returns the footnote based on the ID; this can be used nicely with the run.IsFootnote() functionality.
func (d *Document) Footnotes() []Footnote
Footnotes returns the footnotes defined in the document.
func (d *Document) FormFields() []FormField
FormFields extracts all of the fields from a document. They can then be manipulated via the methods on the field and the document saved.
func (d *Document) GetChartSpaceByRelId(relId string) *crt.ChartSpace
GetChartSpaceByRelId returns a *crt.ChartSpace with the associated relation ID in the document.
func (d *Document) GetDocRelTargetByID(idAttr string) string
GetDocRelTargetByID returns TargetAttr of document relationship given its IdAttr.
func (d *Document) GetFontBytesByRelId(relID string) ([]byte, error)
func (d *Document) GetImageByRelID(relID string) (common.ImageRef, bool)
GetImageByRelID returns an ImageRef with the associated relation ID in the document.
func (d *Document) GetImageObjByRelId(relId string) (common.Image, error)
GetImageObjByRelId returns a common.Image with the associated relation ID in the document.
func (d *Document) GetNumberingLevelByIds(numId, levelId int64) NumberingLevel
GetNumberingLevelByIds returns a NumberingLevel by its NumId and LevelId attributes or an empty one if not found.
func (d *Document) GetStyleByID(id string) Style
GetStyleByID returns Style by it's IdAttr.
func (d *Document) GetTargetByRelId(idAttr string) string
GetTargetByRelId returns a target path with the associated relation ID in the document.
func (d *Document) HasEndnotes() bool
HasEndnotes returns a bool based on the presence or abscence of endnotes within the document.
func (d *Document) HasFootnotes() bool
HasFootnotes returns a bool based on the presence or abscence of footnotes within the document.
func (d *Document) Headers() []Header
Headers returns the headers defined in the document.
func (d *Document) InsertParagraphAfter(relativeTo Paragraph) Paragraph
InsertParagraphAfter adds a new empty paragraph after the relativeTo paragraph.
func (d *Document) InsertParagraphBefore(relativeTo Paragraph) Paragraph
InsertParagraphBefore adds a new empty paragraph before the relativeTo paragraph.
func (d *Document) InsertTableAfter(relativeTo Paragraph) Table
func (d *Document) InsertTableBefore(relativeTo Paragraph) Table
func (d *Document) MailMerge(mergeContent map[string]string)
MailMerge finds mail merge fields and replaces them with the text provided. It also removes the mail merge source info from the document settings.
func (d Document) MergeFields() []string
MergeFields returns the list of all mail merge fields found in the document.
func (d *Document) Nodes() Nodes
Nodes return the document's element as nodes.
func (d *Document) Paragraphs() []Paragraph
Paragraphs returns all of the paragraphs in the document body including tables.
func (d *Document) PutNodeAfter(relativeTo, node Node)
PutNodeAfter put node to position after relativeTo.
func (d *Document) PutNodeBefore(relativeTo, node Node)
PutNodeBefore put node to position before relativeTo.
func (d *Document) RemoveParagraph(p Paragraph)
RemoveParagraph removes a paragraph from a document.
func (d *Document) Save(w io.Writer) error
Save writes the document to an io.Writer in the Zip package format.
func (d *Document) SaveToFile(path string) error
SaveToFile writes the document out to a file.
func (d Document) SetConformance(conformanceAttr st.ST_ConformanceClass)
SetConformance sets conformance attribute of the document as one of these values from github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes: ST_ConformanceClassUnset, ST_ConformanceClassStrict or ST_ConformanceClassTransitional.
func (d Document) SetStrict(strict bool)
SetStrict is a shortcut for document.SetConformance, as one of these values from github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes: ST_ConformanceClassUnset, ST_ConformanceClassStrict or ST_ConformanceClassTransitional.
func (d *Document) StructuredDocumentTags() []StructuredDocumentTag
StructuredDocumentTags returns the structured document tags in the document which are commonly used in document templates.
func (d *Document) Tables() []Table
Tables returns the tables defined in the document.
func (d *Document) Themes() []*dml.Theme
Themes returns document's themes.
func (d *Document) Validate() error
Validate validates the structure and in cases where it't possible, the ranges of elements within a document. A validation error dones't mean that the document won't work in MS Word or LibreOffice, but it's worth checking into.
func (d *Document) X() *wml.Document
X returns the inner wrapped XML type.
DrawingInfo is used for keep information about a drawing wrapping a textbox where the text is located.
type DrawingInfo struct { Drawing *wml.CT_Drawing Width int64 Height int64 }
Endnote is an individual endnote reference within the document.
type Endnote struct {
// contains filtered or unexported fields
}
func (e Endnote) AddParagraph() Paragraph
AddParagraph adds a paragraph to the endnote.
func (e Endnote) Paragraphs() []Paragraph
Paragraphs returns the paragraphs defined in an endnote.
func (e Endnote) RemoveParagraph(p Paragraph)
RemoveParagraph removes a paragraph from the endnote.
func (e Endnote) X() *wml.CT_FtnEdn
X returns the inner wrapped XML type.
ExtractTextOptions extraction text options.
type ExtractTextOptions struct { // WithNumbering extract numbering elements if set to `true`. WithNumbering bool // NumberingIndent default value of numbering indent. NumberingIndent string // RunsOnNewLine write each of runs text on new line if set to `true`. RunsOnNewLine bool }
Fonts allows manipulating a style or run's fonts.
type Fonts struct {
// contains filtered or unexported fields
}
func (f Fonts) SetASCIITheme(t wml.ST_Theme)
SetASCIITheme sets the font ASCII Theme.
func (f Fonts) SetCSTheme(t wml.ST_Theme)
SetCSTheme sets the font complex script theme.
func (f Fonts) SetEastAsiaTheme(t wml.ST_Theme)
SetEastAsiaTheme sets the font East Asia Theme.
func (f Fonts) SetHANSITheme(t wml.ST_Theme)
SetHANSITheme sets the font H ANSI Theme.
func (f Fonts) X() *wml.CT_Fonts
X returns the inner wrapped XML type.
Footer is a footer for a document section.
type Footer struct {
// contains filtered or unexported fields
}
func (f Footer) AddImage(i common.Image) (common.ImageRef, error)
AddImage adds an image to the document package, returning a reference that can be used to add the image to a run and place it in the document contents.
func (f Footer) AddParagraph() Paragraph
AddParagraph adds a paragraph to the footer.
func (f Footer) Clear()
Clear clears all content within a footer
func (f Footer) Index() int
Index returns the index of the footer within the document. This is used to form its zip packaged filename as well as to match it with its relationship ID.
func (f Footer) Paragraphs() []Paragraph
Paragraphs returns the paragraphs defined in a footer.
func (f Footer) RemoveParagraph(p Paragraph)
RemoveParagraph removes a paragraph from a footer.
func (f Footer) Tables() []Table
Tables returns the tables defined in the footer.
func (f Footer) X() *wml.Ftr
X returns the inner wrapped XML type.
Footnote is an individual footnote reference within the document.
type Footnote struct {
// contains filtered or unexported fields
}
func (f Footnote) AddParagraph() Paragraph
AddParagraph adds a paragraph to the footnote.
func (f Footnote) Paragraphs() []Paragraph
Paragraphs returns the paragraphs defined in a footnote.
func (f Footnote) RemoveParagraph(p Paragraph)
RemoveParagraph removes a paragraph from the footnote.
func (f Footnote) X() *wml.CT_FtnEdn
X returns the inner wrapped XML type.
FormField is a form within a document. It references the document, so changes to the form field wil be reflected in the document if it is saved.
type FormField struct {
// contains filtered or unexported fields
}
func (f FormField) IsChecked() bool
IsChecked returns true if a FormFieldTypeCheckBox is checked.
func (f FormField) Name() string
Name returns the name of the field.
func (f FormField) PossibleValues() []string
PossibleValues returns the possible values for a FormFieldTypeDropDown.
func (f FormField) SetCalcOnExit(calcOnExit bool)
SetCalcOnExit marks if a FormField should be CalcOnExit or not.
func (f FormField) SetChecked(b bool)
SetChecked marks a FormFieldTypeCheckBox as checked or unchecked.
func (f FormField) SetDefaultValue(v string)
SetDefaultValue sets the default value of a FormFieldTypeDropDown. For FormFieldTypeDropDown, the value must be one of the fields possible values.
func (f FormField) SetEnabled(enabled bool)
SetEnabled marks a FormField as enabled or disabled.
func (f FormField) SetName(name string)
SetName marks sets a name attribute for a FormField.
func (f FormField) SetPossibleValues(values []string)
SetPossibleValues sets possible values for a FormFieldTypeDropDown.
func (f FormField) SetSize(size uint64)
SetSize sets size attribute for a FormFieldTypeCheckBox in pt.
func (f FormField) SetValue(v string)
SetValue sets the value of a FormFieldTypeText or FormFieldTypeDropDown. For FormFieldTypeDropDown, the value must be one of the fields possible values.
func (f FormField) Type() FormFieldType
Type returns the type of the field.
func (f FormField) Value() string
Value returns the tring value of a FormFieldTypeText or FormFieldTypeDropDown.
FormFieldType is the type of the form field.
type FormFieldType byte
Form Field Type constants
const ( FormFieldTypeUnknown FormFieldType = iota FormFieldTypeText FormFieldTypeCheckBox FormFieldTypeDropDown )
func (i FormFieldType) String() string
Header is a header for a document section.
type Header struct {
// contains filtered or unexported fields
}
func (h Header) AddImage(i common.Image) (common.ImageRef, error)
AddImage adds an image to the document package, returning a reference that can be used to add the image to a run and place it in the document contents.
func (h Header) AddImageRef(r common.ImageRef) (common.ImageRef, error)
AddImageRef add ImageRef to header as relationship, returning ImageRef that can be used to be placed as header content.
func (h Header) AddParagraph() Paragraph
AddParagraph adds a paragraph to the header.
func (h Header) Clear()
Clear clears all content within a header
func (h Header) Index() int
Index returns the index of the header within the document. This is used to form its zip packaged filename as well as to match it with its relationship ID.
func (h Header) Paragraphs() []Paragraph
Paragraphs returns the paragraphs defined in a header.
func (h Header) RemoveParagraph(p Paragraph)
RemoveParagraph removes a paragraph from a footer.
func (h Header) Tables() []Table
Tables returns the tables defined in the header.
func (h Header) X() *wml.Hdr
X returns the inner wrapped XML type.
HyperLink is a link within a document.
type HyperLink struct {
// contains filtered or unexported fields
}
func (h HyperLink) AddRun() Run
AddRun adds a run of text to a hyperlink. This is the text that will be linked.
func (h HyperLink) SetTarget(url string)
SetTarget sets the URL target of the hyperlink.
func (h HyperLink) SetTargetBookmark(bm Bookmark)
SetTargetBookmark sets the bookmark target of the hyperlink.
func (h HyperLink) SetTargetByRef(link common.Hyperlink)
SetTargetByRef sets the URL target of the hyperlink and is more efficient if a link destination will be used many times.
func (h HyperLink) SetToolTip(text string)
SetToolTip sets the tooltip text for a hyperlink.
func (h HyperLink) X() *wml.CT_Hyperlink
X returns the inner wrapped XML type.
InlineDrawing is an inlined image within a run.
type InlineDrawing struct {
// contains filtered or unexported fields
}
func (i InlineDrawing) GetImage() (common.ImageRef, bool)
GetImage returns the ImageRef associated with an InlineDrawing.
func (i InlineDrawing) SetSize(w, h measurement.Distance)
SetSize sets the size of the displayed image on the page.
func (i InlineDrawing) X() *wml.WdInline
X returns the inner wrapped XML type.
Node is document element node, contains Paragraph or Table element.
type Node struct { Style Style AnchoredDrawings []AnchoredDrawing InlineDrawings []InlineDrawing Children []Node // contains filtered or unexported fields }
func (n *Node) Clear()
Clear content of node element.
func (n *Node) ReplaceText(oldText, newText string)
ReplaceText replace the text inside node.
func (n *Node) ReplaceTextByRegexp(rgx *regexp.Regexp, newText string)
ReplaceTextByRegexp replace the text within node using regexp expression.
func (n *Node) Text() string
Text return node and its child text,
func (n *Node) X() interface{}
X return element of Node as interface, can be either *Paragraph, *Table and Run.
Nodes contains slice of Node element.
type Nodes struct {
// contains filtered or unexported fields
}
func (n *Nodes) FindNodeByCondition(f func(node *Node) bool, wholeElements bool) []Node
FindNodeByCondition return node based on condition function, if wholeElements is true, its will extract childs as next node elements.
func (n *Nodes) FindNodeByRegexp(r *regexp.Regexp) []Node
FindNodeByText return node based on matched text and return a slice of node.
func (n *Nodes) FindNodeByStyleId(styleId string) []Node
FindNodeByStyleId return slice of node base on style id.
func (n *Nodes) FindNodeByStyleName(styleName string) []Node
FindNodeByStyleName return slice of node base on style name.
func (n *Nodes) FindNodeByText(text string) []Node
FindNodeByText return node based on matched text and return a slice of node.
func (n *Nodes) ReplaceText(oldText, newText string)
ReplaceText replace text inside node.
func (n *Nodes) ReplaceTextByRegexp(expr *regexp.Regexp, newText string)
ReplaceTextByRegexp replace text inside node using regexp.
func (n *Nodes) X() []Node
X return slice of node.
Numbering is the document wide numbering styles contained in numbering.xml.
type Numbering struct {
// contains filtered or unexported fields
}
func NewNumbering() Numbering
NewNumbering constructs a new numbering.
func (n Numbering) AddDefinition() NumberingDefinition
AddDefinition adds a new numbering definition.
func (n Numbering) Clear()
Clear resets the numbering.
func (n Numbering) Definitions() []NumberingDefinition
Definitions returns the defined numbering definitions.
func (n Numbering) InitializeDefault()
InitializeDefault constructs a default numbering.
func (n *Numbering) Restart(nd *NumberingDefinition)
Restart restarts the numbering
func (n Numbering) X() *wml.Numbering
X returns the inner wrapped XML type.
NumberingDefinition defines a numbering definition for a list of pragraphs.
type NumberingDefinition struct {
// contains filtered or unexported fields
}
func (n NumberingDefinition) AbstractNumberID() int64
AbstractNumberID returns the ID that is unique within all numbering definitions that is used to assign the definition to a paragraph.
func (n NumberingDefinition) AddLevel() NumberingLevel
AddLevel adds a new numbering level to a NumberingDefinition.
func (n NumberingDefinition) Levels() []NumberingLevel
Levels returns all of the numbering levels defined in the definition.
func (n NumberingDefinition) MultiLevelType() wml.ST_MultiLevelType
MultiLevelType returns the multilevel type, or ST_MultiLevelTypeUnset if not set.
func (n NumberingDefinition) SetMultiLevelType(t wml.ST_MultiLevelType)
SetMultiLevelType sets the multilevel type.
func (n NumberingDefinition) X() *wml.CT_AbstractNum
X returns the inner wrapped XML type.
NumberingLevel is the definition for numbering for a particular level within a NumberingDefinition.
type NumberingLevel struct {
// contains filtered or unexported fields
}
func (n NumberingLevel) Properties() ParagraphStyleProperties
Properties returns the numbering level paragraph properties.
func (n NumberingLevel) RunProperties() RunProperties
RunProperties returns the RunProperties controlling numbering level font, etc.
func (n NumberingLevel) SetAlignment(j wml.ST_Jc)
SetAlignment sets the paragraph alignment
func (n NumberingLevel) SetFormat(f wml.ST_NumberFormat)
SetFormat sets the numbering format.
func (n NumberingLevel) SetText(t string)
SetText sets the text to be used in bullet mode.
func (n NumberingLevel) X() *wml.CT_Lvl
X returns the inner wrapped XML type.
OnOffValue represents an on/off value that can also be unset
type OnOffValue byte
OnOffValue constants
const ( OnOffValueUnset OnOffValue = iota OnOffValueOff OnOffValueOn )
Paragraph is a paragraph within a document.
type Paragraph struct {
// contains filtered or unexported fields
}
func (p Paragraph) AddBookmark(name string) Bookmark
AddBookmark adds a bookmark to a document that can then be used from a hyperlink. Name is a document unique name that identifies the bookmark so it can be referenced from hyperlinks.
func (p Paragraph) AddCheckBox(name string) FormField
AddCheckBox adds checkbox form field to the paragraph and returns it.
func (p Paragraph) AddDropdownList(name string) FormField
AddDropdownList adds dropdown list form field to the paragraph and returns it.
func (p Paragraph) AddEndnote(text string) Endnote
AddEndnote will create a new endnote and attach it to the Paragraph in the location at the end of the previous run (endnotes create their own run within the paragraph. The text given to the function is simply a convenience helper, paragraphs and runs can always be added to the text of the endnote later.
func (p Paragraph) AddFootnote(text string) Footnote
AddFootnote will create a new footnote and attach it to the Paragraph in the location at the end of the previous run (footnotes create their own run within the paragraph). The text given to the function is simply a convenience helper, paragraphs and runs can always be added to the text of the footnote later.
func (p Paragraph) AddHyperLink() HyperLink
AddHyperLink adds a new hyperlink to a parapgraph.
func (p Paragraph) AddRun() Run
AddRun adds a run to a paragraph.
func (p Paragraph) AddTextInput(name string) FormField
AddTextInput adds text input form field to the paragraph and returns it.
func (p Paragraph) Borders() ParagraphBorders
Borders returns the ParagraphBorders for setting-up border on paragraph.
func (p Paragraph) IgnoreSpaceBetweenParagraphOfSameStyle()
IgnoreSpaceBetweenParagraphOfSameStyle sets contextual spacing.
func (p Paragraph) InsertRunAfter(relativeTo Run) Run
InsertRunAfter inserts a run in the paragraph after the relative run.
func (p Paragraph) InsertRunBefore(relativeTo Run) Run
InsertRunBefore inserts a run in the paragraph before the relative run.
func (p Paragraph) Numbering() Numbering
Numbering return numbering that being use by paragraph.
func (p Paragraph) Properties() ParagraphProperties
Properties returns the paragraph properties.
func (p Paragraph) RemoveEndnote(id int64)
RemoveEndnote removes a endnote from both the paragraph and the document the requested endnote must be anchored on the paragraph being referenced.
After each removal, the rest of the endnote ids would be reordered.
func (p Paragraph) RemoveFootnote(id int64)
RemoveFootnote removes a footnote from both the paragraph and the document the requested footnote must be anchored on the paragraph being referenced.
After each removal, the rest of the footnote ids would be reordered.
func (p Paragraph) RemoveRun(r Run)
RemoveRun removes a child run from a paragraph.
func (p Paragraph) Runs() []Run
Runs returns all of the runs in a paragraph.
func (p Paragraph) SetAfterLineSpacing(d measurement.Distance)
SetAfterLineSpacing sets spacing below paragraph in line units.
func (p Paragraph) SetAfterSpacing(d measurement.Distance)
SetAfterSpacing sets spacing below paragraph.
func (p Paragraph) SetAlignment(alignment wml.ST_Jc)
SetAlignment set alignment of paragraph.
func (p Paragraph) SetBeforeLineSpacing(d measurement.Distance)
// SetBeforeLineSpacing sets spacing above paragraph in line units.
func (p Paragraph) SetBeforeSpacing(d measurement.Distance)
SetBeforeSpacing sets spacing above paragraph.
func (p Paragraph) SetFirstLineIndent(m measurement.Distance)
SetFirstLineIndent controls the indentation of the first line in a paragraph.
func (p Paragraph) SetHangingIndent(m measurement.Distance)
SetHangingIndent controls special indent of paragraph.
func (p Paragraph) SetLeftIndent(m measurement.Distance)
SetLeftIndent controls left indent of paragraph.
func (p Paragraph) SetLineSpacing(d measurement.Distance, rule wml.ST_LineSpacingRule)
SetLineSpacing sets the spacing between lines in a paragraph.
func (p Paragraph) SetNumberingDefinition(nd NumberingDefinition)
SetNumberingDefinition sets the numbering definition ID via a NumberingDefinition defined in numbering.xml
func (p Paragraph) SetNumberingDefinitionByID(abstractNumberID int64)
SetNumberingDefinitionByID sets the numbering definition ID directly, which must match an ID defined in numbering.xml
func (p Paragraph) SetNumberingLevel(listLevel int)
SetNumberingLevel sets the numbering level of a paragraph. If used, then the NumberingDefinition must also be set via SetNumberingDefinition or SetNumberingDefinitionByID.
func (p Paragraph) SetOutlineLvl(lvl int64)
SetOutlineLvl sets outline level of paragraph.
func (p Paragraph) SetRightIndent(m measurement.Distance)
SetRightIndent controls right indent of paragraph.
func (p Paragraph) SetStyle(s string)
SetStyle sets the style of a paragraph and is identical to setting it on the paragraph's Properties()
func (p Paragraph) Style() string
Style returns the style for a paragraph, or an empty string if it is unset.
func (p Paragraph) X() *wml.CT_P
X returns the inner wrapped XML type.
ParagraphBorders allows manipulation of borders on a paragraph.
type ParagraphBorders struct {
// contains filtered or unexported fields
}
func (pb ParagraphBorders) SetAll(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetAll sets all of the borders to a given value.
func (pb ParagraphBorders) SetBetween(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetBetween sets the between border to a specified type, color and thickness between paragraph.
func (pb ParagraphBorders) SetBottom(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetBottom sets the bottom border to a specified type, color and thickness.
func (pb ParagraphBorders) SetLeft(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetLeft sets the left border to a specified type, color and thickness.
func (pb ParagraphBorders) SetRight(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetRight sets the right border to a specified type, color and thickness.
func (pb ParagraphBorders) SetTop(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetTop sets the top border to a specified type, color and thickness.
func (pb ParagraphBorders) X() *wml.CT_PBdr
X returns the inner wml.CT_PBdr
ParagraphProperties are the properties for a paragraph.
type ParagraphProperties struct {
// contains filtered or unexported fields
}
func (p ParagraphProperties) AddSection(t wml.ST_SectionMark) Section
AddSection adds a new document section with an optional section break. If t is ST_SectionMarkUnset, then no break will be inserted.
func (p ParagraphProperties) AddTabStop(position measurement.Distance, justificaton wml.ST_TabJc, leader wml.ST_TabTlc)
AddTabStop adds a tab stop to the paragraph. It controls the position of text when using Run.AddTab()
func (p ParagraphProperties) Bold() bool
Bold returns true if paragraph font is bold.
func (p ParagraphProperties) Caps() bool
Caps returns true if paragraph font is capitalized.
func (p ParagraphProperties) CharacterSpacingMeasure() string
CharacterSpacingMeasure returns paragraph characters spacing with its measure which can be mm, cm, in, pt, pc or pi.
func (p ParagraphProperties) CharacterSpacingValue() int64
CharacterSpacingValue returns the value of characters spacing in twips (1/20 of point).
func (p ParagraphProperties) ComplexSizeMeasure() string
ComplexSizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func (p ParagraphProperties) ComplexSizeValue() float64
ComplexSizeValue returns the value of paragraph font size for complex fonts in points.
func (p ParagraphProperties) DoubleStrike() bool
DoubleStrike returns true if paragraph is double striked.
func (p ParagraphProperties) EastAsiaFont() string
EastAsiaFont returns the name of paragraph font family for East Asia.
func (p ParagraphProperties) Emboss() bool
Emboss returns true if paragraph emboss is on.
func (p ParagraphProperties) Font() string
Font returns the name of paragraph font family.
func (p ParagraphProperties) GetColor() color.Color
GetColor returns the color.Color object representing the run color.
func (p ParagraphProperties) Italic() bool
Italic returns true if paragraph font is italic.
func (p ParagraphProperties) Outline() bool
Outline returns true if paragraph outline is on.
func (p ParagraphProperties) RStyle() string
RStyle returns the name of character style. It is defined here http://officeopenxml.com/WPstyleCharStyles.php
func (p ParagraphProperties) RightToLeft() bool
RightToLeft returns true if paragraph text goes from right to left.
func (p ParagraphProperties) Section() (Section, bool)
Section return paragraph properties section value.
func (p ParagraphProperties) SetAlignment(align wml.ST_Jc)
SetAlignment controls the paragraph alignment
func (p ParagraphProperties) SetEndIndent(m measurement.Distance)
SetEndIndent controls the end indentation.
func (p ParagraphProperties) SetFirstLineIndent(m measurement.Distance)
SetFirstLineIndent controls the indentation of the first line in a paragraph.
func (p ParagraphProperties) SetHangingIndent(m measurement.Distance)
SetHangingIndent controls the indentation of the non-first lines in a paragraph.
func (p ParagraphProperties) SetHeadingLevel(idx int)
SetHeadingLevel sets a heading level and style based on the level to a paragraph. The default styles for a new unioffice document support headings from level 1 to 8.
func (p ParagraphProperties) SetKeepOnOnePage(b bool)
SetKeepOnOnePage controls if all lines in a paragraph are kept on the same page.
func (p ParagraphProperties) SetKeepWithNext(b bool)
SetKeepWithNext controls if this paragraph should be kept with the next.
func (p ParagraphProperties) SetPageBreakBefore(b bool)
SetPageBreakBefore controls if there is a page break before this paragraph.
func (p ParagraphProperties) SetSpacing(before, after measurement.Distance)
SetSpacing sets the spacing that comes before and after the paragraph. Deprecated: See Spacing() instead which allows finer control.
func (p ParagraphProperties) SetStartIndent(m measurement.Distance)
SetStartIndent controls the start indentation.
func (p ParagraphProperties) SetStyle(s string)
SetStyle sets the style of a paragraph.
func (p ParagraphProperties) SetWindowControl(b bool)
SetWindowControl controls if the first or last line of the paragraph is allowed to display on a separate page.
func (p ParagraphProperties) Shadow() bool
Shadow returns true if paragraph shadow is on.
func (p ParagraphProperties) SizeMeasure() string
SizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func (p ParagraphProperties) SizeValue() float64
SizeValue returns the value of paragraph font size in points.
func (p ParagraphProperties) Spacing() ParagraphSpacing
Spacing returns the paragraph spacing settings.
func (p ParagraphProperties) Strike() bool
Strike returns true if paragraph is striked.
func (p ParagraphProperties) Style() string
Style returns the style for a paragraph, or an empty string if it is unset.
func (p ParagraphProperties) Underline() wml.ST_Underline
Underline returns the type of paragraph underline.
func (p ParagraphProperties) UnderlineColor() string
UnderlineColor returns the hex color value of paragraph underline.
func (p ParagraphProperties) VerticalAlignment() sharedTypes.ST_VerticalAlignRun
VerticalAlign returns the value of paragraph vertical align.
func (p ParagraphProperties) X() *wml.CT_PPr
X returns the inner wrapped XML type.
ParagraphSpacing controls the spacing for a paragraph and its lines.
type ParagraphSpacing struct {
// contains filtered or unexported fields
}
func (p ParagraphSpacing) SetAfter(after measurement.Distance)
SetAfter sets the spacing that comes after the paragraph.
func (p ParagraphSpacing) SetAfterAuto(b bool)
SetAfterAuto controls if spacing after a paragraph is automatically determined.
func (p ParagraphSpacing) SetBefore(before measurement.Distance)
SetBefore sets the spacing that comes before the paragraph.
func (p ParagraphSpacing) SetBeforeAuto(b bool)
SetBeforeAuto controls if spacing before a paragraph is automatically determined.
func (p ParagraphSpacing) SetLineSpacing(d measurement.Distance, rule wml.ST_LineSpacingRule)
SetLineSpacing sets the spacing between lines in a paragraph.
ParagraphStyleProperties is the styling information for a paragraph.
type ParagraphStyleProperties struct {
// contains filtered or unexported fields
}
func (p ParagraphStyleProperties) AddTabStop(position measurement.Distance, justificaton wml.ST_TabJc, leader wml.ST_TabTlc)
AddTabStop adds a tab stop to the paragraph.
func (p ParagraphStyleProperties) NumId() int64
NumId return numbering numId that being use by style properties.
func (p ParagraphStyleProperties) SetAlignment(align wml.ST_Jc)
SetAlignment controls the paragraph alignment
func (p ParagraphStyleProperties) SetContextualSpacing(b bool)
SetContextualSpacing controls whether to Ignore Spacing Above and Below When Using Identical Styles
func (p ParagraphStyleProperties) SetFirstLineIndent(m measurement.Distance)
SetFirstLineIndent controls the first line indent of the paragraph.
func (p ParagraphStyleProperties) SetHangingIndent(m measurement.Distance)
SetHangingIndent controls the hanging indent of the paragraph.
func (p ParagraphStyleProperties) SetKeepNext(b bool)
SetKeepNext controls if the paragraph is kept with the next paragraph.
func (p ParagraphStyleProperties) SetKeepOnOnePage(b bool)
SetKeepOnOnePage controls if all lines in a paragraph are kept on the same page.
func (p ParagraphStyleProperties) SetLeftIndent(m measurement.Distance)
SetLeftIndent controls the left indent of the paragraph.
func (p ParagraphStyleProperties) SetLineSpacing(m measurement.Distance, rule wml.ST_LineSpacingRule)
SetLineSpacing controls the line spacing of the paragraph.
func (p ParagraphStyleProperties) SetOutlineLevel(lvl int)
SetOutlineLevel sets the outline level of this style.
func (p ParagraphStyleProperties) SetSpacing(before, after measurement.Distance)
SetSpacing sets the spacing that comes before and after the paragraph.
func (p ParagraphStyleProperties) SetStartIndent(m measurement.Distance)
SetStartIndent controls the start indent of the paragraph.
func (p ParagraphStyleProperties) X() *wml.CT_PPrGeneral
X returns the inner wrapped XML type.
Row is a row within a table within a document.
type Row struct {
// contains filtered or unexported fields
}
func (r Row) AddCell() Cell
AddCell adds a cell to a row and returns it
func (r Row) Cells() []Cell
Cells returns the cells defined in the table.
func (r Row) Properties() RowProperties
Properties returns the row properties.
func (r Row) X() *wml.CT_Row
X returns the inner wrapped XML type.
RowProperties are the properties for a row within a table
type RowProperties struct {
// contains filtered or unexported fields
}
func (r RowProperties) SetCantSplit(val bool)
SetCantSplit set row properties for Can't Split value.
func (r RowProperties) SetHeight(ht measurement.Distance, rule wml.ST_HeightRule)
SetHeight allows controlling the height of a row within a table.
func (r RowProperties) SetTblHeader(val bool)
SetTblHeader set row properties for repeat table row on every new page value.
Run is a run of text within a paragraph that shares the same formatting.
type Run struct {
// contains filtered or unexported fields
}
func (r Run) AddBreak()
AddBreak adds a line break to a run.
func (r Run) AddDrawingAnchored(img common.ImageRef) (AnchoredDrawing, error)
AddDrawingAnchored adds an anchored (floating) drawing from an ImageRef.
func (r Run) AddDrawingInline(img common.ImageRef) (InlineDrawing, error)
AddDrawingInline adds an inline drawing from an ImageRef.
func (r Run) AddEndnoteReference()
AddEndnoteReference adds a footnote reference to a run.
func (r Run) AddField(code string)
AddField adds a field (automatically computed text) to the document.
func (r Run) AddFieldWithFormatting(code string, fmt string, isDirty bool)
AddFieldWithFormatting adds a field (automatically computed text) to the document with field specifc formatting.
func (r Run) AddFootnoteReference()
AddFootnoteReference adds a footnote reference to a run.
func (r Run) AddPageBreak()
AddPageBreak adds a page break to a run.
func (r Run) AddTab()
AddTab adds tab to a run and can be used with the the Paragraph's tab stops.
func (r Run) AddText(s string)
AddText adds text to a run.
func (r Run) Clear()
Clear removes all of the content from within a run.
func (r Run) ClearContent()
ClearContent clears any content in the run (text, tabs, breaks, etc.)
func (r Run) Control() *axcontrol.Control
Control returns an *axcontrol.Control object contained in the run or the nil value in case of no controls.
func (r Run) DrawingAnchored() []AnchoredDrawing
DrawingAnchored returns a slice of AnchoredDrawings.
func (r Run) DrawingInline() []InlineDrawing
DrawingInline return a slice of InlineDrawings.
func (r Run) IsEndnote() (bool, int64)
IsEndnote returns a bool based on whether the run has a footnote or not. Returns both a bool as to whether it has a footnote as well as the ID of the footnote.
func (r Run) IsFootnote() (bool, int64)
IsFootnote returns a bool based on whether the run has a footnote or not. Returns both a bool as to whether it has a footnote as well as the ID of the footnote.
func (r Run) Properties() RunProperties
Properties returns the run properties.
func (r Run) SetProperties(rp RunProperties)
SetProperties sets the `RunProperties` to the `Run` element
func (r Run) Text() string
Text returns the underlying text in the run.
func (r Run) X() *wml.CT_R
X returns the inner wrapped XML type.
RunProperties controls run styling properties.
type RunProperties struct {
// contains filtered or unexported fields
}
func (r RunProperties) Bold() bool
Bold returns true if run font is bold.
func (r RunProperties) BoldValue() OnOffValue
BoldValue returns the precise nature of the bold setting (unset, off or on).
func (r RunProperties) Caps() bool
Caps returns true if run font is capitalized.
func (r RunProperties) CharacterSpacingMeasure() string
CharacterSpacingMeasure returns paragraph characters spacing with its measure which can be mm, cm, in, pt, pc or pi.
func (r RunProperties) CharacterSpacingValue() int64
CharacterSpacingValue returns the value of run's characters spacing in twips (1/20 of point).
func (r RunProperties) ClearColor()
ClearColor clears the text color.
func (r RunProperties) Color() Color
Color returns the style's Color.
func (r RunProperties) ComplexSizeMeasure() string
ComplexSizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func (r RunProperties) ComplexSizeValue() float64
ComplexSizeValue returns the value of run font size for complex fonts in points.
func (r RunProperties) DoubleStrike() bool
DoubleStrike returns true if run is double striked.
func (r RunProperties) EastAsiaFont() string
EastAsiaFont returns the name of run font family for East Asia.
func (r RunProperties) Emboss() bool
Emboss returns true if run emboss is on.
func (r RunProperties) Font() string
Font returns the name of run font family.
func (r RunProperties) Fonts() Fonts
Fonts returns the style's Fonts.
func (r RunProperties) GetColor() color.Color
GetColor returns the color.Color object representing the run color.
func (r RunProperties) GetEffect() wml.ST_TextEffect
GetEffect returns the effect of the run.
func (r RunProperties) GetHighlight() wml.ST_HighlightColor
GetHighlight returns the HighlightColor.
func (r RunProperties) GetKerning() measurement.Distance
GetKerning returns the kerning (character spacing) of a run
func (r RunProperties) GetRightToLeft() bool
GetRightToLeft returns true if the run text is displayed from right to left.
func (r RunProperties) Imprint() bool
Imprint returns true if run imprint is on.
func (r RunProperties) IsBold() bool
IsBold returns true if the run has been set to bold.
func (r RunProperties) IsItalic() bool
IsItalic returns true if the run has been set to italics.
func (r RunProperties) Italic() bool
Italic returns true if run font is italic.
func (r RunProperties) ItalicValue() OnOffValue
ItalicValue returns the precise nature of the italic setting (unset, off or on).
func (r RunProperties) Outline() bool
Outline returns true if run outline is on.
func (r RunProperties) RStyle() string
RStyle returns the name of character style. It is defined here http://officeopenxml.com/WPstyleCharStyles.php
func (r RunProperties) RightToLeft() bool
RightToLeft returns true if run text goes from right to left.
func (r RunProperties) SetAllCaps(b bool)
SetAllCaps sets the run to all caps.
func (r RunProperties) SetBold(b bool)
SetBold sets the run to bold.
func (r RunProperties) SetCharacterSpacing(size measurement.Distance)
SetCharacterSpacing sets the run's Character Spacing Adjustment.
func (r RunProperties) SetColor(c color.Color)
SetColor sets the text color.
func (r RunProperties) SetDoubleStrikeThrough(b bool)
SetDoubleStrikeThrough sets the run to double strike-through.
func (r RunProperties) SetEffect(e wml.ST_TextEffect)
SetEffect sets a text effect on the run.
func (r RunProperties) SetEmboss(b bool)
SetEmboss sets the run to embossed text.
func (r RunProperties) SetFontFamily(family string)
SetFontFamily sets the Ascii & HAnsi fonly family for a run.
func (r RunProperties) SetHighlight(c wml.ST_HighlightColor)
SetHighlight highlights text in a specified color.
func (r RunProperties) SetImprint(b bool)
SetImprint sets the run to imprinted text.
func (r RunProperties) SetItalic(b bool)
SetItalic sets the run to italic.
func (r RunProperties) SetKerning(size measurement.Distance)
SetKerning sets the run's font kerning.
func (r RunProperties) SetOutline(b bool)
SetOutline sets the run to outlined text.
func (r RunProperties) SetRightToLeft(b bool)
SetRightToLeft sets the run text goes from right to left.
func (r RunProperties) SetShadow(b bool)
SetShadow sets the run to shadowed text.
func (r RunProperties) SetSize(size measurement.Distance)
SetSize sets the font size for a run.
func (r RunProperties) SetSmallCaps(b bool)
SetSmallCaps sets the run to small caps.
func (r RunProperties) SetStrikeThrough(b bool)
SetStrikeThrough sets the run to strike-through.
func (r RunProperties) SetStyle(style string)
SetStyle sets the font size.
func (r RunProperties) SetUnderline(style wml.ST_Underline, c color.Color)
SetUnderline controls underline for a run style.
func (r RunProperties) SetVerticalAlignment(v sharedTypes.ST_VerticalAlignRun)
SetVerticalAlignment controls the vertical alignment of the run, this is used to control if text is superscript/subscript.
func (r RunProperties) Shadow() bool
Shadow returns true if run shadow is on.
func (r RunProperties) SizeMeasure() string
SizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func (r RunProperties) SizeValue() float64
SizeValue returns the value of run font size in points.
func (r RunProperties) Strike() bool
Strike returns true if run is striked.
func (r RunProperties) Underline() wml.ST_Underline
Underline returns the type of run underline.
func (r RunProperties) UnderlineColor() string
UnderlineColor returns the hex color value of run underline.
func (r RunProperties) VerticalAlignment() sharedTypes.ST_VerticalAlignRun
VerticalAlign returns the value of run vertical align.
func (r RunProperties) X() *wml.CT_RPr
X returns the inner wrapped XML type.
Section is the beginning of a new section.
type Section struct {
// contains filtered or unexported fields
}
func (s Section) GetFooter(t wml.ST_HdrFtr) (Footer, bool)
GetFooter gets a section Footer for given type
func (s Section) GetHeader(t wml.ST_HdrFtr) (Header, bool)
GetHeader gets a section Header for given type t [ST_HdrFtrDefault, ST_HdrFtrEven, ST_HdrFtrFirst]
func (s Section) SetFooter(f Footer, t wml.ST_HdrFtr)
SetFooter sets a section footer.
func (s Section) SetHeader(h Header, t wml.ST_HdrFtr)
SetHeader sets a section header.
func (s Section) SetPageMargins(top, right, bottom, left, header, footer, gutter measurement.Distance)
SetPageMargins sets the page margins for a section
func (s Section) SetPageSizeAndOrientation(w, h measurement.Distance, orientation wml.ST_PageOrientation)
SetPageSizeAndOrientation sets the page size and orientation for a section.
func (s Section) X() *wml.CT_SectPr
X returns the internally wrapped *wml.CT_SectPr.
Settings controls the document settings.
type Settings struct {
// contains filtered or unexported fields
}
func NewSettings() Settings
NewSettings constructs a new empty Settings
func (s Settings) RemoveMailMerge()
RemoveMailMerge removes any mail merge settings
func (s Settings) SetUpdateFieldsOnOpen(b bool)
SetUpdateFieldsOnOpen controls if fields are recalculated upon opening the document. This is useful for things like a table of contents as the library only adds the field code and relies on Word/LibreOffice to actually compute the content.
func (s Settings) X() *wml.Settings
X returns the inner wrapped XML type.
StructuredDocumentTag are a tagged bit of content in a document.
type StructuredDocumentTag struct {
// contains filtered or unexported fields
}
func (s StructuredDocumentTag) Paragraphs() []Paragraph
Paragraphs returns the paragraphs within a structured document tag.
Style is a style within the styles.xml file.
type Style struct {
// contains filtered or unexported fields
}
func (s Style) Name() string
Name returns the name of the style if set.
func (s Style) ParagraphProperties() ParagraphStyleProperties
ParagraphProperties returns the paragraph style properties.
func (s Style) RunProperties() RunProperties
RunProperties returns the run style properties.
func (s Style) SetBasedOn(name string)
SetBasedOn sets the style that this style is based on.
func (s Style) SetLinkedStyle(name string)
SetLinkedStyle sets the style that this style is linked to.
func (s Style) SetName(name string)
SetName sets the name of the style.
func (s Style) SetNextStyle(name string)
SetNextStyle sets the style that the next paragraph will use.
func (s Style) SetPrimaryStyle(b bool)
SetPrimaryStyle marks the style as a primary style.
func (s Style) SetSemiHidden(b bool)
SetSemiHidden controls if the style is hidden in the UI.
func (s Style) SetUISortOrder(order int)
SetUISortOrder controls the order the style is displayed in the UI.
func (s Style) SetUnhideWhenUsed(b bool)
SetUnhideWhenUsed controls if a semi hidden style becomes visible when used.
func (s Style) StyleID() string
StyleID returns the style ID.
func (s Style) TableConditionalFormatting(typ wml.ST_TblStyleOverrideType) TableConditionalFormatting
TableConditionalFormatting returns a conditional formatting object of a given type. Calling this method repeatedly will return the same object.
func (s Style) TableProperties() TableStyleProperties
TableProperties returns the table style properties.
func (s Style) Type() wml.ST_StyleType
Type returns the type of the style.
func (s Style) X() *wml.CT_Style
X returns the inner wrapped XML type.
Styles is the document wide styles contained in styles.xml.
type Styles struct {
// contains filtered or unexported fields
}
func NewStyles() Styles
NewStyles constructs a new empty Styles
func (s Styles) AddStyle(styleID string, t wml.ST_StyleType, isDefault bool) Style
AddStyle adds a new empty style, if styleID is already exists, it will return the style.
func (s Styles) Clear()
Clear clears the styes.
func (s Styles) InitializeDefault()
InitializeDefault constructs the default styles.
func (s Styles) InsertStyle(ss Style)
InsertStyle insert style to styles.
func (s Styles) ParagraphStyles() []Style
ParagraphStyles returns only the paragraph styles.
func (s Styles) SearchStyleById(id string) (Style, bool)
SearchStylesById returns style by its id.
func (s Styles) SearchStyleByName(name string) (Style, bool)
SearchStyleByName return style by its name.
func (s Styles) Styles() []Style
Styles returns all styles.
func (s Styles) X() *wml.Styles
X returns the inner wrapped XML type.
Table is a table within a document.
type Table struct {
// contains filtered or unexported fields
}
func (t Table) AddRow() Row
AddRow adds a row to a table.
func (t Table) InsertRowAfter(r Row) Row
InsertRowAfter inserts a row after another row
func (t Table) InsertRowBefore(r Row) Row
InsertRowBefore inserts a row before another row
func (t Table) Properties() TableProperties
Properties returns the table properties.
func (t Table) Rows() []Row
Rows returns the rows defined in the table.
func (t Table) Style() string
Style return the table style.
func (t Table) X() *wml.CT_Tbl
X returns the inner wrapped XML type.
TableBorders allows manipulation of borders on a table.
type TableBorders struct {
// contains filtered or unexported fields
}
func (b TableBorders) SetAll(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetAll sets all of the borders to a given value.
func (b TableBorders) SetBottom(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetBottom sets the bottom border to a specified type, color and thickness.
func (b TableBorders) SetInsideHorizontal(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideHorizontal sets the interior horizontal borders to a specified type, color and thickness.
func (b TableBorders) SetInsideVertical(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideVertical sets the interior vertical borders to a specified type, color and thickness.
func (b TableBorders) SetLeft(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetLeft sets the left border to a specified type, color and thickness.
func (b TableBorders) SetRight(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetRight sets the right border to a specified type, color and thickness.
func (b TableBorders) SetTop(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetTop sets the top border to a specified type, color and thickness.
func (b TableBorders) X() *wml.CT_TblBorders
X returns the inner wml.CT_TblBorders
TableConditionalFormatting controls the conditional formatting within a table style.
type TableConditionalFormatting struct {
// contains filtered or unexported fields
}
func (t TableConditionalFormatting) CellProperties() CellProperties
CellProperties returns the cell properties.
func (t TableConditionalFormatting) ParagraphProperties() ParagraphStyleProperties
ParagraphProperties returns the paragraph properties controlling text formatting within the table.
func (t TableConditionalFormatting) RunProperties() RunProperties
RunProperties returns the run properties controlling text formatting within the table.
func (t TableConditionalFormatting) X() *wml.CT_TblStylePr
X returns the inner wrapped XML type.
TableInfo is used for keep information about a table, a row and a cell where the text is located.
type TableInfo struct { Table *wml.CT_Tbl Row *wml.CT_Row Cell *wml.CT_Tc RowIndex int ColIndex int }
TableLook is the conditional formatting associated with a table style that has been assigned to a table.
type TableLook struct {
// contains filtered or unexported fields
}
func (t TableLook) SetFirstColumn(on bool)
SetFirstColumn controls the conditional formatting for the first column in a table.
func (t TableLook) SetFirstRow(on bool)
SetFirstRow controls the conditional formatting for the first row in a table.
func (t TableLook) SetHorizontalBanding(on bool)
SetHorizontalBanding controls the conditional formatting for horizontal banding.
func (t TableLook) SetLastColumn(on bool)
SetLastColumn controls the conditional formatting for the last column in a table.
func (t TableLook) SetLastRow(on bool)
SetLastRow controls the conditional formatting for the last row in a table. This is called the 'Total' row within Word.
func (t TableLook) SetVerticalBanding(on bool)
SetVerticalBanding controls the conditional formatting for vertical banding.
func (t TableLook) X() *wml.CT_TblLook
X returns the inner wrapped XML type.
TableProperties are the properties for a table within a document
type TableProperties struct {
// contains filtered or unexported fields
}
func (t TableProperties) Borders() TableBorders
Borders allows manipulation of the table borders.
func (t TableProperties) SetAlignment(align wml.ST_JcTable)
SetAlignment sets the alignment of a table within the page.
func (t TableProperties) SetCellSpacing(m measurement.Distance)
SetCellSpacing sets the cell spacing within a table.
func (t TableProperties) SetCellSpacingAuto()
SetCellSpacingAuto sets the cell spacing within a table to automatic.
func (t TableProperties) SetCellSpacingPercent(pct float64)
SetCellSpacingPercent sets the cell spacing within a table to a percent width.
func (t TableProperties) SetLayout(l wml.ST_TblLayoutType)
SetLayout controls the table layout. wml.ST_TblLayoutTypeAutofit corresponds to "Automatically resize to fit contents" being checked, while wml.ST_TblLayoutTypeFixed corresponds to it being unchecked.
func (t TableProperties) SetStyle(name string)
SetStyle sets the table style name.
func (t TableProperties) SetWidth(d measurement.Distance)
SetWidth sets the table with to a specified width.
func (t TableProperties) SetWidthAuto()
SetWidthAuto sets the the table width to automatic.
func (t TableProperties) SetWidthPercent(pct float64)
SetWidthPercent sets the table to a width percentage.
func (t TableProperties) TableLook() TableLook
TableLook returns the table look, or conditional formatting applied to a table style.
func (t TableProperties) X() *wml.CT_TblPr
X returns the inner wrapped XML type.
TableStyleProperties are table properties as defined in a style.
type TableStyleProperties struct {
// contains filtered or unexported fields
}
func (t TableStyleProperties) Borders() TableBorders
Borders allows manipulation of the table borders.
func (t TableStyleProperties) SetCellSpacingAuto()
SetCellSpacingAuto sets the cell spacing within a table to automatic.
func (t TableStyleProperties) SetCellSpacingPercent(pct float64)
SetCellSpacingPercent sets the cell spacing within a table to a percent width.
func (t TableStyleProperties) SetColumnBandSize(cols int64)
SetColumnBandSize sets the number of Columns in the column band
func (t TableStyleProperties) SetRowBandSize(rows int64)
SetRowBandSize sets the number of Rows in the row band
func (t TableStyleProperties) SetTableIndent(ind measurement.Distance)
SetTableIndent sets the Table Indent from the Leading Margin
func (t TableStyleProperties) X() *wml.CT_TblPrBase
X returns the inner wrapped XML type.
TableWidth controls width values in table settings.
type TableWidth struct {
// contains filtered or unexported fields
}
func NewTableWidth() TableWidth
NewTableWidth returns a newly intialized TableWidth
func (s TableWidth) SetValue(m measurement.Distance)
SetValue sets the width value.
func (s TableWidth) X() *wml.CT_TblWidth
X returns the inner wrapped XML type.
TextItem is used for keeping text with references to a paragraph and run or a table, a row and a cell where it is located.
type TextItem struct { Text string DrawingInfo *DrawingInfo Paragraph *wml.CT_P Hyperlink *wml.CT_Hyperlink Run *wml.CT_R TableInfo *TableInfo }
func ExtractFromFooter(footer *wml.Ftr) []TextItem
ExtractFromFooter returns text from the document footer as an array of TextItems.
func ExtractFromHeader(header *wml.Hdr) []TextItem
ExtractFromHeader returns text from the document header as an array of TextItems.
WatermarkPicture is watermark picture within document.
type WatermarkPicture struct {
// contains filtered or unexported fields
}
func NewWatermarkPicture() WatermarkPicture
NewWatermarkPicture generates new WatermarkPicture.
func (w *WatermarkPicture) GetShapeStyle() vmldrawing.ShapeStyle
GetShapeStyle returns string style of the shape in watermark and format it to ShapeStyle.
func (w *WatermarkPicture) Pict() *wml.CT_Picture
Pict returns the pict object.
func (w *WatermarkPicture) SetPicture(imageRef common.ImageRef)
SetPicture sets the watermark picture.
func (w *WatermarkPicture) SetPictureSize(width, height int64)
SetPictureSize set watermark picture size with given width and height.
func (w *WatermarkPicture) SetPictureWashout(isWashout bool)
SetPictureWashout set washout to watermark picture.
func (w *WatermarkPicture) SetShapeStyle(shapeStyle vmldrawing.ShapeStyle)
SetShapeStyle sets style to the element v:shape in watermark.
WatermarkText is watermark text within the document.
type WatermarkText struct {
// contains filtered or unexported fields
}
func NewWatermarkText() WatermarkText
NewWatermarkText generates a new WatermarkText.
func (w *WatermarkText) GetStyle() vmldrawing.TextpathStyle
GetStyle returns string style of the text in watermark and format it to TextpathStyle.
func (w *WatermarkText) GetText() string
GetText returns text in the watermark.
func (w *WatermarkText) Pict() *wml.CT_Picture
Pict returns the pict object.
func (w *WatermarkText) SetStyle(style vmldrawing.TextpathStyle)
SetStyle sets style to the text in watermark.
func (w *WatermarkText) SetText(text string)
SetText sets the watermark text.
func (w *WatermarkText) SetTextStyleBold(value bool)
SetTextStyleBold set text style of watermark to bold.
func (w *WatermarkText) SetTextStyleItalic(value bool)
SetTextStyleItalic set text style of watermark to italic.