From 3b1b7603c4c2a3ad83ebcabaefa7aa16cadea925 Mon Sep 17 00:00:00 2001 From: Zainab2604 Date: Wed, 25 Jun 2025 21:04:45 +0200 Subject: [PATCH] Add bold headline and zoom in pdf viewer --- project/frontend/src/components/pdfViewer.tsx | 46 ++++++++++++++++--- .../extractedResult_.$pitchBook.$kpi.tsx | 4 +- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/project/frontend/src/components/pdfViewer.tsx b/project/frontend/src/components/pdfViewer.tsx index 4d171a7..4749c3e 100644 --- a/project/frontend/src/components/pdfViewer.tsx +++ b/project/frontend/src/components/pdfViewer.tsx @@ -12,6 +12,8 @@ import type { import { socket } from "../socket"; import { API_HOST } from "../util/api"; import { highlightPattern } from "../util/highlighting"; +import ZoomInIcon from "@mui/icons-material/ZoomIn"; +import ZoomOutIcon from "@mui/icons-material/ZoomOut"; interface PDFViewerProps { pitchBookId: string; @@ -30,7 +32,7 @@ export default function PDFViewer({ }: PDFViewerProps) { const [numPages, setNumPages] = useState(null); const [pageNumber, setPageNumber] = useState(currentPage || 1); - const [containerWidth, setContainerWidth] = useState(null); + const [baseWidth, setBaseWidth] = useState(null); const [pdfKey, setPdfKey] = useState(Date.now()); const containerRef = useRef(null); const [posHighlight, setPosHighlight] = useState([]); @@ -38,6 +40,7 @@ export default function PDFViewer({ const [textContent, setTextContent] = useState< { posKey: string; text: string; i: number }[] >([]); + const [zoomLevel, setZoomLevel] = useState(1.0); const onDocumentLoadSuccess = ({ numPages }: { numPages: number }) => { setNumPages(numPages); @@ -46,7 +49,9 @@ export default function PDFViewer({ useEffect(() => { const updateWidth = () => { if (containerRef.current) { - setContainerWidth(containerRef.current.offsetWidth); + if (!baseWidth) { + setBaseWidth(containerRef.current.offsetWidth); + } } }; @@ -186,16 +191,32 @@ export default function PDFViewer({ justifyContent="center" alignItems="center" width="100%" + maxWidth="900px" + margin="0 auto" + minHeight="80vh" height="auto" + sx={{ + backgroundColor: "#f5f5f5", + borderRadius: 2, + boxShadow: 2, + }} > console.error("Ungültige PDF:", error)} > - {containerWidth && ( + {baseWidth && ( @@ -225,6 +246,13 @@ export default function PDFViewer({ gap={1} p={1} > + setZoomLevel(z => Math.max(0.3, z - 0.1))} + title="Verkleinern" + > + + handlePageChange(pageNumber - 1)} @@ -240,6 +268,12 @@ export default function PDFViewer({ > + setZoomLevel(z => Math.min(3, z + 0.1))} + title="Vergrößern" + > + + ); diff --git a/project/frontend/src/routes/extractedResult_.$pitchBook.$kpi.tsx b/project/frontend/src/routes/extractedResult_.$pitchBook.$kpi.tsx index 0194c09..1fbf5fd 100644 --- a/project/frontend/src/routes/extractedResult_.$pitchBook.$kpi.tsx +++ b/project/frontend/src/routes/extractedResult_.$pitchBook.$kpi.tsx @@ -256,8 +256,8 @@ function ExtractedResultsPage() { - - Überprüfung der Kennzahl: {kpi} + + Überprüfung der Kennzahl: {kpi}