# usePageDuplicate

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



Returns a function that duplicates a page, with all its content, and resolves with the new page's id.

```ts
const duplicatePage = usePageDuplicate()

const newPageId = await duplicatePage(sourcePageId, insertAfterPageId?)
```

* Without `insertAfterPageId`, the duplicate is inserted right after the source page.
* The function is asynchronous because the source page's content may not be loaded yet.
* Both ids must identify existing pages, or the call throws `InvalidInputError`; with no document loaded, it throws `DocumentNotLoadedError`.

## Example [#example]

```tsx
import { usePageDuplicate, useScrollToPage } from '@sdk-pdf/react'

function useDuplicateAndShow() {
  const duplicatePage = usePageDuplicate()
  const scrollToPage = useScrollToPage()

  return async (pageId: string) => {
    const newPageId = await duplicatePage(pageId)
    scrollToPage(newPageId, { behavior: 'smooth' })
  }
}
```

