...master 2026-11-12 (1037e2069+unstaged)

DisplayList

A display list is a sequence of device calls that can be replayed multiple times. This is useful e.g. when you need to render a page at multiple resolutions, or when you want to both render a page and later search for text in it. Using a display list to do this, improves performance because it avoids repeatedly reinterpreting the document from file

To populate a display list use the DisplayListDevice.

var list = new mupdf.DisplayList([0, 0, 595, 842])
var listDevice = new mupdf.DisplayListDevice(list)
page.run(listDevice, mupdf.Matrix.identity)

var pixmap = new mupdf.Pixmap(mupdf.ColorSpace.DeviceRGB, [0, 0, 595, 842], false)
var drawDevice = new mupdf.DrawDevice(mupdf.Matrix.identity, pixmap)
list.run(drawDevice, mupdf.Matrix.identity)

var searchHits = list.search("hello world")

Constructors

class DisplayList(mediabox)

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

var displayList = new mupdf.DisplayList([0, 0, 595, 842])

Instance methods

DisplayList.prototype.run(device, matrix)

Play back this display lists sequence of device calls to the given device.

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

DisplayList.prototype.getBounds()

Return a bounding rectangle that encompasses all the contents of the display list.

var bounds = displayList.getBounds()

DisplayList.prototype.toPixmap(matrix, colorspace, alpha)

Render a display list to a Pixmap.

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

DisplayList.prototype.toStructuredText(options)

Extract the text on the page into a StructuredText object.

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

DisplayList.prototype.search(needle, options)

Search the display list text for all instances of the text value needle, and return an array of search hits. Each search hit is an array of Quad, each corresponding to a single character in the search hit.

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

DisplayList.prototype.decodeBarcode(subarea, rotate)

only mutool run

Decodes a barcode detected in the display list, and returns an object with properties for barcode type and contents.

var barcodeInfo = displayList.decodeBarcode([0, 0, 100, 100 ], 0)