import { useEffect } from 'react'; import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin, useStage } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { SearchLayer, searchPlugin, useSearch, useSearchHits } from '@embedpdf/react/search'; import { localEngine } from '@embedpdf/engine'; import './pass-through.css'; const engine = localEngine(); const plugins = [stagePlugin(), renderPlugin(), searchPlugin()]; // [!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 search hit says where it is in page coordinates; the Stage takes them as they are. function Hits() { const search = useSearch(); const stage = useStage(); const hits = useSearchHits(); useEffect(() => { void search.search({ text: 'PDF' }); }, [search]); return (
    {hits.slice(0, 8).map((hit) => hit.bounds ? (
  1. ) : null, )}
); } export default function App() { return ( Loading…

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