useSetPageRotation
Returns a function that sets the rotation of pages, one or several at once as a single undo step.
const setPageRotation = useSetPageRotation()
setPageRotation(pageIdOrPageIds, rotation)rotationis in degrees, clockwise, and must land on a quarter turn:0,90,180, or270. Values outside0..360are normalized first, so-90and450are valid; anything not on a quarter turn throwsInvalidInputError.- The rotation is absolute, not added to the current one. To rotate relative to the current angle, read the page's
rotationfrom usePages first. - Every id must identify an existing page, or the call throws
InvalidInputError; with no document loaded, it throwsDocumentNotLoadedError.
Example
import { usePages, useSetPageRotation } from '@sdk-pdf/react'
function useRotatePageClockwise() {
const pages = usePages()
const setPageRotation = useSetPageRotation()
return (pageId: string) => {
const page = pages.find((page) => page.id === pageId)
if (page) setPageRotation(pageId, page.rotation + 90)
}
}