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.

CONSTRUCTOR METHODS

DisplayList(mediabox: Rect)#

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

Parameters:

mediaboxRect.

Returns:

DisplayList.

EXAMPLE

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

INSTANCE METHODS

run(device: Device, matrix: Matrix)#

Play back the recorded device calls onto the device.

Parameters:

EXAMPLE

displayList.run(device, mupdfjs.Matrix.identity);
getBounds()#

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

Returns:

Rect.

EXAMPLE

var bounds = displayList.getBounds();
toPixmap(matrix: Matrix, colorspace: ColorSpace, alpha=false)#

Render display list to a Pixmap.

Parameters:
  • matrixMatrix.

  • colorspaceColorSpace.

  • alphaboolean. If alpha is true, a transparent background, otherwise white.

Returns:

Pixmap.

EXAMPLE

var pixmap = displayList.toPixmap(mupdfjs.Matrix.identity, mupdfjs.ColorSpace.DeviceRGB, false);
toStructuredText(options: string = '')#

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

Parameters:

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 Quads corresponding to all characters in the search hit.

Parameters:
  • needlestring.

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

Returns:

Quad[][].

EXAMPLE

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

Code samples

Code samples are in TypeScript and assume that the following requirements are defined in your TypeScript file header as follows:

import * as fs from "fs"
import * as mupdfjs from "mupdf/mupdfjs"