Skip to content

Commit

Permalink
clean pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Ryo committed May 23, 2024
1 parent 7b1bf44 commit 14d8ce7
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,19 @@ import { Document, Page, pdfjs } from 'react-pdf';

import 'react-pdf/dist/esm/Page/TextLayer.css';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import { Button } from '@mui/material';

pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
export default function PdfDisplay({ url }: { url: string }) {
const [numPages, setNumPages] = useState<number>(1);
const [pageNumber, setPageNumber] = useState<number>(1);
function onDocumentLoadSuccess({ numPages }: { numPages: number }): void {
setNumPages(numPages);
}
// function handlePages(){
// if()
// }

return (
<Document file={url} onLoadSuccess={onDocumentLoadSuccess}>
<Page width={380} pageNumber={1} />
<p>
Page {pageNumber} sur {numPages}
</p>
<Button onClick={() => setPageNumber(pageNumber + 1)}>+</Button>
<Button onClick={() => setPageNumber(pageNumber - 1)}>-</Button>
{Array.from(Array(numPages).keys()).map((v) => (
<Page key={v} width={380} pageNumber={v} />
))}
</Document>
);
}

0 comments on commit 14d8ce7

Please sign in to comment.