...
Documentation
Documentation

# Package convertutils

## Overview ▹

## Overview ▾

## Index ▹

## Index ▾

### Package files

area_chart.go bar_chart.go chart.go chart_axis.go color.go fonts.go line_chart.go pie_chart.go scatter_chart.go utils.go

## Variables

    var (
        DefaultFontSize     = 12.0 // the height of font sized 12 points, possible default fonts for Word and Excel are 11 or 12 points.
        DefaultImageEncoder core.StreamEncoder

        // DefaultPageSize is the default page size that should be used in all conversion processes.
        DefaultPageSize = PageSizeA4
    )

    var RtlFontFile *model.PdfFont

    var StdFontsMap = map[string][]string{
        "Helvetica": []string{
            "Helvetica",
            "Helvetica-Bold",
            "Helvetica-Oblique",
            "Helvetica-BoldOblique",
        },
        "Courier": []string{
            "Courier",
            "Courier-Bold",
            "Courier-Oblique",
            "Courier-BoldOblique",
        },
        "Times New Roman": []string{
            "Times-Roman",
            "Times-Bold",
            "Times-Italic",
            "Times-BoldItalic",
        },
        "default": []string{
            "Helvetica",
            "Helvetica-Bold",
            "Helvetica-Oblique",
            "Helvetica-BoldOblique",
        },
    }

## func AdjustColor ¶

    func AdjustColor(colorStr string, EG_ColorTransform []*dml.EG_ColorTransform) string

AdjustColor adjusts a color represented by a hexadecimal string with a given array of transform values.

## func AdjustColorByLumMod ¶

    func AdjustColorByLumMod(colorStr string, lum float64) string

AdjustColorByLumMod adjusts a color represented by a hexadecimal string with a given luminance modulation.

## func AdjustColorByLumOff ¶

    func AdjustColorByLumOff(colorStr string, lumOff float64) string

AdjustColorByLumOff adjusts a color represented by a hexadecimal string with a given luminance offset.

## func AdjustColorByShade ¶

    func AdjustColorByShade(colorStr string, shade float64) string

AdjustColorByShade adjusts a color represented by a hexadecimal string with a given shade.

## func AdjustColorByTint ¶

    func AdjustColorByTint(colorStr string, tint float64) string

AdjustColorByTint adjusts a color represented by a hexadecimal string with a given tint.

## func AssignStdFontByName ¶

    func AssignStdFontByName(style creator.TextStyle, fontName string) *model.PdfFont

## func ClearRegisteredFonts ¶

    func ClearRegisteredFonts()

## func CropImageByRect ¶

    func CropImageByRect(sourceImg image.Image, rect image.Rectangle) image.Image

## func DrawLine ¶

    func DrawLine(c *creator.Creator, x0, y0, x1, y1, width float64, color creator.Color)

DrawLine draws a line with given coordinates, width and color.

## func DrawRectangle ¶

    func DrawRectangle(c *creator.Creator, r *Rectangle, w float64, color creator.Color)

DrawRectangle draws a rectangle with given coordinates, width and color.

## func FillRectangle ¶

    func FillRectangle(c *creator.Creator, x, y, width, height float64, color creator.Color)

FillRectangle fills a rectangle with given coordinates and color.

## func FromSTCoordinate ¶

    func FromSTCoordinate(st dml.ST_Coordinate) int64

FromSTCoordinate returns an int64 value from dml.ST_Coordinate or 0 in the case of nil.

## func FromSTCoordinate32 ¶

    func FromSTCoordinate32(st dml.ST_Coordinate32) int64

FromSTCoordinate32 returns an int64 value from dml.ST_Coordinate32 or 0 in the case of nil.

## func FromSTPercentage ¶

    func FromSTPercentage(st *dml.ST_Percentage) float64

## func GetColorStringFromDmlColor ¶

    func GetColorStringFromDmlColor(dmlColor *dml.CT_Color) string

GetColorStringFromDmlColor returns a hexadecimal string representation of dml.CT_Color in the 'rgb' format.

## func GetDataFromXfrm ¶

    func GetDataFromXfrm(xfrm *dml.CT_Transform2D) (float64, float64, float64, float64)

## func GetDefaultPageSize ¶

    func GetDefaultPageSize() creator.PageSize

GetDefaultPageSize returns the default page size.

## func GetGroupOffsetFromXfrm ¶

    func GetGroupOffsetFromXfrm(xfrm *dml.CT_GroupTransform2D) (float64, float64)

## func GetImage ¶

    func GetImage(c *creator.Creator, goImg image.Image, imgHeight, imgWidth, left, top, dividerX, dividerY float64, part ImgPart) (*creator.Image, error)

## func GetOpacityFromColorTransform ¶

    func GetOpacityFromColorTransform(trs []*dml.EG_ColorTransform) float64

## func GetPageDimensions ¶

    func GetPageDimensions(size PageSize) creator.PageSize

GetPageDimensions returns the page dimensions for a given PageSize.

## func GetPageFromCreator ¶

    func GetPageFromCreator(c *creator.Creator) (*model.PdfPage, error)

## func GetRegisteredFont ¶

    func GetRegisteredFont(name string, style FontStyle) *model.PdfFont

## func IsNoSpaceLanguage ¶

    func IsNoSpaceLanguage(symbol string) bool

## func Lighten ¶

    func Lighten(clr float64) float64

Lighten makes a r, g or b channel value lighter by 40% for getting colors of headers and footers.

## func LoadFontFromFile ¶

    func LoadFontFromFile(filename string) (*model.PdfFont, error)

LoadFontFromFile loads PDF font from ttf file and returns it

## func MakeBlockFromChartSpace ¶

    func MakeBlockFromChartSpace(cs *crt.ChartSpace, width, height float64, theme *dml.Theme) (*creator.Block, error)

MakeBlockFromChartSpace makes creator.Block from the chart space.

## func MakeBlockFromCreator ¶

    func MakeBlockFromCreator(c *creator.Creator) (*creator.Block, error)

MakeBlockFromCreator makes a creator.Block from the first page of a creator.

## func MakeImageFromChartSpace ¶

    func MakeImageFromChartSpace(cs *crt.ChartSpace, width, height float64, theme *dml.Theme, workbook *spreadsheet.Workbook) (image.Image, error)

MakeBlockFromChartSpace renders a Go image from the chart space.

## func MakeTempCreator ¶

    func MakeTempCreator(width, height float64) *creator.Creator

MakeTempCreator returns a creator.Creator with a given width and height in millimeters.

## func MakeTempCreatorMaxHeight ¶

    func MakeTempCreatorMaxHeight(width float64) *creator.Creator

MakeTempCreator returns a creator.Creator with a given width in millimeters and a height that tall enough to fit most content.

## func ParseExcelRange ¶

    func ParseExcelRange(s string) (string, reference.CellReference, reference.CellReference, error)

## func PointsFromTwips ¶

    func PointsFromTwips(twips int64) float64

PointsFromTwips converts twips to points.

## func RegisterEmbeddedFonts ¶

    func RegisterEmbeddedFonts(d *document.Document) error

## func RegisterFont ¶

    func RegisterFont(name string, style FontStyle, font *model.PdfFont)

RegisterFont makes a PdfFont accessible for using in converting to PDF.

## func RegisterFontsFromDirectory ¶

    func RegisterFontsFromDirectory(dirName string) error

RegisterFontsFromDirectory registers all fonts from the given directory.

## func RegisterFontsFromFiles ¶

    func RegisterFontsFromFiles(files []string) error

RegisterFontsFromFiles registers all fonts from given slice of files.

## func TwipsFromPoints ¶

    func TwipsFromPoints(points float64) float64

TwipsFromPoints converts points to twips.

## type BorderPosition ¶

    type BorderPosition byte

    const (
        BorderPositionTop    BorderPosition = 0
        BorderPositionLeft   BorderPosition = 1
        BorderPositionBottom BorderPosition = 2
        BorderPositionRight  BorderPosition = 3
    )

## type FontStyle ¶

FontStyle represents a kind of font styling. It can be FontStyle_Regular, FontStyle_Bold, FontStyle_Italic and FontStyle_BoldItalic.

    type FontStyle byte

    const (
        FontStyle_Regular    FontStyle = 0
        FontStyle_Bold       FontStyle = 1
        FontStyle_Italic     FontStyle = 2
        FontStyle_BoldItalic FontStyle = 3
    )

### func (FontStyle) String ¶

    func (fs FontStyle) String() string

String returns a string representation of FontStyle for logging purposes.

## type ImgPart ¶

    type ImgPart byte

    const (
        ImgPart_whole ImgPart = 0
        ImgPart_t     ImgPart = 1
        ImgPart_b     ImgPart = 2
        ImgPart_l     ImgPart = 3
        ImgPart_r     ImgPart = 4
        ImgPart_lt    ImgPart = 5
        ImgPart_rt    ImgPart = 6
        ImgPart_lb    ImgPart = 7
        ImgPart_rb    ImgPart = 8
    )

## type PageSize ¶

EnumeratedValues for the DefaultPageSize.

    type PageSize int

    const (
        PageSizeA4 PageSize = iota
        PageSizeA3
        PageSizeA5
        PageSizeLetter
        PageSizeLegal

        // constant for conversion ST_PercentageDecimal and ST_PositiveFixedPercentageDecimal values
        Percent100 = 100000.0

        MaxPageHeight = 11906 // A rounded value from A3 page width in PPMM multiplied by 10.
    )

## type Rectangle ¶

Rectangle represents a rectangle with top, bottom, left and right float64 coordinates.

    type Rectangle struct {
        Top    float64
        Bottom float64
        Left   float64
        Right  float64
    }

### func (*Rectangle) Translate ¶

    func (r *Rectangle) Translate(x, y float64)

Translate moves a rectangle by provided x and y, which can be positive or negative float64.