import { useState } from 'react'; import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin, useStage, useStageState } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { localEngine } from '@embedpdf/engine'; import './navigation.css'; const engine = localEngine(); const plugins = [stagePlugin(), renderPlugin()]; const welcome = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/welcome.pdf'); return { kind: 'bytes', id: 'welcome', bytes: new Uint8Array(await response.arrayBuffer()) }; }; function PageToolbar() { const stage = useStage(); const { currentPageIndex, pageCount } = useStageState(); const [typed, setTyped] = useState(''); // People count from 1, an index from 0. An index past the end goes to the last page. const jump = () => { const number = Number(typed); if (Number.isInteger(number) && number >= 1) stage.goToPage(number - 1); setTyped(''); }; return (
Page{' '} {currentPageIndex + 1} / {pageCount} setTyped(event.target.value)} onKeyDown={(event) => event.key === 'Enter' && jump()} />
); } export default function App() { return ( Loading…

}> {() => }
); }