Skip to content

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Insert Pages ​

Insert a blank page or pages from other PDFs into the target document.

Insert Blank Pages ​

This example shows how to insert a blank page:

javascript
// Insert after the first page.
const insertBeforeThisPage = 2;
const width = 612;
const height = 792;

await documentViewer.getDocument().insertBlankPages([insertBeforeThisPage], width, height);

Insert Pages from other PDFs ​

This example shows how to insert pages from other PDFs:

javascript
const file = {...}; // File Object.
const insertBeforeThisPage = 2; // Insert after the first page.
const pagesToInsert = [1, '3-5']; // Insert the range of PDF pages.

const sourceDocument = await instance.Core.createDocument(file);
await documentViewer.getDocument().insertPages(sourceDocument, pagesToInsert, insertBeforeThisPage);