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

Removing pages from PDF using JavaScript

Requirements

These packages are required to use these features in production. Trial keys have unlimited access to all features

Package: Page ManipulationLive demo

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

WebViewer(...)
  .then(instance => {
    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
    })
  });
WebViewer(...)
  .then(instance => {
    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?