paper

package
v5.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2022 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllOrientation holds all possible values.
	AllOrientation = []Orientation{
		Portrait,
		Landscape,
	}
)
View Source
var (
	// AllSize holds all possible values.
	AllSize = []Size{
		Letter,
		Legal,
		Tabloid,
		A0,
		A1,
		A2,
		A3,
		A4,
		A5,
		A6,
	}
)
View Source
var (
	// AllUnits holds all possible values.
	AllUnits = []Units{
		Inch,
		Centimeter,
		Millimeter,
	}
)

Functions

This section is empty.

Types

type Length

type Length struct {
	Length float64
	Units  Units
}

Length contains a real-world length value with an attached units.

func LengthFromString

func LengthFromString(text string) Length

LengthFromString creates a new Length. May have any of the known units.Units suffixes or no notation at all, in which case units.Inch is used.

func ParseLengthFromString

func ParseLengthFromString(text string) (length Length, err error)

ParseLengthFromString parses a Length from the text. May have any of the known units.Units suffixes or no notation at all, in which case units.Inch is used.

func (*Length) EnsureValidity

func (l *Length) EnsureValidity()

EnsureValidity checks the current settings for validity and if they aren't valid, makes them so.

func (Length) MarshalJSON

func (l Length) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Length) Pixels

func (l Length) Pixels() float32

Pixels returns the number of 72-pixels-per-inch pixels this represents.

func (Length) String

func (l Length) String() string

func (*Length) UnmarshalJSON

func (l *Length) UnmarshalJSON(in []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Orientation

type Orientation byte

Orientation holds the orientation of the page.

const (
	Portrait Orientation = iota
	Landscape
	LastOrientation = Landscape
)

Possible values.

func ExtractOrientation

func ExtractOrientation(str string) Orientation

ExtractOrientation extracts the value from a string.

func (Orientation) Dimensions

func (enum Orientation) Dimensions(width, height Length) (adjustedWidth, adjustedHeight Length)

Dimensions returns the paper dimensions after orienting the paper.

func (Orientation) EnsureValid

func (enum Orientation) EnsureValid() Orientation

EnsureValid ensures this is of a known value.

func (Orientation) Key

func (enum Orientation) Key() string

Key returns the key used in serialization.

func (Orientation) MarshalText

func (enum Orientation) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (Orientation) String

func (enum Orientation) String() string

String implements fmt.Stringer.

func (*Orientation) UnmarshalText

func (enum *Orientation) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Size

type Size byte

Size holds a standard paper dimension.

const (
	Letter Size = iota
	Legal
	Tabloid
	A0
	A1
	A2
	A3
	A4
	A5
	A6
	LastSize = A6
)

Possible values.

func ExtractSize

func ExtractSize(str string) Size

ExtractSize extracts the value from a string.

func (Size) Dimensions

func (enum Size) Dimensions() (width, height Length)

Dimensions returns the paper dimensions.

func (Size) EnsureValid

func (enum Size) EnsureValid() Size

EnsureValid ensures this is of a known value.

func (Size) Key

func (enum Size) Key() string

Key returns the key used in serialization.

func (Size) MarshalText

func (enum Size) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (Size) String

func (enum Size) String() string

String implements fmt.Stringer.

func (*Size) UnmarshalText

func (enum *Size) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Units

type Units byte

Units holds the real-world length unit type.

const (
	Inch Units = iota
	Centimeter
	Millimeter
	LastUnits = Millimeter
)

Possible values.

func ExtractUnits

func ExtractUnits(str string) Units

ExtractUnits extracts the value from a string.

func (Units) EnsureValid

func (enum Units) EnsureValid() Units

EnsureValid ensures this is of a known value.

func (Units) Key

func (enum Units) Key() string

Key returns the key used in serialization.

func (Units) MarshalText

func (enum Units) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (Units) String

func (enum Units) String() string

String implements fmt.Stringer.

func (Units) ToPixels

func (enum Units) ToPixels(length float64) float32

ToPixels converts the given length in this Units to the number of 72-pixels-per-inch pixels it represents.

func (*Units) UnmarshalText

func (enum *Units) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL