import { Viewer, DocumentGate, DocumentScope, useDocument, useDocumentsState, } 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 './scope.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', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] // [!doc-source article] const article = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/article.pdf'); return { kind: 'bytes', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] // The same component in both panes: each talks to the document its names. function Header() { const { name, pageCount } = useDocument(); const stage = useStage(); const zoomLevel = useStageState((state) => state.zoomLevel); return (
{name} {pageCount} pages {Math.round(zoomLevel * 100)}%
); } function SideBySide() { const { documents } = useDocumentsState(); return (
{documents.map((document) => (
Opening…

}>
{() => }
))}
); } export default function App() { return ( ); }