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:
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:
  • deviceDevice.

  • 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.

  • colorspaceColorSpace.

  • alphaBoolean. 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:
  • optionsString.

Returns:

StructuredText.

EXAMPLE

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

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:
  • needleString.

  • max_hitsInteger Use to limit number of results, defaults to 500.

Returns:

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

EXAMPLE

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