import { Viewer, DocumentGate, useDocument, useDocuments, 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 './tabs.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] // [!doc-source sketch] const sketch = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/sketch.pdf'); return { kind: 'bytes', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] function Tabs() { const documents = useDocuments(); const { documents: open, activeId } = useDocumentsState(); return (
{open.map((document) => (
))}
); } // The active tab: rename it, move it to the front, and zoom it. Each tab keeps its own zoom. function TabTools() { const documents = useDocuments(); const { id, name } = useDocument(); const stage = useStage(); const zoomLevel = useStageState((state) => state.zoomLevel); return (
documents.rename(id, event.target.value)} /> {Math.round(zoomLevel * 100)}%
); } export default function App() { return ( Opening…

}> {() => }
); }