...master 2026-11-10 (4e7201cfc+unstaged)

Page

A Page object is a page that has been loaded from a Document.

Page objects that belong to a PDFDocument, also provide the interface described in PDFPage.

Constructors

class Page()

You cannot create instances of this class with the new operator!

Page instances are returned by Document.prototype.loadPage().

Constants

The page box types:

Page.MEDIA_BOX

Page.CROP_BOX

Page.BLEED_BOX

Page.TRIM_BOX

Page.ART_BOX

Instance methods

Page.prototype.getBounds(box)

Returns a rectangle describing the page dimensions.

var rect = page.getBounds()

Page.prototype.run(device, transform)

Calls device functions for all the contents on the page, using the specified transform.

The device can be one of the built-in devices (DrawDevice and DisplayListDevice) or a Javascript Device.

The matrix transforms coordinates from user space to device space.

page.run(dev, mupdf.Matrix.identity)

Page.prototype.runPageContents(device, transform)

This is the same as the Page.prototype.run() method above but it only runs the page itself and omits annotations and widgets.

page.runPageContents(dev, mupdf.Matrix.identity)

Page.prototype.runPageAnnots(device, transform)

This is the same as the Page.prototype.run() method above but it only runs the page annotations.

page.runPageAnnots(dev, mupdf.Matrix.identity)

Page.prototype.runPageWidgets(device, transform)

This is the same as the Page.prototype.run() method above but it only runs the page widgets.

page.runPageWidgets(dev, mupdf.Matrix.identity)

Page.prototype.toPixmap(matrix, colorspace, alpha, showExtras)

Render the page into a Pixmap using the specified transform matrix and colorspace. If alpha is true, the page will be drawn on a transparent background, otherwise white. If showExtras is true then the operation will include any page annotations and/or widgets.

var pixmap = page.toPixmap(mupdf.Matrix.identity, mupdf.ColorSpace.DeviceRGB, true, true)

Page.prototype.toDisplayList(showExtras)

Record the contents on the page into a DisplayList. If showExtras is true then the operation will include all annotations and/or widgets on the page.

var displayList = page.toDisplayList(true)

Page.prototype.toStructuredText(options)

Extract the text on the page into a StructuredText object.

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

Page.prototype.search(needle, options)

Search the page text for all instances of the needle value, and return an array of search hits.

Each search hit is an array of Quad, each corresponding to a character in the search hit.

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

Return an array of all the links on the page. If there are no links then an empty array is returned.

Each link is an object with a ‘bounds’ property, and either a ‘page’ or ‘uri’ property, depending on whether it’s an internal or external link.

var links = page.getLinks()
var link = links[0]
var linkDestination = doc.resolveLink(link)

Page.prototype.createLink(rect, uri)

Create a new link with the supplied metrics for the page, linking to the destination URI string.

To create links to other pages within the document see the Document.prototype.formatLinkURI method.

// create a link to an external URL
var link = page.createLink([0, 0, 100, 50], "https://example.com")

// create a link to another page in the document
var link = page.createLink([0, 100, 100, 150], "#page=1&view=FitV,0")

Delete the link from the page.

page.deleteLink(link_obj)

Page.prototype.getLabel()

Returns the page number as a string using the numbering scheme of the document.

var label = page.getLabel()

Page.prototype.isPDF()

Returns true if the page is from a PDF document.

var isPDF = page.isPDF()

Page.prototype.decodeBarcode(subarea, rotate)

only mutool run

Decodes a barcode detected on the page, and returns an object with properties for barcode type and contents.

var info = page.decodeBarcode(page.getBounds(), 0)