Guides
Rotate Pages
Rotate the display orientation of specified pages, supporting clockwise or counterclockwise rotation in 90-degree increments.
The following example demonstrates how to rotate pages:
tsx
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({})}
/>
// Get the current rotation angle of the page
const pageIndex = 0;
const page = await pdfReaderRef.current?._pdfDocument.pageAtIndex(pageIndex);
const rotation = await page?.getRotation();
// Set a new rotation angle (rotate 90 degrees clockwise from the current angle)
const result = await page?.setRotation(rotation! + 90);
if (result) {
// Refresh the page to apply the rotation effect
await pdfReaderRef.current?.reloadPages();
}