PagesApi.insert()
Inserts a blank page. Needs the
edit-pages feature.methodStructuresince 1.0.0
Signature
insert(options?: InsertPageOptions): Promise<number>
Parameters
| 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. |
Returns
Promise<number> The index the new page landed at.
Throws
FEATURE_NOT_LICENSED— the license lacksedit-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, unlessoptions.invalidateSignatures; or a progressive document still downloading.
Example
TypeScript
await doc.pages.insert({ position: { after: 0 } }); // second page, A4 await doc.pages.insert({ size: { width: 612, height: 792 } }); // US Letter, at the end