HomeUniDoc
...

Package sizes

Overview ▾

Package sizes defines basic types that determines the size units i.e. lengths.

Index ▾

Constants
func MarshalPageSize(p PageSize) (string, error)
func MarshalUnit(unit Length) (string, error)
type Inch
    func UnmarshalInch(unit string) (Inch, error)
    func (i *Inch) HasChanged() bool
    func (i Inch) Inches() Inch
    func (i Inch) MarshalJSON() ([]byte, error)
    func (i Inch) Millimeters() Millimeter
    func (i Inch) Name() string
    func (i Inch) Points() Point
    func (i *Inch) Set(s string) error
    func (i Inch) String() string
    func (i Inch) Type() string
    func (i Inch) ValueString() string
    func (i Inch) ValueType() string
type Length
    func UnmarshalLength(length string) (Length, error)
type LengthFlag
    func (u *LengthFlag) Set(s string) error
    func (u *LengthFlag) String() string
    func (u *LengthFlag) Type() string
type Millimeter
    func (m Millimeter) Inches() Inch
    func (m Millimeter) MarshalJSON() ([]byte, error)
    func (m Millimeter) Millimeters() Millimeter
    func (m Millimeter) Points() Point
    func (m Millimeter) String() string
type Orientation
    func (o *Orientation) Set(s string) error
    func (o Orientation) String() string
    func (o Orientation) Type() string
type PageSize
    func PageSizeString(s string) (PageSize, error)
    func PageSizeValues() []PageSize
    func UnmarshalPageSize(pageSize string) (PageSize, error)
    func (p PageSize) Dimensions() (width, height Millimeter)
    func (i PageSize) IsAPageSize() bool
    func (i PageSize) MarshalJSON() ([]byte, error)
    func (i PageSize) MarshalText() ([]byte, error)
    func (p *PageSize) Set(s string) error
    func (i PageSize) String() string
    func (p PageSize) Type() string
    func (i *PageSize) UnmarshalJSON(data []byte) error
    func (i *PageSize) UnmarshalText(text []byte) error
type Point
    func (i *Point) HasChanged() bool
    func (i Point) Inches() Inch
    func (i Point) MarshalJSON() ([]byte, error)
    func (i Point) Millimeters() Millimeter
    func (i Point) Name() string
    func (i Point) Points() Point
    func (i *Point) Set(s string) error
    func (i Point) String() string
    func (i Point) Type() string
    func (i Point) ValueString() string
    func (i Point) ValueType() string

Package files

doc.go length.go orientation.go page-size.go pagesize_enumer.go

Constants

Orientation constant definitions.

const (
    Portrait  = Orientation(false)
    Landscape = Orientation(true)
)

func MarshalPageSize

func MarshalPageSize(p PageSize) (string, error)

MarshalPageSize marshals the page size into string.

func MarshalUnit

func MarshalUnit(unit Length) (string, error)

MarshalUnit marshals the unit into the string.

type Inch

Inch is a unit that

type Inch float64

func UnmarshalInch

func UnmarshalInch(unit string) (Inch, error)

UnmarshalInch unmarshalls provided string into unit.

func (*Inch) HasChanged

func (i *Inch) HasChanged() bool

HasChanged implements pflag.Value interface.

func (Inch) Inches

func (i Inch) Inches() Inch

Inches gets the inch value. Implements Length interface.

func (Inch) MarshalJSON

func (i Inch) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (Inch) Millimeters

func (i Inch) Millimeters() Millimeter

Millimeters converts the inches value to the millimeters.

func (Inch) Name

func (i Inch) Name() string

Name implements pflag.Value interface.

func (Inch) Points

func (i Inch) Points() Point

Points implements Length interface.

func (*Inch) Set

func (i *Inch) Set(s string) error

Set implements pflag.Value interface.

func (Inch) String

func (i Inch) String() string

String implements fmt.Stringer interface.

func (Inch) Type

func (i Inch) Type() string

Type implements pflag.Value interface.

func (Inch) ValueString

func (i Inch) ValueString() string

ValueString implements pflag.Value interface.

func (Inch) ValueType

func (i Inch) ValueType() string

ValueType implements pflag.Value interface.

type Length

Length is it the default dimension unit.

type Length interface {
    Millimeters() Millimeter
    Inches() Inch
    Points() Point
    String() string
}

func UnmarshalLength

func UnmarshalLength(length string) (Length, error)

UnmarshalLength unmarshalls string value into Length.

type LengthFlag

LengthFlag is a pflag wrapper for the Length value.

type LengthFlag struct {
    Length Length
}

func (*LengthFlag) Set

func (u *LengthFlag) Set(s string) error

Set sets the unit value. Implements pflag.Value interface.

func (*LengthFlag) String

func (u *LengthFlag) String() string

String gets the string value for given flag.

func (*LengthFlag) Type

func (u *LengthFlag) Type() string

Type implements pflag.Value interface.

type Millimeter

Millimeter is the dimension unit that defines a millimeter.

type Millimeter float64

func (Millimeter) Inches

func (m Millimeter) Inches() Inch

Inches gets the inches equivalent from provided millimeter value.

func (Millimeter) MarshalJSON

func (m Millimeter) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (Millimeter) Millimeters

func (m Millimeter) Millimeters() Millimeter

Millimeters gets the float64 millimeter value.

func (Millimeter) Points

func (m Millimeter) Points() Point

Points implements Length interface.

func (Millimeter) String

func (m Millimeter) String() string

String implements fmt.Stringer interface.

type Orientation

Orientation is the page orientation type wrapper.

type Orientation bool

func (*Orientation) Set

func (o *Orientation) Set(s string) error

Set implements flag.Value interface.

func (Orientation) String

func (o Orientation) String() string

String implements fmt.Stringer interface.

func (Orientation) Type

func (o Orientation) Type() string

Type implements pflag.Value interface.

type PageSize

PageSize is the enum used for defining the page size.

type PageSize int

Defines enums used by the ISO 216 page sizes.

const (
    Undefined PageSize = iota
    A0
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    B0
    B1
    B2
    B3
    B4
    B5
    B6
    B7
    B8
    B9
    B10
    Letter
)

func PageSizeString

func PageSizeString(s string) (PageSize, error)

PageSizeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func PageSizeValues

func PageSizeValues() []PageSize

PageSizeValues returns all values of the enum

func UnmarshalPageSize

func UnmarshalPageSize(pageSize string) (PageSize, error)

UnmarshalPageSize unmarshals the page size from the string.

func (PageSize) Dimensions

func (p PageSize) Dimensions() (width, height Millimeter)

Dimensions gets the dimensions of the given page size. If provided page size is not valid than the function returns 0 values.

func (PageSize) IsAPageSize

func (i PageSize) IsAPageSize() bool

IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise

func (PageSize) MarshalJSON

func (i PageSize) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for PageSize

func (PageSize) MarshalText

func (i PageSize) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for PageSize

func (*PageSize) Set

func (p *PageSize) Set(s string) error

Set implements pflag.Value interface.

func (PageSize) String

func (i PageSize) String() string

func (PageSize) Type

func (p PageSize) Type() string

Type implements pflag.Value interface.

func (*PageSize) UnmarshalJSON

func (i *PageSize) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for PageSize

func (*PageSize) UnmarshalText

func (i *PageSize) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize

type Point

Point is a unit of Length commonly used to measure the height of fonts.

type Point float64

func (*Point) HasChanged

func (i *Point) HasChanged() bool

HasChanged implements viper.FlagValue interface.

func (Point) Inches

func (i Point) Inches() Inch

Inches gets the inch value. Implements Length interface.

func (Point) MarshalJSON

func (i Point) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (Point) Millimeters

func (i Point) Millimeters() Millimeter

Millimeters converts the inches value to the millimeters.

func (Point) Name

func (i Point) Name() string

Name implements viper.FlagValue interface.

func (Point) Points

func (i Point) Points() Point

Points implements Length interface.

func (*Point) Set

func (i *Point) Set(s string) error

Set implements flag.Value interface.

func (Point) String

func (i Point) String() string

String implements fmt.Stringer interface.

func (Point) Type

func (i Point) Type() string

Type implements pflag.Value interface.

func (Point) ValueString

func (i Point) ValueString() string

ValueString implements viper.FlagValue interface.

func (Point) ValueType

func (i Point) ValueType() string

ValueType implements viper.FlagValue interface.