Skip to content
Back to top

# StructuredTextWalker

A structured text walker is an object with (optional) callback methods used to iterate over the contents of a StructuredText.

## Constructors

class StructuredTextWalker()

  This is an interface, not a concrete class!

On beginLine the direction parameter is a vector (e.g. [0, 1]) and can you can calculate the rotation as an angle with some trigonometry on the vector.

beginTextBlock(bbox)

  Called before every text block in the StructuredText.

  Arguments:

    - bbox (`Rect`)

endTextBlock()

  Called after every text block.

beginLine(bbox, wmode, direction)

  Called before every line of text in a block.

  Arguments:

    - bbox (`Rect`)

    - wmode (`number`)

    - direction (`Point`)

endLine()

  Called after every line of text.

beginStruct(standard, raw, index)

  Called to indicate that a new structure element begins. May not be neatly nested within blocks or lines.

  Arguments:

    - standard (`string`)

    - raw (`string`)

    - index (`number`)

endStruct()

  Called after every structure element.

onChar(c, origin, font, size, quad, color, flags)

  Called for every character in a line of text.

  Arguments:

    - c (`string`)

    - origin (`Point`)

    - font (`Font`)

    - size (`number`)

    - quad (`Quad`)

    - color (`Color`)

    - flags (`number`)

onImageBlock(bbox, transform, image)

  Called for every image in a StructuredText if its options were set to preserve images.

  Arguments:

    - bbox (`Rect`)

    - transform (`Matrix`)

    - image (`Image`)

onVector(bbox, flags, rgb)

  Called for every vector in a StructuredText if its options were set to collect vectors.

  Arguments:

    - bbox (`Rect`)

    - flags (`Object`)

    - rgb (`Array of number`)

  The flags object is of the form `{ isStroked: boolean, isRectangle: boolean }`.