import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Scrollbar, Stage, stagePlugin, useScrollMetrics } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { localEngine } from '@embedpdf/engine'; import './scrollbar.css'; const engine = localEngine(); const plugins = [stagePlugin(), renderPlugin()]; // [!doc-source welcome] 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()) }; }; // [!/doc-source] // A reading-progress bar, from the same numbers a scrollbar uses. function ReadingProgress() { const { scrollTop, scrollHeight, clientHeight } = useScrollMetrics(); const travel = scrollHeight - clientHeight; const progress = travel > 0 ? Math.round((scrollTop / travel) * 100) : 0; return (
); } export default function App() { return ( Loading…

}> } > {() => }
); }