text

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder builds Text

func (*Builder) Add

func (b *Builder) Add(t Text)

Add adds the Text content to the buffer, merging text parts if possible.

func (*Builder) Render

func (b *Builder) Render(x, y, w, h float64, font, content string)

Render adds the content with the given dimensions and font to the text builder. Text blocks are sectioned into lines and paragraphs based on their relative location on the page.

func (Builder) Text

func (b Builder) Text() Text

func (*Builder) WriteNewline

func (b *Builder) WriteNewline()

type Content

type Content []interface {
	String() string
	DebugString() string
}

func (Content) DebugString

func (c Content) DebugString() string

func (Content) Headings

func (c Content) Headings() []string

func (Content) Sections

func (c Content) Sections(names []string) Content

func (Content) String

func (c Content) String() string

type Part

type Part struct {
	Size float64
	// bitmask of styles, currently just 1 for bold.
	Weight  int
	Content string
}

Part is a part of Text with the same size and font weight.

type Section

type Section struct {
	Title   Text
	Content Content
}

func (Section) DebugString

func (s Section) DebugString() string

func (Section) String

func (s Section) String() string

type Text

type Text []Part

Text represents minimally structured text extracted from a PDF.

func (Text) DebugString

func (t Text) DebugString() string

DebugString renders the Text as a string with annotation at each change of text size.

func (Text) Sectioned

func (t Text) Sectioned() Content

Sectioned attempts to process the text into a structured hierarchy of sections. This does not work via metadata encoded in the PDF as that is found to be unreliable, but via text size and positioning.

func (Text) Size

func (t Text) Size() float64

Size is calculated to be the maximum size of any segment in the string.

func (Text) Split

func (s Text) Split(sep string) []Text

Split splits the Text by the separator.

func (Text) String

func (t Text) String() string

String renders the Text without sizing information.

func (Text) TrimSpace

func (t Text) TrimSpace() Text

TrimSpace trims whitespace from both ends of the Text.

Jump to

Keyboard shortcuts

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