usePageDelete
Returns a function that deletes pages by id, one or several at once as a single undo step.
const deletePages = usePageDelete()
deletePages(pageId)
deletePages([pageId1, pageId2])- Every id must identify an existing page, or the call throws
InvalidInputErrorand deletes nothing; with no document loaded, it throwsDocumentNotLoadedError. - A deleted page is not necessarily gone forever: an undo can restore it, together with its blocks.
Example
import { usePageCount, usePageDelete } from '@sdk-pdf/react'
function DeleteCurrentPageButton({ currentPageId }: { currentPageId: string }) {
const deletePages = usePageDelete()
const pageCount = usePageCount()
return (
// Keep at least one page in the document.
<button disabled={pageCount <= 1} onClick={() => deletePages(currentPageId)}>
Delete page
</button>
)
}