Section:

Reordering PDF pages using JavaScript

Pages in the PDF document can be reordered using the movePages function.

1// config.js
2const { documentViewer } = instance.Core;
3
4documentViewer.addEventListener('documentLoaded', async () => {
5 const doc = documentViewer.getDocument();
6 const page1 = 1, page2 = 2, page3 = 3;
7
8 const pagesToMove = [page2, page3];
9 const insertBefore = page1;
10
11 await doc.movePages(pagesToMove, insertBefore);
12 // pages are now in the order of [page2, page3, page1];
13});

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales