import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin } from '@embedpdf/react/stage'; import { RenderLayer, SnapshotLayer, renderPlugin } from '@embedpdf/react/render'; import { interactionPlugin, useInteraction, useInteractionState, } from '@embedpdf/react/interaction'; import { SelectionLayer, selectionPlugin } from '@embedpdf/react/selection'; import { localEngine } from '@embedpdf/engine'; import './switch.css'; const engine = localEngine(); // The document opens with the hand tool. const plugins = [ stagePlugin(), renderPlugin(), interactionPlugin({ defaultTool: 'pan' }), selectionPlugin(), ]; // [!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] const LABELS: Record = { pointer: 'Select', pan: 'Hand', zoom: 'Zoom', snapshot: 'Snapshot', }; const HINTS: Record = { pointer: 'A drag selects text', pan: 'A drag scrolls the pages', zoom: 'A drag zooms to the box, a click zooms in', snapshot: 'A drag takes part of a page as an image', }; // A button for every tool you can switch to, the active one pressed. function ToolSwitch() { const interaction = useInteraction(); const { activeToolId, tools } = useInteractionState(); return (
{tools.map((tool) => ( ))}
{activeToolId ? HINTS[activeToolId] : ''}
); } export default function App() { return ( Loading…

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