Reordering PDF pages using JavaScript

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

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

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales