The Manage Pages panel, headless: the panel's actions do what these members do. Every member that changes the pages (insert, delete, move, rotate, setRotation, duplicate, import) needs the license's edit-pages feature, as the panel does, and extract needs export; without them they refuse with FEATURE_NOT_LICENSED, before the document's own permissions and signature checks. Each change is made to the open document at once, and a viewer showing it records an undo step; the panel's changes become one undo step on Apply changes, and Cancel undoes them.
On a certified document, every write the certification forbids rejects with INVALID_STATE unless the call passes invalidateSignatures: true — the certification is then broken for good and nothing is asked again (see Document features). On a progressive document every write, and extract, rejects with INVALID_STATE until doc.whenFullyLoaded() resolves.
Page boxes are Rects in page space: PDF points, the origin at the page's bottom-left corner, y growing upwards, unturned by the page's rotation. Page sizes are in points too.
namespacedoc.pages
Usage
TypeScript
await doc.pages.insert({ position: { after: 0 }, size: { width: 612, height: 792 } }); // US Letter, page 2await doc.pages.rotate(0, 90);
await doc.pages.setRotation(1, 0); // upright, whatever it wasawait doc.pages.move(3, 0);
const coverAndTerms = await doc.pages.extract([0, 4]);
// .slice() gives an ArrayBuffer-backed copy, which TypeScript 5.7+ requires of a request body.awaitfetch('/upload', { method: 'PUT', body: coverAndTerms.slice() });
The page's MediaBox / CropBox / BleedBox / TrimBox / ArtBox, read without loading it.
Parameter
Type
Description
pageIndex
number
Zero-based page index.
ReturnsPromise<PageBoxes>{ mediaBox, cropBox, trimBox, bleedBox, artBox }, every box a Rect in page space, resolved as a reader resolves it: the MediaBox is the full sheet (US Letter when the file has none); the CropBox is what renders (the MediaBox when the file declares none); the TrimBox, BleedBox and ArtBox fall back to the CropBox.
Inserts a blank page. Needs the edit-pages feature.
Parameter
Type
Description
options?
InsertPageOptions
position is { after } or { before } (zero-based); omit to append. size is { width, height } in points, default A4. invalidateSignatures breaks a certification that forbids the change.
ReturnsPromise<number> The index the new page landed at.
FEATURE_NOT_LICENSED — the license lacks edit-pages.
INVALID_ARGUMENT — the position is not a whole number (one past the ends is clamped).
PAGE_ERROR — the page tree is nested too deeply, or the page could not be created.
DOCUMENT_CLOSED — the document has been closed.
INVALID_STATE — a certified document whose certification forbids it, unless options.invalidateSignatures; or a progressive document still downloading.
TypeScript
await doc.pages.insert({ position: { after: 0 } }); // second page, A4await doc.pages.insert({ size: { width: 612, height: 792 } }); // US Letter, at the end
Copies a page and inserts the copy right after it. The copy's form fields are its original's: filling one fills both (left outside the form: a signature field's copy, and every copy in an encrypted document or one with a signed field). Needs the edit-pages feature.
Parameter
Type
Description
pageIndex
number
Zero-based page index.
options?
SignedDocumentOptions
{ invalidateSignatures? }.
ReturnsPromise<number> The copy's index.
INVALID_ARGUMENT — a page index out of range.
PAGE_ERROR — the page tree is nested too deeply, or the page could not be copied.
FEATURE_NOT_LICENSED — the license lacks edit-pages.
DOCUMENT_CLOSED — the document has been closed.
INVALID_STATE — a certified document whose certification forbids it, unless options.invalidateSignatures; or a progressive document still downloading.
Builds a new PDF from those pages, in that order. The source is untouched. A page with form fields comes out flattened, as it prints: its fields do not go to another document. The new document gets a creation date. Needs the export feature.
Parameter
Type
Description
indices
number[]
Zero-based page indices, in the order they should appear.
ReturnsPromise<Uint8Array> The new PDF's bytes.
INVALID_ARGUMENT — no pages, or a page the document lacks.
PAGE_ERROR — the pages could not be copied.
EXPORT_FAILED — a page with form fields could not be flattened, or the new document could not be watermarked or serialized.
FEATURE_NOT_LICENSED — the license lacks export.
DOCUMENT_CLOSED — the document has been closed.
INVALID_STATE — a progressive document still downloading.
Inserts every page of another PDF. A page with form fields comes in flattened, as it prints: its fields do not join this document's form. Needs the edit-pages feature.
Importing is a load for the license, once the imported file has opened: under a stopped license (paused, revoked, expired, a copied or forged key) it is refused with LICENSE_REQUIRED, as opening a document is.
Parameter
Type
Description
bytes
Uint8Array
The source PDF.
options?
ImportPagesOptions
position ({ after } or { before }; appended when omitted), password (the source's, if it is encrypted) and invalidateSignatures.
ReturnsPromise<number> How many pages came in.
FEATURE_NOT_LICENSED — the license lacks edit-pages.
LICENSE_REQUIRED — the license is stopped.
FORMAT_ERROR — the imported bytes are not a PDF, or a corrupt one.
PASSWORD_ERROR — the imported file needs a password, or options.password is wrong.
SECURITY_ERROR — the imported file is encrypted with a security handler the SDK cannot open.
INVALID_ARGUMENT — the position is not a whole number (one past the ends is clamped).
PAGE_ERROR — a page could not be copied in, its form fields could not be flattened, or the page tree is nested too deeply.
DOCUMENT_CLOSED — the document has been closed.
INVALID_STATE — a certified document whose certification forbids it, unless options.invalidateSignatures; or a progressive document still downloading.
TypeScript
const other = newUint8Array(await (awaitfetch('/terms.pdf')).arrayBuffer());
const added = await doc.pages.import(other); // appended at the end