Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# `Story`

mutool only

new Story(contents, userCSS, em, archive)

  Constructor method.

  Create a new story with the given `contents`, formatted according to the provided `userCSS` and `em` size, and an `archive` to lookup images, etc.

  Arguments:

    - contents – `String` HTML source code. If omitted, a basic minimum is generated.

    - userCSS – `String` CSS source code. If provided, must contain valid CSS specifications.

    - em – `Float` The default text font size.

    - archive – An `Archive` from which to load resources for rendering. Currently supported resource types are images and text fonts. If omitted, the `Story` will not try to look up any such data and may thus produce incomplete output.

  EXAMPLE

      var story = new mupdf.Story(<contents>, <css>, <em>, <archive>);

Instance methods

document()

  Return an `XML` for an unplaced story. This allows adding content before placing the `Story`.

  Returns:

    XML.

  EXAMPLE

      var xml = story.document();

place(rect)

  Place (or continue placing) a `Story` into the supplied rectangle, returning a Placement Result Object. Call `draw()` to draw the placed content before calling `place()` again to continue placing remaining content.

  Arguments:

    - rect – `[ulx,uly,lrx,lry]` Rectangle.

  Returns:

    Placement Result Object.

  EXAMPLE

      var result = story.place([0,0,100,100]);

draw(device, transform)

  Draw the placed `Story` to the given `device` with the given `transform`.

  Arguments:

    - device – Device.

    - transform – `[a,b,c,d,e,f]`. The transform matrix.

  EXAMPLE

      story.draw(device, mupdf.Matrix.identity);