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")Create an empty display list. The mediabox rectangle should be the bounds of the page.
Rect) – The size of the
page.var displayList = new mupdf.DisplayList([0, 0, 595, 842])Play back this display lists sequence of device calls to the given device.
displayList.run(device, mupdf.Matrix.identity)Return a bounding rectangle that encompasses all the contents of the display list.
var bounds = displayList.getBounds()Render a display list to a Pixmap.
Matrix) – Transformation
matrix.ColorSpace) – The
desired colorspace of the returned pixmap.boolean) – Whether the returned
pixmap has transparency or not. If the pixmap handles transparency, it
starts out transparent (otherwise it is filled white), before the
contents of the display list are rendered onto the pixmap.var pixmap = displayList.toPixmap(mupdf.Matrix.identity, mupdf.ColorSpace.DeviceRGB, false)Extract the text on the page into a StructuredText object.
string) – See Structured Text Options.var sText = displayList.toStructuredText("preserve-whitespace")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.
string) – The text to search
for.string) – See Search Options.var results = displayList.search("my search phrase")only mutool run
Decodes a barcode detected in the display list, and returns an object with properties for barcode type and contents.
Rect) – Only detect barcode
within subarea. Defaults to the entire area returned by DisplayList.prototype.getBounds().number) – Degrees of rotation
to rotate display list before detecting barcode. Defaults to 0.var barcodeInfo = displayList.decodeBarcode([0, 0, 100, 100 ], 0)