PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Move a specified page within the document to a target position. The steps to move pages are as follows:
The following example demonstrates how to move pages:
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({})}
/>
// Move page 1 to the position of page 2 (page indices start from 0)
const fromIndex = 0;
const toIndex = 1;
const moveResult = await pdfReaderRef.current?._pdfDocument.movePage(
fromIndex,
toIndex
);
if (moveResult) {
// Refresh the page to apply the move effect
await pdfReaderRef.current?.reloadPages2();
}