modern-pdf-lib / insertPage
Function: insertPage()
insertPage(
doc,index,size?):PdfPage
Defined in: src/core/pageManipulation.ts:146
Insert a new blank page into the document at the specified position.
All existing pages at index and beyond are shifted to make room.
Parameters
doc
The PdfDocument to modify.
index
number
Zero-based position at which to insert the page. Must be in the range [0, pageCount].
size?
Optional page size. Defaults to A4.
Returns
The newly created PdfPage.
Example
ts
import { createPdf, insertPage, PageSizes } from 'modern-pdf-lib';
const doc = createPdf();
doc.addPage();
const newPage = insertPage(doc, 0, PageSizes.Letter); // insert at front