HomeUniDoc
...

Package common

Overview ▾

Package common contains wrapper types and utilities common to all of the OOXML document formats.

Package common contains common properties used by the subpackages.

Index ▾

Constants
Variables
func AddImageToZip(z *zip.Writer, img ImageRef, imageNum int, dt unioffice.DocType) error
func UtcTimeFormat(t time.Time) string
type AppProperties
    func NewAppProperties() AppProperties
    func (a AppProperties) Application() string
    func (a AppProperties) ApplicationVersion() string
    func (a AppProperties) Company() string
    func (a AppProperties) Pages() int32
    func (a AppProperties) SetApplication(s string)
    func (a AppProperties) SetApplicationVersion(s string)
    func (a AppProperties) SetCompany(s string)
    func (a AppProperties) SetDocSecurity(v int32)
    func (a AppProperties) SetLinksUpToDate(v bool)
    func (a AppProperties) SetPages(n int32)
    func (a AppProperties) X() *extended_properties.Properties
type ContentTypes
    func NewContentTypes() ContentTypes
    func (c ContentTypes) AddDefault(fileExtension string, contentType string)
    func (c ContentTypes) AddOverride(path, contentType string)
    func (c ContentTypes) CopyOverride(path, newPath string)
    func (c ContentTypes) EnsureDefault(ext, contentType string)
    func (c ContentTypes) EnsureOverride(path, contentType string)
    func (c ContentTypes) RemoveOverride(path string)
    func (c ContentTypes) RemoveOverrideByIndex(path string, indexToFind int) error
    func (c ContentTypes) X() *content_types.Types
type CoreProperties
    func NewCoreProperties() CoreProperties
    func (c CoreProperties) Author() string
    func (c CoreProperties) Category() string
    func (c CoreProperties) ContentStatus() string
    func (c CoreProperties) Created() time.Time
    func (c CoreProperties) Description() string
    func (c CoreProperties) LastModifiedBy() string
    func (c CoreProperties) Modified() time.Time
    func (c CoreProperties) SetAuthor(s string)
    func (c CoreProperties) SetCategory(s string)
    func (c CoreProperties) SetContentStatus(s string)
    func (c CoreProperties) SetCreated(t time.Time)
    func (c CoreProperties) SetDescription(s string)
    func (c CoreProperties) SetLanguage(s string)
    func (c CoreProperties) SetLastModifiedBy(s string)
    func (c CoreProperties) SetModified(t time.Time)
    func (c CoreProperties) SetTitle(s string)
    func (c CoreProperties) Title() string
    func (c CoreProperties) X() *core_properties.CoreProperties
type CustomProperties
    func NewCustomProperties() CustomProperties
    func (c CustomProperties) GetPropertyByName(name string) CustomProperty
    func (c CustomProperties) PropertiesList() []*custom_properties.CT_Property
    func (c CustomProperties) SetPropertyAsArray(name string, array *docPropsVTypes.Array)
    func (c CustomProperties) SetPropertyAsBlob(name, blob string)
    func (c CustomProperties) SetPropertyAsBool(name string, b bool)
    func (c CustomProperties) SetPropertyAsBstr(name string, bstr string)
    func (c CustomProperties) SetPropertyAsClsid(name string, clsid string)
    func (c CustomProperties) SetPropertyAsCy(name string, cy string)
    func (c CustomProperties) SetPropertyAsDate(name string, date time.Time)
    func (c CustomProperties) SetPropertyAsDecimal(name string, decimal float64)
    func (c CustomProperties) SetPropertyAsEmpty(name string)
    func (c CustomProperties) SetPropertyAsError(name string, error string)
    func (c CustomProperties) SetPropertyAsFiletime(name string, filetime time.Time)
    func (c CustomProperties) SetPropertyAsI1(name string, i1 int8)
    func (c CustomProperties) SetPropertyAsI2(name string, i2 int16)
    func (c CustomProperties) SetPropertyAsI4(name string, i4 int32)
    func (c CustomProperties) SetPropertyAsI8(name string, i8 int64)
    func (c CustomProperties) SetPropertyAsInt(name string, i int)
    func (c CustomProperties) SetPropertyAsLpstr(name string, lpstr string)
    func (c CustomProperties) SetPropertyAsLpwstr(name string, lpwstr string)
    func (c CustomProperties) SetPropertyAsNull(name string)
    func (c CustomProperties) SetPropertyAsOblob(name, oblob string)
    func (c CustomProperties) SetPropertyAsOstorage(name string, ostorage string)
    func (c CustomProperties) SetPropertyAsOstream(name string, ostream string)
    func (c CustomProperties) SetPropertyAsR4(name string, r4 float32)
    func (c CustomProperties) SetPropertyAsR8(name string, r8 float64)
    func (c CustomProperties) SetPropertyAsStorage(name string, storage string)
    func (c CustomProperties) SetPropertyAsStream(name string, stream string)
    func (c CustomProperties) SetPropertyAsUi1(name string, ui1 uint8)
    func (c CustomProperties) SetPropertyAsUi2(name string, ui2 uint16)
    func (c CustomProperties) SetPropertyAsUi4(name string, ui4 uint32)
    func (c CustomProperties) SetPropertyAsUi8(name string, ui8 uint64)
    func (c CustomProperties) SetPropertyAsUint(name string, ui uint)
    func (c CustomProperties) SetPropertyAsVector(name string, vector *docPropsVTypes.Vector)
    func (c CustomProperties) SetPropertyAsVstream(name string, vstream *docPropsVTypes.Vstream)
    func (c CustomProperties) X() *custom_properties.Properties
type CustomProperty
    func (c CustomProperty) X() *custom_properties.CT_Property
type DocBase
    func (d *DocBase) AddCustomRelationships()
    func (d *DocBase) AddExtraFileFromZip(f *zip.File) error
    func (docBase0 DocBase) Append(docBase1 DocBase) DocBase
    func (d *DocBase) CreateCustomProperties()
    func (d *DocBase) GetImageBytesByTarget(target string) (Image, error)
    func (d *DocBase) GetOrCreateCustomProperties() CustomProperties
    func (d *DocBase) WriteExtraFiles(z *zip.Writer) error
type ExtraFile
type Hyperlink
type Image
    func ImageFromBytes(data []byte) (Image, error)
    func ImageFromFile(path string) (Image, error)
    func ImageFromStorage(path string) (Image, error)
type ImageRef
    func MakeImageRef(img Image, d *DocBase, rels Relationships) ImageRef
    func (i ImageRef) Data() *[]byte
    func (i ImageRef) Format() string
    func (i ImageRef) Path() string
    func (i ImageRef) RelID() string
    func (i ImageRef) RelativeHeight(w measurement.Distance) measurement.Distance
    func (i ImageRef) RelativeWidth(h measurement.Distance) measurement.Distance
    func (i *ImageRef) SetRelID(id string)
    func (i *ImageRef) SetTarget(target string)
    func (i ImageRef) Size() image.Point
    func (i *ImageRef) Target() string
type Relationship
    func NewRelationship() Relationship
    func (r Relationship) ID() string
    func (r Relationship) SetID(ID string)
    func (r Relationship) SetTarget(s string)
    func (r Relationship) String() string
    func (r Relationship) Target() string
    func (r Relationship) Type() string
    func (r Relationship) X() *relationships.Relationship
type Relationships
    func NewRelationships() Relationships
    func NewRelationshipsCopy(rels Relationships) Relationships
    func (r Relationships) AddAutoRelationship(dt unioffice.DocType, src string, idx int, ctype string) Relationship
    func (r Relationships) AddHyperlink(target string) Hyperlink
    func (r Relationships) AddRelationship(target, ctype string) Relationship
    func (r Relationships) Clear()
    func (r Relationships) CopyRelationship(idAttr string) (Relationship, bool)
    func (r Relationships) FindRIDForN(i int, t string) string
    func (r Relationships) GetByRelId(idAttr string) Relationship
    func (r Relationships) GetTargetByRelId(idAttr string) string
    func (r Relationships) GetTargetByRelIdAndType(idAttr string, typeAttr string) string
    func (r Relationships) IsEmpty() bool
    func (r Relationships) Relationships() []Relationship
    func (r Relationships) Remove(rel Relationship) bool
    func (r Relationships) X() *relationships.Relationships
type Table
    func NewTable() *Table
    func NewTableWithXfrm(xfrm *dml.CT_Transform2D) *Table
    func (t Table) AddCol() *TableCol
    func (t Table) AddRow() *TableRow
    func (t Table) Grid() *dml.CT_TableGrid
    func (t Table) Properties() *dml.CT_TableProperties
    func (t Table) Rows() []*TableRow
    func (t Table) SetOffsetX(offX float64)
    func (t Table) SetOffsetY(offY float64)
    func (t Table) SetStyle(style *dml.CT_TableStyle)
    func (t Table) X() *dml.Tbl
type TableCol
    func (c TableCol) SetWidth(m measurement.Distance)
type TableRow
    func (r TableRow) Cells() []*dml.CT_TableCell
    func (r TableRow) SetHeight(m measurement.Distance)
type TableStyles
    func NewTableStyles() TableStyles
    func (t TableStyles) DefAttr() string
    func (t TableStyles) TblStyle() []*dml.CT_TableStyle
    func (t TableStyles) X() *dml.TblStyleLst
type Theme
    func NewTheme() Theme
    func (t Theme) X() *dml.Theme

Examples

CoreProperties
CustomProperties

Package files

append.go appproperties.go contenttypes.go coreproperties.go customproperties.go doc.go docbase.go helpers.go image.go relationship.go relationships.go storage.go table.go table_col.go table_row.go table_styles.go theme.go time.go version.go

Constants

Version holds version information, when bumping this make sure to bump the released at stamp also.

const Version = "1.36.0"

Variables

var ReleasedAt = time.Date(releaseYear, releaseMonth, releaseDay, releaseHour, releaseMin, 0, 0, time.UTC)

func AddImageToZip

func AddImageToZip(z *zip.Writer, img ImageRef, imageNum int, dt unioffice.DocType) error

AddImageToZip adds an image (either from bytes or from disk) and adds it to the zip file.

func UtcTimeFormat

func UtcTimeFormat(t time.Time) string

type AppProperties

AppProperties contains properties specific to the document and the application that created it.

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

func NewAppProperties

func NewAppProperties() AppProperties

NewAppProperties constructs a new AppProperties.

func (AppProperties) Application

func (a AppProperties) Application() string

Application returns the name of the application that created the document. For unioffice created documents, it defaults to github.com/unidoc/unioffice

func (AppProperties) ApplicationVersion

func (a AppProperties) ApplicationVersion() string

ApplicationVersion returns the version of the application that created the document.

func (AppProperties) Company

func (a AppProperties) Company() string

Company returns the name of the company that created the document. For unioffice created documents, it defaults to github.com/unidoc/unioffice

func (AppProperties) Pages

func (a AppProperties) Pages() int32

Pages returns total number of pages which are saved by the text editor which produced the document. For unioffice created documents, it is 0.

func (AppProperties) SetApplication

func (a AppProperties) SetApplication(s string)

SetApplication sets the name of the application that created the document.

func (AppProperties) SetApplicationVersion

func (a AppProperties) SetApplicationVersion(s string)

SetApplicationVersion sets the version of the application that created the document. Per MS, the verison string mut be in the form 'XX.YYYY'.

func (AppProperties) SetCompany

func (a AppProperties) SetCompany(s string)

SetCompany sets the name of the company that created the document.

func (AppProperties) SetDocSecurity

func (a AppProperties) SetDocSecurity(v int32)

SetDocSecurity sets the document security flag.

func (AppProperties) SetLinksUpToDate

func (a AppProperties) SetLinksUpToDate(v bool)

SetLinksUpToDate sets the links up to date flag.

func (AppProperties) SetPages

func (a AppProperties) SetPages(n int32)

SetPages sets the pages count of the document.

func (AppProperties) X

func (a AppProperties) X() *extended_properties.Properties

X returns the inner wrapped XML type.

type ContentTypes

ContentTypes is the top level "[Content_Types].xml" in a zip package.

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

func NewContentTypes

func NewContentTypes() ContentTypes

NewContentTypes returns a wrapper around a newly constructed content-types.

func (ContentTypes) AddDefault

func (c ContentTypes) AddDefault(fileExtension string, contentType string)

AddDefault registers a default content type for a given file extension.

func (ContentTypes) AddOverride

func (c ContentTypes) AddOverride(path, contentType string)

AddOverride adds an override content type for a given path name.

func (ContentTypes) CopyOverride

func (c ContentTypes) CopyOverride(path, newPath string)

CopyOverride copies override content type for a given `path` and puts it with a path `newPath`.

func (ContentTypes) EnsureDefault

func (c ContentTypes) EnsureDefault(ext, contentType string)

EnsureDefault esnures that an extension and default content type exist, adding it if necessary.

func (ContentTypes) EnsureOverride

func (c ContentTypes) EnsureOverride(path, contentType string)

EnsureOverride ensures that an override for the given path exists, adding it if necessary

func (ContentTypes) RemoveOverride

func (c ContentTypes) RemoveOverride(path string)

RemoveOverride removes an override given a path.

func (ContentTypes) RemoveOverrideByIndex

func (c ContentTypes) RemoveOverrideByIndex(path string, indexToFind int) error

RemoveOverrideByIndex removes an override given a path and override index.

func (ContentTypes) X

func (c ContentTypes) X() *content_types.Types

X returns the inner raw content types.

type CoreProperties

CoreProperties contains document specific properties.

type CoreProperties struct {
    // contains filtered or unexported fields
}
Example

Code:

doc, _ := document.Open("document.docx")
defer doc.Close()
cp := doc.CoreProperties
// Reading Properties
fmt.Println("Title:", cp.Title())
fmt.Println("Author:", cp.Author())
fmt.Println("Description:", cp.Description())
fmt.Println("Last Modified By:", cp.LastModifiedBy())
fmt.Println("Category:", cp.Category())
fmt.Println("Content Status:", cp.ContentStatus())
fmt.Println("Created:", cp.Created())
fmt.Println("Modified:", cp.Modified())

// Setting Properties
cp.SetTitle("CP Invoices")
cp.SetAuthor("John Doe")
cp.SetCategory("Invoices")
cp.SetContentStatus("Draft")
cp.SetLastModifiedBy("Jane Smith")
cp.SetCreated(time.Now())
cp.SetModified(time.Now())
doc.SaveToFile("document.docx")

func NewCoreProperties

func NewCoreProperties() CoreProperties

NewCoreProperties constructs a new CoreProperties.

func (CoreProperties) Author

func (c CoreProperties) Author() string

Author returns the author of the document

func (CoreProperties) Category

func (c CoreProperties) Category() string

Category returns the category of the document

func (CoreProperties) ContentStatus

func (c CoreProperties) ContentStatus() string

ContentStatus returns the content status of the document (e.g. "Final", "Draft")

func (CoreProperties) Created

func (c CoreProperties) Created() time.Time

Created returns the time that the document was created.

func (CoreProperties) Description

func (c CoreProperties) Description() string

Description returns the description of the document

func (CoreProperties) LastModifiedBy

func (c CoreProperties) LastModifiedBy() string

LastModifiedBy returns the name of the last person to modify the document

func (CoreProperties) Modified

func (c CoreProperties) Modified() time.Time

Modified returns the time that the document was modified.

func (CoreProperties) SetAuthor

func (c CoreProperties) SetAuthor(s string)

SetAuthor records the author of the document.

func (CoreProperties) SetCategory

func (c CoreProperties) SetCategory(s string)

SetCategory records the category of the document.

func (CoreProperties) SetContentStatus

func (c CoreProperties) SetContentStatus(s string)

SetContentStatus records the content status of the document.

func (CoreProperties) SetCreated

func (c CoreProperties) SetCreated(t time.Time)

SetCreated sets the time that the document was created.

func (CoreProperties) SetDescription

func (c CoreProperties) SetDescription(s string)

SetDescription records the description of the document.

func (CoreProperties) SetLanguage

func (c CoreProperties) SetLanguage(s string)

SetLanguage records the language of the document.

func (CoreProperties) SetLastModifiedBy

func (c CoreProperties) SetLastModifiedBy(s string)

SetLastModifiedBy records the last person to modify the document.

func (CoreProperties) SetModified

func (c CoreProperties) SetModified(t time.Time)

SetModified sets the time that the document was modified.

func (CoreProperties) SetTitle

func (c CoreProperties) SetTitle(s string)

SetTitle records the title of the document.

func (CoreProperties) Title

func (c CoreProperties) Title() string

Title returns the Title of the document

func (CoreProperties) X

func (c CoreProperties) X() *core_properties.CoreProperties

X returns the inner wrapped XML type.

type CustomProperties

CustomProperties contains document specific properties.

type CustomProperties struct {
    // contains filtered or unexported fields
}
Example

Code:

doc, _ := document.Open("document.docx")
doc.Close()

cp := doc.CustomProperties
// You can read properties from the document
fmt.Println("AppVersion", *cp.GetPropertyByName("AppVersion").X().Lpwstr)
fmt.Println("category", *cp.GetPropertyByName("category").X().Lpwstr)
fmt.Println("contentStatus", *cp.GetPropertyByName("contentStatus").X().Lpwstr)
fmt.Println("HyperlinksChanged", *cp.GetPropertyByName("HyperlinksChanged").X().Bool)
fmt.Println("Non-existent", cp.GetPropertyByName("nonexistentproperty"))

// And change them as well
cp.SetPropertyAsLpwstr("Another text property", "My text value") // text
cp.SetPropertyAsI4("Another integer number property", 42)        // int23
cp.SetPropertyAsR8("Another float number property", 3.14)        // float64
cp.SetPropertyAsDate("Another date property", time.Now())        // date

doc.SaveToFile("document.docx")

func NewCustomProperties

func NewCustomProperties() CustomProperties

NewCustomProperties constructs a new CustomProperties.

func (CustomProperties) GetPropertyByName

func (c CustomProperties) GetPropertyByName(name string) CustomProperty

GetPropertyByName returns a custom property selected by it's name.

func (CustomProperties) PropertiesList

func (c CustomProperties) PropertiesList() []*custom_properties.CT_Property

PropertiesList returns the list of all custom properties of the document.

func (CustomProperties) SetPropertyAsArray

func (c CustomProperties) SetPropertyAsArray(name string, array *docPropsVTypes.Array)

func (CustomProperties) SetPropertyAsBlob

func (c CustomProperties) SetPropertyAsBlob(name, blob string)

func (CustomProperties) SetPropertyAsBool

func (c CustomProperties) SetPropertyAsBool(name string, b bool)

func (CustomProperties) SetPropertyAsBstr

func (c CustomProperties) SetPropertyAsBstr(name string, bstr string)

func (CustomProperties) SetPropertyAsClsid

func (c CustomProperties) SetPropertyAsClsid(name string, clsid string)

func (CustomProperties) SetPropertyAsCy

func (c CustomProperties) SetPropertyAsCy(name string, cy string)

func (CustomProperties) SetPropertyAsDate

func (c CustomProperties) SetPropertyAsDate(name string, date time.Time)

func (CustomProperties) SetPropertyAsDecimal

func (c CustomProperties) SetPropertyAsDecimal(name string, decimal float64)

func (CustomProperties) SetPropertyAsEmpty

func (c CustomProperties) SetPropertyAsEmpty(name string)

func (CustomProperties) SetPropertyAsError

func (c CustomProperties) SetPropertyAsError(name string, error string)

func (CustomProperties) SetPropertyAsFiletime

func (c CustomProperties) SetPropertyAsFiletime(name string, filetime time.Time)

func (CustomProperties) SetPropertyAsI1

func (c CustomProperties) SetPropertyAsI1(name string, i1 int8)

func (CustomProperties) SetPropertyAsI2

func (c CustomProperties) SetPropertyAsI2(name string, i2 int16)

func (CustomProperties) SetPropertyAsI4

func (c CustomProperties) SetPropertyAsI4(name string, i4 int32)

func (CustomProperties) SetPropertyAsI8

func (c CustomProperties) SetPropertyAsI8(name string, i8 int64)

func (CustomProperties) SetPropertyAsInt

func (c CustomProperties) SetPropertyAsInt(name string, i int)

func (CustomProperties) SetPropertyAsLpstr

func (c CustomProperties) SetPropertyAsLpstr(name string, lpstr string)

func (CustomProperties) SetPropertyAsLpwstr

func (c CustomProperties) SetPropertyAsLpwstr(name string, lpwstr string)

func (CustomProperties) SetPropertyAsNull

func (c CustomProperties) SetPropertyAsNull(name string)

func (CustomProperties) SetPropertyAsOblob

func (c CustomProperties) SetPropertyAsOblob(name, oblob string)

func (CustomProperties) SetPropertyAsOstorage

func (c CustomProperties) SetPropertyAsOstorage(name string, ostorage string)

func (CustomProperties) SetPropertyAsOstream

func (c CustomProperties) SetPropertyAsOstream(name string, ostream string)

func (CustomProperties) SetPropertyAsR4

func (c CustomProperties) SetPropertyAsR4(name string, r4 float32)

func (CustomProperties) SetPropertyAsR8

func (c CustomProperties) SetPropertyAsR8(name string, r8 float64)

func (CustomProperties) SetPropertyAsStorage

func (c CustomProperties) SetPropertyAsStorage(name string, storage string)

func (CustomProperties) SetPropertyAsStream

func (c CustomProperties) SetPropertyAsStream(name string, stream string)

func (CustomProperties) SetPropertyAsUi1

func (c CustomProperties) SetPropertyAsUi1(name string, ui1 uint8)

func (CustomProperties) SetPropertyAsUi2

func (c CustomProperties) SetPropertyAsUi2(name string, ui2 uint16)

func (CustomProperties) SetPropertyAsUi4

func (c CustomProperties) SetPropertyAsUi4(name string, ui4 uint32)

func (CustomProperties) SetPropertyAsUi8

func (c CustomProperties) SetPropertyAsUi8(name string, ui8 uint64)

func (CustomProperties) SetPropertyAsUint

func (c CustomProperties) SetPropertyAsUint(name string, ui uint)

func (CustomProperties) SetPropertyAsVector

func (c CustomProperties) SetPropertyAsVector(name string, vector *docPropsVTypes.Vector)

func (CustomProperties) SetPropertyAsVstream

func (c CustomProperties) SetPropertyAsVstream(name string, vstream *docPropsVTypes.Vstream)

func (CustomProperties) X

func (c CustomProperties) X() *custom_properties.Properties

X returns the inner wrapped XML type.

type CustomProperty

CustomProperty contains document specific property. Using of this type is deprecated.

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

func (CustomProperty) X

func (c CustomProperty) X() *custom_properties.CT_Property

X returns the inner wrapped XML type of CustomProperty.

type DocBase

DocBase is the type embedded in in the Document/Workbook/Presentation types that contains members common to all.

type DocBase struct {
    ContentTypes     ContentTypes
    AppProperties    AppProperties
    Rels             Relationships
    CoreProperties   CoreProperties
    CustomProperties CustomProperties
    Thumbnail        image.Image // thumbnail preview of the document

    Images     []ImageRef
    ExtraFiles []ExtraFile
    TmpPath    string // path where temporary files are stored when opening documents
}

func (*DocBase) AddCustomRelationships

func (d *DocBase) AddCustomRelationships()

AddCustomRelationships adds relationships related to custom properties to the document.

func (*DocBase) AddExtraFileFromZip

func (d *DocBase) AddExtraFileFromZip(f *zip.File) error

AddExtraFileFromZip is used when reading an unsupported file from an OOXML file. This ensures that unsupported file content will at least round-trip correctly.

func (DocBase) Append

func (docBase0 DocBase) Append(docBase1 DocBase) DocBase

Append appends DocBase part of an office document to another DocBase.

func (*DocBase) CreateCustomProperties

func (d *DocBase) CreateCustomProperties()

CreateCustomProperties creates the custom properties of the document.

func (*DocBase) GetImageBytesByTarget

func (d *DocBase) GetImageBytesByTarget(target string) (Image, error)

GetImageBytesByTarget returns Image object with Data bytes read from its target.

func (*DocBase) GetOrCreateCustomProperties

func (d *DocBase) GetOrCreateCustomProperties() CustomProperties

GetOrCreateCustomProperties returns the custom properties of the document (and if they not exist yet, creating them first).

func (*DocBase) WriteExtraFiles

func (d *DocBase) WriteExtraFiles(z *zip.Writer) error

WriteExtraFiles writes the extra files to the zip package.

type ExtraFile

ExtraFile is an unsupported file type extracted from, or to be written to a zip package

type ExtraFile struct {
    ZipPath  string
    DiskPath string // TODO: Change to "StoragePath" in next major version (v2).
}

Hyperlink is just an appropriately configured relationship.

type Hyperlink Relationship

type Image

Image is a container for image information. It's used as we need format and and size information to use images. It contains either the filesystem path to the image, or the image itself.

type Image struct {
    Size   image.Point
    Format string
    Path   string
    Data   *[]byte
}

func ImageFromBytes

func ImageFromBytes(data []byte) (Image, error)

ImageFromBytes returns an Image struct for an in-memory image. You can also construct an Image directly if the file and size are known.

func ImageFromFile

func ImageFromFile(path string) (Image, error)

ImageFromFile reads an image from a file on disk. It doesn't keep the image in memory and only reads it to determine the format and size. You can also construct an Image directly if the file and size are known. NOTE: See also ImageFromStorage.

func ImageFromStorage

func ImageFromStorage(path string) (Image, error)

ImageFromStorage reads an image using the currently set temporary storage mechanism (see tempstorage). You can also construct an Image directly if the file and size are known.

type ImageRef

ImageRef is a reference to an image within a document.

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

func MakeImageRef

func MakeImageRef(img Image, d *DocBase, rels Relationships) ImageRef

MakeImageRef constructs an image reference which is a reference to a particular image file inside a document. The same image can be used multiple times in a document by re-use the ImageRef.

func (ImageRef) Data

func (i ImageRef) Data() *[]byte

Data returns the data of an image file, if any.

func (ImageRef) Format

func (i ImageRef) Format() string

Format returns the format of the underlying image

func (ImageRef) Path

func (i ImageRef) Path() string

Path returns the path to an image file, if any.

func (ImageRef) RelID

func (i ImageRef) RelID() string

RelID returns the relationship ID.

func (ImageRef) RelativeHeight

func (i ImageRef) RelativeHeight(w measurement.Distance) measurement.Distance

RelativeHeight returns the relative height of an image given a fixed width. This is used when setting image to a fixed width to calculate the height required to keep the same image aspect ratio.

func (ImageRef) RelativeWidth

func (i ImageRef) RelativeWidth(h measurement.Distance) measurement.Distance

RelativeWidth returns the relative width of an image given a fixed height. This is used when setting image to a fixed height to calculate the width required to keep the same image aspect ratio.

func (*ImageRef) SetRelID

func (i *ImageRef) SetRelID(id string)

func (*ImageRef) SetTarget

func (i *ImageRef) SetTarget(target string)

SetTarget changes the target attribute of the image reference (e.g. in the case of the creation of the reference or if the image which the reference is related to was moved from one location to another).

func (ImageRef) Size

func (i ImageRef) Size() image.Point

Size returns the size of an image

func (*ImageRef) Target

func (i *ImageRef) Target() string

Target returns the target attrubute of the image reference (a path where the image file is located in the document structure).

type Relationship

Relationship is a relationship within a .rels file.

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

func NewRelationship

func NewRelationship() Relationship

NewRelationship constructs a new relationship.

func (Relationship) ID

func (r Relationship) ID() string

ID returns the ID of a relationship.

func (Relationship) SetID

func (r Relationship) SetID(ID string)

SetID set the ID of a relationship.

func (Relationship) SetTarget

func (r Relationship) SetTarget(s string)

SetTarget set the target (path) of a relationship.

func (Relationship) String

func (r Relationship) String() string

func (Relationship) Target

func (r Relationship) Target() string

Target returns the target (path) of a relationship.

func (Relationship) Type

func (r Relationship) Type() string

Type returns the type of a relationship.

func (Relationship) X

func (r Relationship) X() *relationships.Relationship

X returns the inner wrapped XML type.

type Relationships

Relationships represents a .rels file.

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

func NewRelationships

func NewRelationships() Relationships

NewRelationships creates a new relationship wrapper.

func NewRelationshipsCopy

func NewRelationshipsCopy(rels Relationships) Relationships

NewRelationshipsCopy creates a new relationships wrapper as a copy of passed in instance.

func (Relationships) AddAutoRelationship

func (r Relationships) AddAutoRelationship(dt unioffice.DocType, src string, idx int, ctype string) Relationship

AddAutoRelationship adds a relationship with an automatically generated filename based off of the type. It should be preferred over AddRelationship to ensure consistent filenames are maintained.

func (r Relationships) AddHyperlink(target string) Hyperlink

AddHyperlink adds an external hyperlink relationship.

func (Relationships) AddRelationship

func (r Relationships) AddRelationship(target, ctype string) Relationship

AddRelationship adds a relationship.

func (Relationships) Clear

func (r Relationships) Clear()

Clear removes any existing relationships.

func (Relationships) CopyRelationship

func (r Relationships) CopyRelationship(idAttr string) (Relationship, bool)

CopyRelationship copies the relationship.

func (Relationships) FindRIDForN

func (r Relationships) FindRIDForN(i int, t string) string

FindRIDForN returns the relationship ID for the i'th relationship of type t.

func (Relationships) GetByRelId

func (r Relationships) GetByRelId(idAttr string) Relationship

GetByRelId returns a relationship with the associated relation ID.

func (Relationships) GetTargetByRelId

func (r Relationships) GetTargetByRelId(idAttr string) string

GetTargetByRelId returns a target path with the associated relation ID.

func (Relationships) GetTargetByRelIdAndType

func (r Relationships) GetTargetByRelIdAndType(idAttr string, typeAttr string) string

GetTargetByRelIdAndType returns a target path with the associated relation ID.

func (Relationships) IsEmpty

func (r Relationships) IsEmpty() bool

IsEmpty returns true if there are no relationships.

func (Relationships) Relationships

func (r Relationships) Relationships() []Relationship

Relationships returns a slice of all of the relationships.

func (Relationships) Remove

func (r Relationships) Remove(rel Relationship) bool

Remove removes an existing relationship.

func (Relationships) X

func (r Relationships) X() *relationships.Relationships

X returns the underlying raw XML data.

type Table

Table represents a table in the document.

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

func NewTable

func NewTable() *Table

NewTable makes a new table.

func NewTableWithXfrm

func NewTableWithXfrm(xfrm *dml.CT_Transform2D) *Table

NewTableWithXfrm makes a new table with a pointer to its parent Xfrm for changing its offset and size.

func (Table) AddCol

func (t Table) AddCol() *TableCol

AddCol adds a column to a table.

func (Table) AddRow

func (t Table) AddRow() *TableRow

AddRow adds a row to a table.

func (Table) Grid

func (t Table) Grid() *dml.CT_TableGrid

Properties returns table properties.

func (Table) Properties

func (t Table) Properties() *dml.CT_TableProperties

Properties returns table properties.

func (Table) Rows

func (t Table) Rows() []*TableRow

Rows returns all table rows.

func (Table) SetOffsetX

func (t Table) SetOffsetX(offX float64)

SetOffsetX sets horizontal offset of a table in distance units (see measurement package).

func (Table) SetOffsetY

func (t Table) SetOffsetY(offY float64)

SetOffsetY sets vertical offset of a table in distance units (see measurement package).

func (Table) SetStyle

func (t Table) SetStyle(style *dml.CT_TableStyle)

SetStyle assigns TableStyle to a table.

func (Table) X

func (t Table) X() *dml.Tbl

X returns the inner wrapped XML type.

type TableCol

TableCol represents a column in a table.

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

func (TableCol) SetWidth

func (c TableCol) SetWidth(m measurement.Distance)

SetWidth sets column width, see measurement package.

type TableRow

TableRow represents a row in a table.

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

func (TableRow) Cells

func (r TableRow) Cells() []*dml.CT_TableCell

Cells returns an array of row cells.

func (TableRow) SetHeight

func (r TableRow) SetHeight(m measurement.Distance)

SetHeight sets row height, see measurement package.

type TableStyles

TableStyles contains document specific properties.

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

func NewTableStyles

func NewTableStyles() TableStyles

NewTableStyles constructs a new TableStyles.

func (TableStyles) DefAttr

func (t TableStyles) DefAttr() string

DefAttr returns the DefAttr property.

func (TableStyles) TblStyle

func (t TableStyles) TblStyle() []*dml.CT_TableStyle

TblStyle returns the TblStyle property.

func (TableStyles) X

func (t TableStyles) X() *dml.TblStyleLst

X returns the inner wrapped XML type.

type Theme

Theme is a drawingml theme.

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

func NewTheme

func NewTheme() Theme

NewTheme constructs a new theme.

func (Theme) X

func (t Theme) X() *dml.Theme

X returns the inner wrapped XML type.

Subdirectories

Name Synopsis
..
axcontrol
license Package license helps manage commercial licenses and check if they are valid for the version of UniOffice used.
logger
tempstorage
diskstore Package diskstore implements tempStorage interface by using disk as a storage
memstore Package memstore implements tempStorage interface by using memory as a storage