# usePageCreate

Source: https://sdk.pdf.net/docs/v1/reference/usePageCreate



Returns a function that creates a blank page and returns the new page's id.

```ts
const createPage = usePageCreate()

const pageId = createPage(width, height, insertAfterPageId?)
```

* `width` and `height` are 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 `DocumentNotLoadedError` with no document, and `InvalidInputError` when `insertAfterPageId` doesn't identify an existing page.

## Example [#example]

```tsx
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>
  )
}
```

