A PDFPage inherits Page, so its interface is also available for PDFPage objects.
You cannot create instances of this class with the new operator!
Instances of this class are returned by loadPage
called on a PDFDocument.
only mupdf.js
for no image redactions
to redact entire images
for redacting just the covered pixels
only redact visible images
for no line art redactions
redacts line art if covered
redacts line art if touched
to redact text
for no text redaction
Get the underlying PDFObject for a PDFPage.
var obj = page.getObject()Returns an array of all annotations on the page.
var annots = page.getAnnotations()Returns an array of all widgets on the page.
var widgets = page.getWidgets()Sets the type of box required for the page.
page.setPageBox("ArtBox", [10, 10, 585, 832])Create a new blank annotation of a given annotation type.
string) – The annotation
type to create.var annot = page.createAnnotation("Text")Delete a PDFAnnotation from the page.
PDFAnnotation)var annots = getAnnotations()
page.delete(annots[0])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()Render the page into a Pixmap with the PDF “usage” and page box.
Matrix) – The transformation
matrix.ColorSpace) – The
desired colorspace.boolean) – Whether or not the
returned pixmap will use alpha.boolean) – Whether
annotations and widgets should be rendered. Defaults to true.string) – If the output is
destined for viewing or printing. Defaults to “View”.string) – Default is
“CropBox”.var pixmap = page.toPixmap(
mupdf.Matrix.identity,
mupdf.ColorSpace.DeviceRGB,
true,
false,
"View",
"CropBox"
)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.
boolean) – Whether to use
black boxes at each redaction or not.number) – Default is PDFPage.REDACT_IMAGE_PIXELS.number) – Default is PDFPage.REDACT_LINE_ART_REMOVE_IF_COVERED.number) – Default is PDFPage.REDACT_TEXT_REMOVE.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)only mutool run
Run through the page contents stream and call methods on the supplied PDFProcessor.
PDFProcessor) –
User defined function callback object.pdfPage.process(processor)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()only mutool run
Create a new signature widget with the given name as field label.
string) – The desired field
label.var signatureWidget = pdfPage.createSignature("test")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()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)only mutool run
Clip the page to the given rectangle.
Rect) – The new desired
dimensions.pdfPage.clip([0, 0, 200, 300])