Help us shape the future of Go! Take the 2026 Go Developer Survey

page

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coords

type Coords struct {
	Points []image.Point `xml:"points,attr"`
}

Coords are rectangles of points.

func (Coords) BoundingBox

func (c Coords) BoundingBox() image.Rectangle

BoundingBox returns the bounding box of the polygon.

func (*Coords) MarshalXML added in v0.7.2

func (c *Coords) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshals a Coords instance. <Coords points="x0,y0 x1,y1 x2,y2,..."/>

func (*Coords) UnmarshalXML

func (c *Coords) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals a Coords instance.

type Glyph

type Glyph struct {
	TextRegionBase
}

Glyph is a single character in a word.

type Metadata

type Metadata map[string]string

Metadata defines

func (Metadata) MarshalXML added in v0.7.2

func (m Metadata) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshals the Metadata of a PcGts structure to xml. <Metadata> <Creator>OCR-D</Creator> ... </Metadata>

func (Metadata) UnmarshalXML

func (m Metadata) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the Metadata of a PcGts structure from xml.

type OrderedGroup

type OrderedGroup struct {
	ID               string `xml:"id,attr"`
	Caption          string `xml:"caption,attr"`
	RegionRefIndexed []RegionRefIndexed
}

OrderedGroup is a collection of regions.

type Page

type Page struct {
	ImageFilename string `xml:"imageFilename,attr"`
	ImageHeight   int    `xml:"imageHeight,attr"`
	ImageWidth    int    `xml:"imageWidth,attr"`
	Type          string `xml:"type,attr"`
	PrintSpace    PrintSpace
	ReadingOrder  ReadingOrder
	TextRegion    []TextRegion
}

Page is a page in a PcGts structure.

type PcGts

type PcGts struct {
	Attributes []xml.Attr
	Metadata   Metadata `xml:"Metadata"`
	Page       Page     `xml:"Page"`
}

PcGts is the top level node of page XML files.

func Open

func Open(path string) (*PcGts, error)

OpenPcGts reads a new page xml file from the given file path.

func Read

func Read(r io.Reader) (*PcGts, error)

ReadPcGts reads a new page xml file from an input stream.

func (*PcGts) UnmarshalXML

func (p *PcGts) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the top-level PcGts node of page xml files.

type PrintSpace

type PrintSpace struct {
	Coords Coords
}

PrintSpace defines the print space of a page.

type ReadingOrder

type ReadingOrder struct {
	OrderedGroup []OrderedGroup
}

ReadingOrder is a collection of ordered groups.

type RegionRefIndexed

type RegionRefIndexed struct {
	Index     int    `xml:"index,attr"`
	RegionRef string `xml:"regionRef,attr"`
}

RegionRefIndexed is a index region.

type TextEquiv

type TextEquiv struct {
	PlainText []string
	Unicode   []string
}

TextEquiv defines the text string of text regions.

type TextLine

type TextLine struct {
	TextRegionBase
	BaseLine Coords `xml:"Baseline"`
	Word     []Word
}

TextLine is a line of text in a text region.

type TextRegion

type TextRegion struct {
	TextRegionBase
	Type     string `xml:"type,attr"`
	TextLine []TextLine
}

TextRegion is a region of text (paragraph, block, ...)

type TextRegionBase

type TextRegionBase struct {
	ID        string `xml:"id,attr"`
	Custom    string `xml:"custom,attr"`
	Coords    Coords
	TextStyle TextStyle
	TextEquiv TextEquiv
}

TextRegionBase defines the base data structure for all text regions (TextRegion, Line, Word, Glyph) in a page XML document.

type TextStyle

type TextStyle struct {
	FontFamaily  string  `xml:"fontFamily,attr,omitempty"`
	Serif        bool    `xml:"serif,attr,omitempty"`
	Monospace    bool    `xml:"monospace,attr,omitempty"`
	FontSize     float32 `xml:"fontSize,attr,omitempty"`
	Kerning      int     `xml:"kerning,attr,omitempty"`
	TextColor    string  `xml:"textColour,attr,omitempty"`
	TextColorRGB int     `xml:"textColourRgb,attr,omitempty"`
}

TextStyle specifies font information of any text region.

type Word

type Word struct {
	TextRegionBase
	Glyph []Glyph
}

Word is a token in a line.

Jump to

Keyboard shortcuts

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