LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
added jump to page functionality in pdf viewer for highlight (#824)
vishnuszipstackce1f5658331b
diff --git a/frontend/src/components/custom-tools/pdf-viewer/PdfViewer.jsx b/frontend/src/components/custom-tools/pdf-viewer/PdfViewer.jsxindex 2526fcfde..765e468b7 100644--- a/frontend/src/components/custom-tools/pdf-viewer/PdfViewer.jsx+++ b/frontend/src/components/custom-tools/pdf-viewer/PdfViewer.jsx@@ -1,4 +1,4 @@-import { useRef } from "react";+import { useEffect, useRef } from "react";import { Viewer, Worker } from "@react-pdf-viewer/core";import { defaultLayoutPlugin } from "@react-pdf-viewer/default-layout";import { pageNavigationPlugin } from "@react-pdf-viewer/page-navigation";@@ -12,13 +12,19 @@ try {RenderHighlights =require("../../../plugins/pdf-highlight/RenderHighlights").RenderHighlights;} catch (err) {- // Do nothing, No plugin will be loaded.+ // Do nothing, no plugin will be loaded.}function PdfViewer({ fileUrl, highlightData }) {const newPlugin = defaultLayoutPlugin();const pageNavigationPluginInstance = pageNavigationPlugin();+ const { jumpToPage } = pageNavigationPluginInstance;const parentRef = useRef(null);+ function removeZerosAndDeleteIfAllZero(highlightData) {+ return highlightData.filter((innerArray) =>+ innerArray.some((value) => value !== 0)+ ); // Keep arrays that contain at least one non-zero value+ }let highlightPluginInstance = "";if (RenderHighlights && highlightData) {highlightPluginInstance = highlightPlugin({@@ -28,6 +34,19 @@ function PdfViewer({ fileUrl, highlightData }) {});}+ // Jump to page when highlightData changes+ useEffect(() => {+ if (highlightData && highlightData.length > 0) {+ highlightData = removeZerosAndDeleteIfAllZero(highlightData);+ const pageNumber = highlightData[0][0]; // Assume highlightData[0][0] is the page number+ if (pageNumber !== null && jumpToPage) {+ setTimeout(() => {+ jumpToPage(pageNumber); // jumpToPage is 0-indexed, so subtract 1+ }, 100); // Add a slight delay to ensure proper page rendering+ }+ }+ }, [highlightData, jumpToPage]);+return (<div ref={parentRef} className="doc-manager-body"><Worker workerUrl="https://unpkg.com/[email protected]/build/pdf.worker.min.js">