'use client'; import { useState } from 'react'; import { Document, Page, pdfjs } from 'react-pdf'; import { ChevronLeft, ChevronRight, ZoomIn, ZoomOut, Loader2 } from 'lucide-react'; import 'react-pdf/dist/Page/AnnotationLayer.css'; import 'react-pdf/dist/Page/TextLayer.css'; if (typeof window !== 'undefined') { pdfjs.GlobalWorkerOptions.workerSrc = `/pdf.worker.min.mjs`; } export default function PdfViewer({ url }: { url: string }) { const [numPages, setNumPages] = useState(); const [scale, setScale] = useState(1.2); function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { setNumPages(numPages); } return (
{/* PDF Toolbar */}
{numPages ? `${numPages} Pages` : 'Loading...'}
{Math.round(scale * 100)}%
{/* PDF Content */}
} className="flex flex-col items-center gap-6" > {numPages && Array.from(new Array(numPages), (el, index) => ( ))}
); }