Documentation
¶
Overview ¶
File: elements/hyperlink.go
elements/image.go
File: elements/paragraph.go
File: elements/run.go
elements/table.go
Index ¶
- Constants
- func CreateHyperlinkWithRelationship(text, url string) (*Hyperlink, *HyperlinkRelationship)
- type BorderStyle
- type Hyperlink
- func (h *Hyperlink) AddFormattedText(text string, format func(*Run)) *Run
- func (h *Hyperlink) AddRun() *Run
- func (h *Hyperlink) AddText(text string) *Run
- func (h *Hyperlink) Clone() *Hyperlink
- func (h *Hyperlink) RemoveUnderline() *Hyperlink
- func (h *Hyperlink) SetColor(color string) *Hyperlink
- func (h *Hyperlink) SetDocLocation(location string) *Hyperlink
- func (h *Hyperlink) SetHistory(history bool) *Hyperlink
- func (h *Hyperlink) SetScreenTip(tip string) *Hyperlink
- func (h *Hyperlink) SetStyle(styleID string) *Hyperlink
- func (h *Hyperlink) SetTargetFrame(frame string) *Hyperlink
- func (h *Hyperlink) SetTooltip(tooltip string) *Hyperlink
- func (h *Hyperlink) Type() string
- func (h *Hyperlink) Validate() error
- func (h *Hyperlink) XML() ([]byte, error)
- type HyperlinkRelationship
- type Image
- func (img *Image) Clone() *Image
- func (img *Image) FileName() string
- func (img *Image) FitToBox(maxWidthInches, maxHeightInches float64) *Image
- func (img *Image) FitToHeight(maxHeightInches float64) *Image
- func (img *Image) FitToWidth(maxWidthInches float64) *Image
- func (img *Image) GetAspectRatio() float64
- func (img *Image) GetBase64Data() string
- func (img *Image) GetDimensionsInCm() (width, height float64)
- func (img *Image) GetDimensionsInInches() (width, height float64)
- func (img *Image) GetDimensionsInPixels() (width, height int)
- func (img *Image) RawContent() []byte
- func (img *Image) RelID() string
- func (img *Image) RelType() string
- func (img *Image) SaveToFile(path string) error
- func (img *Image) Scale(factor float64) *Image
- func (img *Image) ScaleToHeight(heightInches float64) *Image
- func (img *Image) ScaleToWidth(widthInches float64) *Image
- func (img *Image) SetAlignment(align properties.ImageAlignment) *Image
- func (img *Image) SetAltText(text string) *Image
- func (img *Image) SetBorder(width int, color string) *Image
- func (img *Image) SetCropping(top, bottom, left, right float64) *Image
- func (img *Image) SetFloating(hAnchor properties.HorizontalAnchor, vAnchor properties.VerticalAnchor) *Image
- func (img *Image) SetOffset(horizontal, vertical int64) *Image
- func (img *Image) SetOffsetInches(horizontal, vertical float64) *Image
- func (img *Image) SetProperties(props properties.ImageProperties) *Image
- func (img *Image) SetRotation(degrees int) *Image
- func (img *Image) SetShadow(enabled bool) *Image
- func (img *Image) SetSize(widthInches, heightInches float64) *Image
- func (img *Image) SetSizeInCm(widthCm, heightCm float64) *Image
- func (img *Image) SetSizeInPixels(widthPx, heightPx int) *Image
- func (img *Image) SetTransparency(transparency float64) *Image
- func (img *Image) SetWrapStyle(wrap properties.WrapStyle) *Image
- func (img *Image) TargetPath() string
- func (img *Image) Type() string
- func (img *Image) XML() ([]byte, error)
- type LineBreak
- type ListType
- type MarginValue
- type PageBreak
- type Paragraph
- func (p *Paragraph) AddChildren(child ParagraphChild)
- func (p *Paragraph) AddFormattedText(text string, format func(*Run)) *Run
- func (pb *Paragraph) AddHyperlink(text, url string) *Paragraph
- func (p *Paragraph) AddLineBreak() *Paragraph
- func (p *Paragraph) AddPageBreak() *Paragraph
- func (p *Paragraph) AddRun() *Run
- func (p *Paragraph) AddText(text string) *Run
- func (p *Paragraph) Clear()
- func (p *Paragraph) Clone() *Paragraph
- func (p *Paragraph) SetAlignment(alignment string) *Paragraph
- func (p *Paragraph) SetBorders(borders *properties.ParagraphBorders) *Paragraph
- func (p *Paragraph) SetHangingIndent(hanging float64) *Paragraph
- func (p *Paragraph) SetIndentation(left, right, firstLine float64) *Paragraph
- func (p *Paragraph) SetKeepLines(keep bool) *Paragraph
- func (p *Paragraph) SetKeepNext(keep bool) *Paragraph
- func (p *Paragraph) SetLineSpacing(spacing float64, rule string) *Paragraph
- func (p *Paragraph) SetNumbering(listType ListType, level int) *Paragraph
- func (p *Paragraph) SetOutlineLevel(level int) *Paragraph
- func (p *Paragraph) SetPageBreakBefore(pageBreak bool) *Paragraph
- func (p *Paragraph) SetShading(shading *properties.ParagraphShading) *Paragraph
- func (p *Paragraph) SetSpacing(before, after float64) *Paragraph
- func (p *Paragraph) SetStyle(styleID string) *Paragraph
- func (p *Paragraph) SetTabs(tabs []properties.TabStop) *Paragraph
- func (p *Paragraph) SetWidowControl(control bool) *Paragraph
- func (p *Paragraph) Type() string
- func (p *Paragraph) Validate() error
- func (p *Paragraph) XML() ([]byte, error)
- type ParagraphChild
- type Run
- func (r *Run) AddBreak() *Run
- func (r *Run) AddPageBreak() *Run
- func (r *Run) AddSpace(count int) *Run
- func (r *Run) AddTab() *Run
- func (r *Run) AddText(text string) *Run
- func (r *Run) Clone() *Run
- func (r *Run) HasFormatting() bool
- func (r *Run) SetAllCaps(allCaps bool) *Run
- func (r *Run) SetBold(bold bool) *Run
- func (r *Run) SetColor(color string) *Run
- func (r *Run) SetDoubleStrike(doubleStrike bool) *Run
- func (r *Run) SetEmboss(emboss bool) *Run
- func (r *Run) SetFontFamily(font string) *Run
- func (r *Run) SetFontSize(size float64) *Run
- func (r *Run) SetHighlight(color string) *Run
- func (r *Run) SetImprint(imprint bool) *Run
- func (r *Run) SetItalic(italic bool) *Run
- func (r *Run) SetKerning(kerning float64) *Run
- func (r *Run) SetOutline(outline bool) *Run
- func (r *Run) SetShadow(shadow bool) *Run
- func (r *Run) SetSmallCaps(smallCaps bool) *Run
- func (r *Run) SetSpacing(spacing int) *Run
- func (r *Run) SetStrike(strike bool) *Run
- func (r *Run) SetStyle(styleID string) *Run
- func (r *Run) SetUnderline(underline string) *Run
- func (r *Run) SetVanish(vanish bool) *Run
- func (r *Run) SetVerticalAlign(align string) *Run
- func (r *Run) Type() string
- func (r *Run) Validate() error
- func (r *Run) XML() ([]byte, error)
- type RunChild
- type Tab
- type Table
- func (t *Table) AddRow() *TableRow
- func (t *Table) MergeCells(row, startCol, endCol int) error
- func (t *Table) SetCellFormattedText(row, col int, text string, format func(*Run)) error
- func (t *Table) SetCellShading(row, col int, color string) error
- func (t *Table) SetCellText(row, col int, text string) error
- func (t *Table) SetCellVerticalAlignment(row, col int, alignment VerticalAlign) error
- func (t *Table) SetColumnWidth(col int, width string) error
- func (t *Table) SetHeaderRow(row int) error
- func (t *Table) SetRowHeight(row int, height string, rule string) error
- func (t *Table) SetTableAlignment(alignment TableAlign)
- func (t *Table) SetTableWidth(widthType, value string)
- func (t *Table) Type() string
- func (t *Table) XML() ([]byte, error)
- type TableAlign
- type TableAlignment
- type TableBorders
- type TableCell
- type TableCellBorders
- type TableCellMargin
- type TableCellMargins
- type TableCellProperties
- type TableCellShading
- type TableCellSpacing
- type TableCellWidth
- type TableGrid
- type TableGridCol
- type TableIndent
- type TableLook
- type TableProperties
- type TableRow
- type TableRowHeight
- type TableRowProperties
- type TableStyle
- type TableWidth
- type Text
- type VerticalAlign
- type VerticalMerge
Constants ¶
const ( HyperlinkTypeExternal = "external" HyperlinkTypeInternal = "internal" HyperlinkTypeEmail = "email" HyperlinkTypeBookmark = "bookmark" )
HyperlinkType constants
const ( // EMUs per inch EmusPerInch = 914400 // EMUs per centimeter EmusPerCm = 360000 // EMUs per pixel at 96 DPI EmusPerPixel = 9525 )
const ( ContentTypeJPEG = "image/jpeg" ContentTypePNG = "image/png" ContentTypeGIF = "image/gif" ContentTypeBMP = "image/bmp" ContentTypeTIFF = "image/tiff" ContentTypeSVG = "image/svg+xml" )
Image content types
Variables ¶
This section is empty.
Functions ¶
func CreateHyperlinkWithRelationship ¶
func CreateHyperlinkWithRelationship(text, url string) (*Hyperlink, *HyperlinkRelationship)
CreateHyperlinkWithRelationship creates a hyperlink and its relationship
Types ¶
type BorderStyle ¶
type BorderStyle struct {
Value string // single, double, dotted, dashed, thick, none
Size string
Space string
Color string
}
BorderStyle represents a border style
type Hyperlink ¶
type Hyperlink struct {
ID string // Relationship ID
URL string // Target URL or anchor
Tooltip string // Tooltip text
Children []ParagraphChild // Child elements (usually runs)
Properties *properties.RunProperties // Default properties for children
Typ string // Type: "external" or "internal"
Anchor string // Anchor for internal links
DocLocation string // Document location for internal links
TargetFrame string // Target frame
History bool // Add to history
ScreenTip string // Extended tooltip
}
Hyperlink represents a hyperlink element
func NewBookmarkHyperlink ¶
NewBookmarkHyperlink creates a hyperlink to a bookmark
func NewEmailHyperlink ¶
NewEmailHyperlink creates an email hyperlink
func NewHyperlink ¶
NewHyperlink creates a new external hyperlink
func NewInternalHyperlink ¶
NewInternalHyperlink creates a hyperlink to a bookmark
func (*Hyperlink) AddFormattedText ¶
AddFormattedText adds text with additional formatting
func (*Hyperlink) RemoveUnderline ¶
RemoveUnderline removes the default underline
func (*Hyperlink) SetDocLocation ¶
SetDocLocation sets document location for internal links
func (*Hyperlink) SetHistory ¶
SetHistory sets whether to add to history
func (*Hyperlink) SetScreenTip ¶
SetScreenTip sets extended tooltip text
func (*Hyperlink) SetTargetFrame ¶
SetTargetFrame sets the target frame
func (*Hyperlink) SetTooltip ¶
SetTooltip sets the hyperlink tooltip
type HyperlinkRelationship ¶
HyperlinkRelationship represents a hyperlink relationship for the document
func NewHyperlinkRelationship ¶
func NewHyperlinkRelationship(id, target string) *HyperlinkRelationship
NewHyperlinkRelationship creates a new hyperlink relationship
type Image ¶
type Image struct {
RelationshipID string
Width int64 // Width in EMUs (English Metric Units)
Height int64 // Height in EMUs
Name string
Description string
Data []byte
ContentType string
Extension string
// contains filtered or unexported fields
}
Image represents an image element in a Word document
func NewImageFromBytes ¶
func NewImageFromBytes(document types.Document, data []byte, name string, contentType string) (*Image, error)
NewImageFromBytes creates a new image from byte data
func NewImageFromReader ¶
NewImageFromReader creates a new image from an io.Reader
func (*Image) FitToBox ¶
FitToBox scales the image to fit within a bounding box while maintaining aspect ratio
func (*Image) FitToHeight ¶
FitToHeight scales the image to fit within a maximum height while maintaining aspect ratio
func (*Image) FitToWidth ¶
FitToWidth scales the image to fit within a maximum width while maintaining aspect ratio
func (*Image) GetAspectRatio ¶
GetAspectRatio returns the aspect ratio of the image
func (*Image) GetBase64Data ¶
GetBase64Data returns the image data as base64 encoded string
func (*Image) GetDimensionsInCm ¶
GetDimensionsInCm returns the image dimensions in centimeters
func (*Image) GetDimensionsInInches ¶
GetDimensionsInInches returns the image dimensions in inches
func (*Image) GetDimensionsInPixels ¶
GetDimensionsInPixels returns the image dimensions in pixels (at 96 DPI)
func (*Image) RawContent ¶
RawContent returns the raw image data
func (*Image) SaveToFile ¶
SaveToFile saves the image data to a file
func (*Image) ScaleToHeight ¶
ScaleToHeight scales the image to a specific height while maintaining aspect ratio
func (*Image) ScaleToWidth ¶
ScaleToWidth scales the image to a specific width while maintaining aspect ratio
func (*Image) SetAlignment ¶
func (img *Image) SetAlignment(align properties.ImageAlignment) *Image
SetAlignment sets the horizontal alignment for inline images
func (*Image) SetAltText ¶
SetAltText sets the alternative text for accessibility
func (*Image) SetCropping ¶
SetCropping sets the crop percentages for each side
func (*Image) SetFloating ¶
func (img *Image) SetFloating(hAnchor properties.HorizontalAnchor, vAnchor properties.VerticalAnchor) *Image
SetFloating makes the image float with specified anchoring
func (*Image) SetOffsetInches ¶
SetOffsetInches sets the offset for floating images in inches
func (*Image) SetProperties ¶
func (img *Image) SetProperties(props properties.ImageProperties) *Image
SetProperties sets the image properties
func (*Image) SetRotation ¶
SetRotation sets the rotation angle in degrees
func (*Image) SetSizeInCm ¶
SetSizeInCm sets the image size in centimeters
func (*Image) SetSizeInPixels ¶
SetSizeInPixels sets the image size in pixels (at 96 DPI)
func (*Image) SetTransparency ¶
SetTransparency sets the image transparency (0 to 100)
func (*Image) SetWrapStyle ¶
func (img *Image) SetWrapStyle(wrap properties.WrapStyle) *Image
SetWrapStyle sets how text wraps around the image
func (*Image) TargetPath ¶
TargetPath returns the target path for the image
type LineBreak ¶
type LineBreak struct {
Typ string // Type of break: "textWrapping" (default), "page", "column", "textWrapping"
Clear string // Clear type for text wrapping: "none", "left", "right", "all"
}
LineBreak represents a line break within a run
func NewTextWrappingBreak ¶
NewTextWrappingBreak creates a line break that clears floating objects
type MarginValue ¶
MarginValue represents a margin value
type Paragraph ¶
type Paragraph struct {
Properties *properties.ParagraphProperties
Children []ParagraphChild
// contains filtered or unexported fields
}
Paragraph represents a paragraph element
func NewParagraph ¶
NewParagraph creates a new paragraph
func NewTableCellParagraph ¶
func (*Paragraph) AddFormattedText ¶
AddFormattedText adds text with specific formatting
func (*Paragraph) AddHyperlink ¶
AddHyperlink
func (*Paragraph) AddLineBreak ¶
AddLineBreak adds a paragraph
func (*Paragraph) AddPageBreak ¶
AddPageBreak adds a page break to the paragraph
func (*Paragraph) SetAlignment ¶
SetAlignment sets the paragraph alignment
func (*Paragraph) SetBorders ¶
func (p *Paragraph) SetBorders(borders *properties.ParagraphBorders) *Paragraph
SetBorders sets paragraph borders
func (*Paragraph) SetHangingIndent ¶
SetHangingIndent sets a hanging indent
func (*Paragraph) SetIndentation ¶
SetIndentation sets paragraph indentation
func (*Paragraph) SetKeepLines ¶
SetKeepLines sets whether to keep all lines together
func (*Paragraph) SetKeepNext ¶
SetKeepNext sets whether to keep this paragraph with the next one
func (*Paragraph) SetLineSpacing ¶
SetLineSpacing sets the line spacing
func (*Paragraph) SetNumbering ¶
SetNumbering sets numbering properties
ID: 1 -> Bullet list ID: 2 -> Decimal numbering ID: 3 -> Legal numbering ID: 4 -> Roman numerals ID: 5 -> Custom symbols
func (*Paragraph) SetOutlineLevel ¶
SetOutlineLevel sets the outline level for TOC
func (*Paragraph) SetPageBreakBefore ¶
SetPageBreakBefore sets whether to insert a page break before
func (*Paragraph) SetShading ¶
func (p *Paragraph) SetShading(shading *properties.ParagraphShading) *Paragraph
SetShading sets paragraph shading
func (*Paragraph) SetSpacing ¶
SetSpacing sets spacing before and after the paragraph
func (*Paragraph) SetTabs ¶
func (p *Paragraph) SetTabs(tabs []properties.TabStop) *Paragraph
SetTabs sets custom tab stops
func (*Paragraph) SetWidowControl ¶
SetWidowControl sets widow/orphan control
type ParagraphChild ¶
ParagraphChild interface for elements that can be children of a paragraph
type Run ¶
type Run struct {
Properties *properties.RunProperties
Children []RunChild
}
Run represents a run of text with consistent formatting
func (*Run) HasFormatting ¶
HasFormatting returns true if the run has any formatting applied
func (*Run) SetAllCaps ¶
SetAllCaps sets the all caps property
func (*Run) SetDoubleStrike ¶
SetDoubleStrike sets the double strikethrough property
func (*Run) SetFontFamily ¶
SetFontFamily sets the font family
func (*Run) SetFontSize ¶
SetFontSize sets the font size in points
func (*Run) SetHighlight ¶
SetHighlight sets the highlight color Values: "yellow", "green", "cyan", "magenta", "blue", "red", "darkBlue",
"darkCyan", "darkGreen", "darkMagenta", "darkRed", "darkYellow", "darkGray", "lightGray", "black", "none"
func (*Run) SetImprint ¶
SetImprint sets the imprint/engrave property
func (*Run) SetKerning ¶
SetKerning sets the kerning in points
func (*Run) SetOutline ¶
SetOutline sets the outline property
func (*Run) SetSmallCaps ¶
SetSmallCaps sets the small caps property
func (*Run) SetSpacing ¶
SetSpacing sets the character spacing in twips (1/20th of a point)
func (*Run) SetUnderline ¶
SetUnderline sets the underline property Values: "single", "double", "thick", "dotted", "dash", "dotDash", "dotDotDash", "wave"
func (*Run) SetVerticalAlign ¶
SetVerticalAlign sets the vertical alignment Values: "baseline", "superscript", "subscript"
type Tab ¶
type Tab struct {
Position int // Position in twips (optional, for positional tabs)
Alignment string // Alignment: "left", "center", "right", "decimal", "bar"
Leader string // Leader character: "dot", "hyphen", "underscore", "heavy", "middleDot"
}
Tab represents a tab character
func NewPositionalTab ¶
NewPositionalTab creates a tab at a specific position
func (*Tab) SetAlignment ¶
SetAlignment sets the tab alignment
func (*Tab) SetPosition ¶
SetPosition sets the tab position in twips
type Table ¶
type Table struct {
Properties *TableProperties
Grid *TableGrid
Rows []*TableRow
// contains filtered or unexported fields
}
Table represents a table element in a Word document
func (*Table) MergeCells ¶
MergeCells merges cells horizontally
func (*Table) SetCellFormattedText ¶
SetCellFormattedText sets formatted text in a specific cell
func (*Table) SetCellShading ¶
SetCellShading sets background color for a cell
func (*Table) SetCellText ¶
SetCellText sets text in a specific cell
func (*Table) SetCellVerticalAlignment ¶
func (t *Table) SetCellVerticalAlignment(row, col int, alignment VerticalAlign) error
SetCellVerticalAlignment sets vertical alignment for a cell
func (*Table) SetColumnWidth ¶
SetColumnWidth sets the width of a specific column
func (*Table) SetHeaderRow ¶
SetHeaderRow marks a row as a header row
func (*Table) SetRowHeight ¶
SetRowHeight sets the height of a specific row
func (*Table) SetTableAlignment ¶
func (t *Table) SetTableAlignment(alignment TableAlign)
SetTableAlignment sets table alignment (left, center, right)
func (*Table) SetTableWidth ¶
SetTableWidth sets the overall table width
type TableAlign ¶
type TableAlign string
Horizontal alignment options
const ( AlignLeft TableAlign = "left" // not shown in Word UI, but valid AlignCenterH TableAlign = "center" AlignRight TableAlign = "right" AlignJustify TableAlign = "both" )
type TableAlignment ¶
type TableAlignment struct {
Value TableAlign // left, center, right
}
TableAlignment represents table alignment
type TableBorders ¶
type TableBorders struct {
Top *BorderStyle
Left *BorderStyle
Bottom *BorderStyle
Right *BorderStyle
InsideH *BorderStyle
InsideV *BorderStyle
}
TableBorders represents table borders
func DefaultTableBorders ¶
func DefaultTableBorders() *TableBorders
DefaultTableBorders returns default table borders
type TableCell ¶
type TableCell struct {
Properties *TableCellProperties
Paragraphs []*Paragraph
}
TableCell represents a table cell
type TableCellBorders ¶
type TableCellBorders struct {
Top *BorderStyle
Left *BorderStyle
Bottom *BorderStyle
Right *BorderStyle
}
TableCellBorders represents cell borders
type TableCellMargin ¶
type TableCellMargin struct {
Top *MarginValue
Left *MarginValue
Bottom *MarginValue
Right *MarginValue
}
TableCellMargin represents table cell margins
type TableCellMargins ¶
type TableCellMargins struct {
Top *MarginValue
Left *MarginValue
Bottom *MarginValue
Right *MarginValue
}
TableCellMargins represents individual cell margins
type TableCellProperties ¶
type TableCellProperties struct {
Width *TableCellWidth
GridSpan int
VerticalMerge *VerticalMerge
Borders *TableCellBorders
Shading *TableCellShading
Margins *TableCellMargins
VerticalAlign VerticalAlign // top, center, bottom
}
TableCellProperties represents table cell properties
type TableCellShading ¶
TableCellShading represents cell shading
type TableCellSpacing ¶
TableCellSpacing represents cell spacing
type TableCellWidth ¶
TableCellWidth represents cell width
type TableGridCol ¶
type TableGridCol struct {
Width string
}
TableGridCol represents a table grid column
type TableIndent ¶
TableIndent represents table indentation
type TableLook ¶
type TableLook struct {
FirstRow string
LastRow string
FirstColumn string
LastColumn string
NoHBand string
NoVBand string
}
TableLook represents table look properties
type TableProperties ¶
type TableProperties struct {
Width *TableWidth
Alignment *TableAlignment
Borders *TableBorders
CellMargin *TableCellMargin
Style *TableStyle
Look *TableLook
CellSpacing *TableCellSpacing
Indent *TableIndent
}
TableProperties represents table properties
type TableRow ¶
type TableRow struct {
Properties *TableRowProperties
Cells []*TableCell
}
TableRow represents a table row
type TableRowHeight ¶
TableRowHeight represents row height
type TableRowProperties ¶
type TableRowProperties struct {
Height *TableRowHeight
CantSplit bool
TableHeader bool
}
TableRowProperties represents table row properties
type TableStyle ¶
type TableStyle struct {
Value string
}
TableStyle represents table style reference
type TableWidth ¶
TableWidth represents table width
type VerticalAlign ¶
type VerticalAlign string
Vertical alignment options
const ( AlignTop VerticalAlign = "top" AlignCenter VerticalAlign = "center" AlignBottom VerticalAlign = "bottom" )
type VerticalMerge ¶
type VerticalMerge struct {
Value string // restart, continue
}
VerticalMerge represents vertical cell merge