For the complete documentation index, see llms.txt. This page is also available as Markdown.

Removing pages from PDF using JavaScript

Pages can be removed from the PDF document using the removePages function.

// config.js
const { documentViewer } = instance.Core;

documentViewer.addEventListener('documentLoaded', async () => {
  const doc = documentViewer.getDocument();
  const page1 = 1, page2 = 2, page3 = 3;

  documentViewer.getPageCount(); // 3

  await doc.removePages([page2]);
  documentViewer.getPageCount(); // 2
})
// config.js
const { docViewer } = instance;

docViewer.on('documentLoaded', async () => {
  const doc = docViewer.getDocument();
  const page1 = 1, page2 = 2, page3 = 3;

  docViewer.getPageCount(); // 3

  await doc.removePages([page2]);
  docViewer.getPageCount(); // 2
})

Last updated

Was this helpful?