From 48582a34e70542ea1fd7ab1c56d929f565c056df Mon Sep 17 00:00:00 2001 From: LarsFlem <43146722+LarsFlem@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:20:18 +0200 Subject: [PATCH] Update PDF.tsx --- src/components/PDF.tsx | 46 +++++++++++------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/src/components/PDF.tsx b/src/components/PDF.tsx index 717d4db..85467b2 100644 --- a/src/components/PDF.tsx +++ b/src/components/PDF.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from "react"; +import React, { useEffect, useRef } from "react"; import "./PDF.css"; // Import the PDF file @@ -6,46 +6,24 @@ import CV_PDF from "./_PDF/Lars_Flem_CV_english.pdf"; // Define the PdfViewer component const PdfViewer: React.FC = () => { - const [isIOS, setIsIOS] = useState(false); - const iframeRef = useRef(null); // Ref for iframe - const objectRef = useRef(null); // Ref for object + const pdfRef = useRef(null); useEffect(() => { - const userAgent = navigator.userAgent || navigator.vendor; - - // Detect iOS (iPhone/iPad) - updated condition to not use window.opera - const isIOSDevice = /iPad|iPhone|iPod/.test(userAgent); - setIsIOS(isIOSDevice); + if (pdfRef.current) { + // Calculate the height dynamically based on the window height + const windowHeight = window.innerHeight; + pdfRef.current.style.height = `${windowHeight - 150}px`; // Subtract header/footer or any margin as needed + } }, []); return (

CV

- {isIOS ? ( - - ) : ( - -

- PDF cannot be displayed. Download the PDF. -

-
- )} + +

+ PDF cannot be displayed. Download the PDF. +

+
); };