paper

package
v5.25.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Orientations = []Orientation{
	Portrait,
	Landscape,
}

Orientations holds all possible values.

View Source
var Sizes = []Size{
	Letter,
	Legal,
	Tabloid,
	A0,
	A1,
	A2,
	A3,
	A4,
	A5,
	A6,
}

Sizes holds all possible values.

View Source
var Units = []Unit{
	Inch,
	Centimeter,
	Millimeter,
}

Units holds all possible values.

Functions

This section is empty.

Types

type Length

type Length struct {
	Length float64
	Units  Unit
}

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 unit suffixes or no notation at all, in which case 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 unit suffixes or no notation at all, in which case inch is used.

func (Length) CSSString added in v5.16.2

func (l Length) CSSString() string

CSSString returns a CSS-compatible version of the value.

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
)

Possible values.

const LastOrientation Orientation = Landscape

LastOrientation is the last valid value.

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
)

Possible values.

const LastSize Size = A6

LastSize is the last valid value.

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 Unit added in v5.19.0

type Unit byte

Unit holds the real-world length unit type.

const (
	Inch Unit = iota
	Centimeter
	Millimeter
)

Possible values.

const LastUnit Unit = Millimeter

LastUnit is the last valid value.

func ExtractUnit added in v5.19.0

func ExtractUnit(str string) Unit

ExtractUnit extracts the value from a string.

func (Unit) EnsureValid added in v5.19.0

func (enum Unit) EnsureValid() Unit

EnsureValid ensures this is of a known value.

func (Unit) Key added in v5.19.0

func (enum Unit) Key() string

Key returns the key used in serialization.

func (Unit) MarshalText added in v5.19.0

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

MarshalText implements the encoding.TextMarshaler interface.

func (Unit) String added in v5.19.0

func (enum Unit) String() string

String implements fmt.Stringer.

func (Unit) ToPixels added in v5.19.0

func (enum Unit) ToPixels(length float64) float32

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

func (*Unit) UnmarshalText added in v5.19.0

func (enum *Unit) 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