import 'react-pdf/dist/Page/TextLayer.css'; import 'react-pdf/dist/Page/AnnotationLayer.css'; import { convertFileSrc } from '@tauri-apps/api/core'; import './PdfViewer.css'; import type { PDFDocumentProxy } from 'pdfjs-dist'; import React, { useRef, useState } from 'react'; import { Document, Page } from 'react-pdf'; import { useContainerSize } from '../../hooks/useContainerQuery'; interface Props { bodyPath: string; } const options = { cMapUrl: '/cmaps/', standardFontDataUrl: '/standard_fonts/', }; export function PdfViewer({ bodyPath }: Props) { const containerRef = useRef(null); const [numPages, setNumPages] = useState(); const { width: containerWidth } = useContainerSize(containerRef); const onDocumentLoadSuccess = ({ numPages: nextNumPages }: PDFDocumentProxy): void => { setNumPages(nextNumPages); }; const src = convertFileSrc(bodyPath); return (
{Array.from(new Array(numPages), (_, index) => ( ))}
); }