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.
You cannot create instances of this class with the new operator!
Page instances are returned by Document.prototype.loadPage().
The page box types:
Returns a rectangle describing the page dimensions.
var rect = page.getBounds()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)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)This is the same as the Page.prototype.run() method
above but it only runs the page annotations.
page.runPageAnnots(dev, mupdf.Matrix.identity)This is the same as the Page.prototype.run() method
above but it only runs the page widgets.
page.runPageWidgets(dev, mupdf.Matrix.identity)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.
Matrix) – The transformation
matrix.ColorSpace) – The
desired colorspace of the returned pixmap.boolean) – Whether the
resulting pixmap should have an alpha component. Defaults to
true.boolean) – Whether to
render annotations and widgets. Defaults to true.var pixmap = page.toPixmap(mupdf.Matrix.identity, mupdf.ColorSpace.DeviceRGB, true, true)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.
boolean) – Whether to
render annotations and widgets. Defaults to true.var displayList = page.toDisplayList(true)Extract the text on the page into a StructuredText object.
string) – See Structured Text Options.var sText = page.toStructuredText("preserve-whitespace")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.
string) – The text to search
for.string) – See Search Options.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)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.
Rect) – Rectangle specifying the
active area on the page the link should cover.string) – A URI string
describing the desired link destination.// 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.
Link) – The link to remove.page.deleteLink(link_obj)Returns the page number as a string using the numbering scheme of the document.
var label = page.getLabel()Returns true if the page is from a PDF document.
var isPDF = page.isPDF()only mutool run
Decodes a barcode detected on the page, and returns an object with properties for barcode type and contents.
Rect) – Only detect barcode
within subarea. Defaults to the entire page.number) – Degrees of rotation
to rotate page before detecting barcode. Defaults to 0.var info = page.decodeBarcode(page.getBounds(), 0)