diff --git a/frontend/src/components/viewer/LocalEmbedPDF.tsx b/frontend/src/components/viewer/LocalEmbedPDF.tsx index a55a95dd5..a334badcb 100644 --- a/frontend/src/components/viewer/LocalEmbedPDF.tsx +++ b/frontend/src/components/viewer/LocalEmbedPDF.tsx @@ -87,7 +87,7 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) { // Register zoom plugin with configuration createPluginRegistration(ZoomPluginPackage, { - defaultZoomLevel: 1.0, // Start at exactly 100% zoom + defaultZoomLevel: 1.4, // Start at 140% zoom for better readability minZoom: 0.2, maxZoom: 3.0, }), diff --git a/frontend/src/components/viewer/ZoomAPIBridge.tsx b/frontend/src/components/viewer/ZoomAPIBridge.tsx index e2b265a8c..709f408b8 100644 --- a/frontend/src/components/viewer/ZoomAPIBridge.tsx +++ b/frontend/src/components/viewer/ZoomAPIBridge.tsx @@ -1,4 +1,4 @@ -import { useEffect } from 'react'; +import { useEffect, useRef } from 'react'; import { useZoom } from '@embedpdf/plugin-zoom/react'; /** @@ -6,17 +6,30 @@ import { useZoom } from '@embedpdf/plugin-zoom/react'; */ export function ZoomAPIBridge() { const { provides: zoom, state: zoomState } = useZoom(); + const hasSetInitialZoom = useRef(false); + + // Set initial zoom once when plugin is ready + useEffect(() => { + if (zoom && !hasSetInitialZoom.current) { + hasSetInitialZoom.current = true; + setTimeout(() => { + console.log('Setting initial zoom to 140%'); + zoom.requestZoom(1.4); + }, 50); + } + }, [zoom]); useEffect(() => { if (zoom) { + // Export zoom controls to global window for right rail access (window as any).embedPdfZoom = { zoomIn: () => zoom.zoomIn(), zoomOut: () => zoom.zoomOut(), toggleMarqueeZoom: () => zoom.toggleMarqueeZoom(), requestZoom: (level: any) => zoom.requestZoom(level), - currentZoom: zoomState?.currentZoomLevel || 1, - zoomPercent: Math.round((zoomState?.currentZoomLevel || 1) * 100), + currentZoom: zoomState?.currentZoomLevel || 1.4, + zoomPercent: Math.round((zoomState?.currentZoomLevel || 1.4) * 100), }; }