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

# `DisplayList`

A display list records all the device calls for playback later. If you want to run a page through several devices, or run it multiple times for any other reason, recording the page to a display list and replaying the display list may be a performance gain since then you can avoid reinterpreting the page each time. Be aware though, that a display list will keep all the graphics required in memory, so will increase the amount of memory required.

new DisplayList(mediabox)

  Constructor method.

  Create an empty display list. The mediabox rectangle should be the bounds of the page.

  Arguments:

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

  Returns:

    `DisplayList`.

  EXAMPLE

      var displayList = new mupdf.DisplayList([0,0,100,100]);

Instance methods

run(device, transform)

  Play back the recorded device calls onto the device.

  Arguments:

    - device – `Device`.

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

  EXAMPLE

      displayList.run(device, mupdf.Matrix.identity);

getBounds()

  Returns a rectangle containing the dimensions of the display list contents.

  Returns:

    `[ulx,uly,lrx,lry]` Rectangle.

  EXAMPLE

      var bounds = displayList.getBounds();

toPixmap(transform, colorspace, alpha)

  Render display list to a `Pixmap`.

  Arguments:

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

    - colorspace – `ColorSpace`.

    - alpha – `Boolean`. If alpha is true, a transparent background, otherwise white.

  Returns:

    `Pixmap`.

  EXAMPLE

      var pixmap = displayList.toPixmap(mupdf.Matrix.identity, mupdf.ColorSpace.DeviceRGB, false);

toStructuredText(options)

  Extract the text on the page into a `StructuredText` object. The options argument is a comma separated list of flags: “preserve-ligatures”, “preserve-whitespace”, “preserve-spans”, and “preserve-images”.

  Arguments:

    - options – `String`.

  Returns:

    `StructuredText`.

  EXAMPLE

      var sText = displayList.toStructuredText("preserve-whitespace");

search(needle, max_hits)

  Search the display list text for all instances of the `needle` value, and return an array of search hits. Each search hit is an array of rectangles corresponding to all characters in the search hit.

  Arguments:

    - needle – `String`.

    - max_hits – `Integer` Use to limit number of results, defaults to 500.

  Returns:

    `[ [ Quad, Quad, ... ], [ Quad, Quad, ...], ... ]`.

  EXAMPLE

      var results = displayList.search("my search phrase");