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

PDFPage

A PDFPage inherits Page, so its interface is also available for PDFPage objects.

Constructors

class PDFPage()

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

Instances of this class are returned by loadPage called on a PDFDocument.

Static properties

only mupdf.js

PDFPage.REDACT_IMAGE_NONE

for no image redactions

PDFPage.REDACT_IMAGE_REMOVE

to redact entire images

PDFPage.REDACT_IMAGE_PIXELS

for redacting just the covered pixels

PDFPage.REDACT_IMAGE_UNLESS_INVISIBLE

only redact visible images

PDFPage.REDACT_LINE_ART_NONE

for no line art redactions

PDFPage.REDACT_LINE_ART_REMOVE_IF_COVERED

redacts line art if covered

PDFPage.REDACT_LINE_ART_REMOVE_IF_TOUCHED

redacts line art if touched

PDFPage.REDACT_TEXT_REMOVE

to redact text

PDFPage.REDACT_TEXT_NONE

for no text redaction

Instance methods

PDFPage.prototype.getObject()

Get the underlying PDFObject for a PDFPage.

var obj = page.getObject()

PDFPage.prototype.getAnnotations()

Returns an array of all annotations on the page.

var annots = page.getAnnotations()

PDFPage.prototype.getWidgets()

Returns an array of all widgets on the page.

var widgets = page.getWidgets()

PDFPage.prototype.setPageBox(box, rect)

Sets the type of box required for the page.

page.setPageBox("ArtBox", [10, 10, 585, 832])

PDFPage.prototype.createAnnotation(type)

Create a new blank annotation of a given annotation type.

var annot = page.createAnnotation("Text")

PDFPage.prototype.deleteAnnotation(annot)

Delete a PDFAnnotation from the page.

var annots = getAnnotations()
page.delete(annots[0])

PDFPage.prototype.update()

Loop through all annotations of the page and update them.

Returns true if re-rendering is needed because at least one annotation was changed (due to either events or Javascript actions or annotation editing).

// edit an annotation
var updated = page.update()

PDFPage.prototype.toPixmap(matrix, colorspace, alpha, showExtras, usage, box)

Render the page into a Pixmap with the PDF “usage” and page box.

var pixmap = page.toPixmap(
        mupdf.Matrix.identity,
        mupdf.ColorSpace.DeviceRGB,
        true,
        false,
        "View",
        "CropBox"
)

PDFPage.prototype.applyRedactions(blackBoxes, imageMethod, lineArtMethod, textMethod)

Applies all the Redaction annotations on the page.

Redactions are a special type of annotation used to permanently remove (or “redact”) content from a PDF.

Once redactions are added to a page you can apply them, which is an irreversible action, thus it is a two step process as follows:

var annot1 = page.createAnnotation("Redaction")
annot1.setRect([0, 0, 500, 100])
var annot2 = page.createAnnotation("Redaction")
annot2.setRect([0, 600, 500, 700])
page.applyRedactions(true, mupdf.PDFPage.REDACT_IMAGE_NONE)

PDFPage.prototype.process(processor)

only mutool run

Run through the page contents stream and call methods on the supplied PDFProcessor.

pdfPage.process(processor)

PDFPage.prototype.getTransform()

Return the transform from MuPDF page space (upper left page origin, y descending, 72 dpi) to PDF user space (arbitrary page origin, y ascending, UserUnit dpi).

var transform = pdfPage.getTransform()

PDFPage.prototype.createSignature(name)

only mutool run

Create a new signature widget with the given name as field label.

var signatureWidget = pdfPage.createSignature("test")

PDFPage.prototype.countAssociatedFiles()

only mutool run

Return the number of associated files associated with this page. Note that this is the number of files associated with this page, not necessarily the total number of files associated with elements throughout the entire document.

var count = pdfPage.countAssociatedFiles()

PDFPage.prototype.associatedFile(n)

only mutool run

Return the file specification object that represents the nth Associated File on this page.

n should be in the range 0 <= n < countAssociatedFiles().

Returns null if no associated file exists or index is out of range.

var obj = pdfPage.associatedFile(0)

PDFPage.prototype.clip(rect)

only mutool run

Clip the page to the given rectangle.

pdfPage.clip([0, 0, 200, 300])