usePageCreate
Returns a function that creates a blank page and returns the new page's id.
const createPage = usePageCreate()
const pageId = createPage(width, height, insertAfterPageId?)widthandheightare in user-space units (one unit is 1/72 of an inch; A4 is roughly 595 × 842).- Without
insertAfterPageId, the page is appended at the end of the document. - Throws
DocumentNotLoadedErrorwith no document, andInvalidInputErrorwheninsertAfterPageIddoesn't identify an existing page.
Example
import { usePageCreate, useScrollToPage } from '@sdk-pdf/react'
function AddPageButton() {
const createPage = usePageCreate()
const scrollToPage = useScrollToPage()
return (
<button
onClick={() => {
const pageId = createPage(595, 842)
scrollToPage(pageId, { behavior: 'smooth' })
}}
>
Add page
</button>
)
}