pdfjs-reader-core 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -250,20 +250,24 @@ interface StudentModeProps {
250
250
  interface PDFViewerProps {
251
251
  /** URL or ArrayBuffer of the PDF file */
252
252
  src: string | ArrayBuffer | Uint8Array;
253
- /** Initial page number (1-indexed) */
253
+ /** Initial page number (1-indexed) - used in uncontrolled mode */
254
254
  initialPage?: number;
255
- /** Initial scale/zoom level */
255
+ /** Controlled page - viewer syncs to this value when provided */
256
+ page?: number;
257
+ /** Initial scale/zoom level. Use 'auto' or 'page-width' to fit to container width. */
256
258
  initialScale?: number | 'page-fit' | 'page-width' | 'auto';
257
259
  /** Theme mode */
258
260
  theme?: 'light' | 'dark' | 'sepia';
259
261
  /** Custom class name */
260
262
  className?: string;
261
- /** Whether to show the toolbar */
263
+ /** Whether to show the toolbar (default: true) */
262
264
  showToolbar?: boolean;
263
- /** Whether to show the sidebar */
265
+ /** Whether to show the sidebar (default: true) */
264
266
  showSidebar?: boolean;
265
- /** Whether to show the annotation toolbar */
267
+ /** Whether to show the annotation toolbar (default: false) */
266
268
  showAnnotationToolbar?: boolean;
269
+ /** Whether to show floating zoom controls (default: true) */
270
+ showFloatingZoom?: boolean;
267
271
  /** Default sidebar panel */
268
272
  defaultSidebarPanel?: SidebarPanel;
269
273
  /** View mode for the document */
@@ -280,6 +284,22 @@ interface PDFViewerProps {
280
284
  onError?: (error: Error) => void;
281
285
  /** Worker source URL for pdf.js */
282
286
  workerSrc?: string;
287
+ /** Callback when a page starts rendering */
288
+ onPageRenderStart?: (pageNumber: number) => void;
289
+ /** Callback when a page finishes rendering */
290
+ onPageRenderComplete?: (pageNumber: number) => void;
291
+ /** Callback when a highlight is added */
292
+ onHighlightAdded?: (highlight: Highlight) => void;
293
+ /** Callback when a highlight is removed */
294
+ onHighlightRemoved?: (highlightId: string) => void;
295
+ /** Callback when an annotation is added */
296
+ onAnnotationAdded?: (annotation: Annotation) => void;
297
+ /** Callback when zoom/scale changes (alias for onScaleChange) */
298
+ onZoomChange?: (scale: number) => void;
299
+ /** Custom loading component */
300
+ loadingComponent?: React.ReactNode;
301
+ /** Custom error component - can be a node or a function receiving error and retry callback */
302
+ errorComponent?: React.ReactNode | ((error: Error, retry: () => void) => React.ReactNode);
283
303
  }
284
304
  interface PDFDocumentLoadedEvent {
285
305
  numPages: number;
@@ -310,6 +330,12 @@ type ViewMode = 'single' | 'dual' | 'continuous';
310
330
  type ScrollMode = 'single' | 'continuous';
311
331
  type SidebarPanel = 'thumbnails' | 'outline' | 'search' | 'annotations' | null;
312
332
  type Theme = 'light' | 'dark' | 'sepia';
333
+ /** Request to scroll to a specific page */
334
+ interface ScrollToPageRequest {
335
+ page: number;
336
+ requestId: string;
337
+ behavior: 'smooth' | 'instant';
338
+ }
313
339
  interface ViewerState {
314
340
  document: PDFDocumentProxy | null;
315
341
  numPages: number;
@@ -318,6 +344,7 @@ interface ViewerState {
318
344
  currentPage: number;
319
345
  scale: number;
320
346
  rotation: number;
347
+ scrollToPageRequest: ScrollToPageRequest | null;
321
348
  viewMode: ViewMode;
322
349
  scrollMode: ScrollMode;
323
350
  theme: Theme;
@@ -334,6 +361,8 @@ interface ViewerActions {
334
361
  goToPage: (page: number) => void;
335
362
  nextPage: () => void;
336
363
  previousPage: () => void;
364
+ requestScrollToPage: (page: number, behavior?: 'smooth' | 'instant') => Promise<void>;
365
+ completeScrollRequest: (requestId: string) => void;
337
366
  setScale: (scale: number) => void;
338
367
  zoomIn: () => void;
339
368
  zoomOut: () => void;
@@ -359,8 +388,8 @@ interface Highlight {
359
388
  comment?: string;
360
389
  createdAt: Date;
361
390
  updatedAt: Date;
362
- /** Source of the highlight: user-created or agent-created */
363
- source?: 'user' | 'agent';
391
+ /** Source of the highlight: user-created, agent-created, or search result */
392
+ source?: 'user' | 'agent' | 'search';
364
393
  }
365
394
  interface HighlightRect {
366
395
  x: number;
@@ -469,6 +498,291 @@ interface PDFViewerEventMap {
469
498
  textselect: TextSelection;
470
499
  error: Error;
471
500
  }
501
+ interface HighlightTextOptions {
502
+ /** Highlight color (default: 'yellow') */
503
+ color?: HighlightColor;
504
+ /** Only highlight on specific page (default: all pages) */
505
+ page?: number;
506
+ /** Case sensitive search (default: false) */
507
+ caseSensitive?: boolean;
508
+ /** Scroll to first match (default: true) */
509
+ scrollTo?: boolean;
510
+ }
511
+ interface DrawRectOptions {
512
+ /** Page number (1-indexed) */
513
+ page: number;
514
+ /** X coordinate (percentage of page width, 0-100) */
515
+ x: number;
516
+ /** Y coordinate (percentage of page height, 0-100) */
517
+ y: number;
518
+ /** Width (percentage of page width) */
519
+ width: number;
520
+ /** Height (percentage of page height) */
521
+ height: number;
522
+ /** Border color (default: 'blue') */
523
+ color?: string;
524
+ /** Border width in pixels (default: 2) */
525
+ strokeWidth?: number;
526
+ /** Fill color (optional, transparent if not set) */
527
+ fillColor?: string;
528
+ }
529
+ interface DrawCircleOptions {
530
+ /** Page number (1-indexed) */
531
+ page: number;
532
+ /** Center X coordinate (percentage of page width, 0-100) */
533
+ x: number;
534
+ /** Center Y coordinate (percentage of page height, 0-100) */
535
+ y: number;
536
+ /** Radius (percentage of page width) */
537
+ radius: number;
538
+ /** Border color (default: 'blue') */
539
+ color?: string;
540
+ /** Border width in pixels (default: 2) */
541
+ strokeWidth?: number;
542
+ /** Fill color (optional, transparent if not set) */
543
+ fillColor?: string;
544
+ }
545
+ interface AddNoteOptions {
546
+ /** Page number (1-indexed) */
547
+ page: number;
548
+ /** X coordinate (percentage of page width, 0-100) */
549
+ x: number;
550
+ /** Y coordinate (percentage of page height, 0-100) */
551
+ y: number;
552
+ /** Note content */
553
+ content: string;
554
+ /** Note color (default: 'yellow') */
555
+ color?: string;
556
+ }
557
+ interface SearchOptions {
558
+ /** Case sensitive search (default: false) */
559
+ caseSensitive?: boolean;
560
+ /** Match whole words only (default: false) */
561
+ wholeWord?: boolean;
562
+ /** Highlight all matches (default: true) */
563
+ highlightAll?: boolean;
564
+ }
565
+ interface GoToPageOptions {
566
+ /** Scroll behavior (default: 'smooth') */
567
+ behavior?: 'smooth' | 'instant';
568
+ }
569
+ interface SearchAndHighlightOptions {
570
+ /** Highlight color (default: 'yellow') */
571
+ color?: HighlightColor;
572
+ /** Page range to search - either { start, end } or array of page numbers */
573
+ pageRange?: {
574
+ start: number;
575
+ end: number;
576
+ } | number[];
577
+ /** Case sensitive search (default: false) */
578
+ caseSensitive?: boolean;
579
+ /** Match whole words only (default: false) */
580
+ wholeWord?: boolean;
581
+ /** Scroll to first match (default: true) */
582
+ scrollToFirst?: boolean;
583
+ /** Clear previous search highlights (default: true) */
584
+ clearPrevious?: boolean;
585
+ }
586
+ interface SearchAndHighlightResult {
587
+ /** Total number of matches found */
588
+ matchCount: number;
589
+ /** IDs of created highlights */
590
+ highlightIds: string[];
591
+ /** Detailed match information */
592
+ matches: Array<{
593
+ pageNumber: number;
594
+ text: string;
595
+ highlightId: string;
596
+ rects: HighlightRect[];
597
+ }>;
598
+ }
599
+ interface AgentToolResult<T = void> {
600
+ success: boolean;
601
+ data?: T;
602
+ error?: {
603
+ code: string;
604
+ message: string;
605
+ };
606
+ }
607
+ interface AgentTools {
608
+ /** Navigate to a specific page */
609
+ navigateToPage: (page: number) => Promise<AgentToolResult<{
610
+ previousPage: number;
611
+ currentPage: number;
612
+ }>>;
613
+ /** Highlight text with structured response */
614
+ highlightText: (text: string, options?: HighlightTextOptions) => Promise<AgentToolResult<{
615
+ matchCount: number;
616
+ highlightIds: string[];
617
+ }>>;
618
+ /** Get text content of a specific page */
619
+ getPageContent: (page: number) => Promise<AgentToolResult<{
620
+ text: string;
621
+ }>>;
622
+ /** Clear all visual elements (highlights and annotations) */
623
+ clearAllVisuals: () => Promise<AgentToolResult<void>>;
624
+ }
625
+ interface PageCoordinates {
626
+ x: number;
627
+ y: number;
628
+ }
629
+ interface PageDimensionsInfo {
630
+ width: number;
631
+ height: number;
632
+ rotation: number;
633
+ }
634
+ interface CoordinateHelpers {
635
+ /** Get dimensions of a specific page */
636
+ getPageDimensions: (page: number) => PageDimensionsInfo | null;
637
+ /** Convert percent coordinates (0-100) to pixels */
638
+ percentToPixels: (xPercent: number, yPercent: number, page: number) => PageCoordinates | null;
639
+ /** Convert pixel coordinates to percent (0-100) */
640
+ pixelsToPercent: (x: number, y: number, page: number) => PageCoordinates | null;
641
+ }
642
+ /**
643
+ * Imperative handle for PDFViewerClient.
644
+ * Use this to programmatically control the PDF viewer.
645
+ *
646
+ * @example
647
+ * ```tsx
648
+ * const viewerRef = useRef<PDFViewerHandle>(null);
649
+ *
650
+ * // Highlight text
651
+ * viewerRef.current?.highlightText("important keyword");
652
+ *
653
+ * // Draw a rectangle
654
+ * viewerRef.current?.drawRect({ page: 1, x: 10, y: 20, width: 30, height: 10 });
655
+ *
656
+ * // Navigate
657
+ * viewerRef.current?.goToPage(5);
658
+ * ```
659
+ */
660
+ interface PDFViewerHandle {
661
+ /**
662
+ * Find and highlight text in the PDF.
663
+ * @param text - Text to find and highlight
664
+ * @param options - Highlight options
665
+ * @returns Array of highlight IDs created
666
+ */
667
+ highlightText: (text: string, options?: HighlightTextOptions) => Promise<string[]>;
668
+ /**
669
+ * Remove a specific highlight by ID.
670
+ */
671
+ removeHighlight: (id: string) => void;
672
+ /**
673
+ * Clear all highlights.
674
+ */
675
+ clearHighlights: () => void;
676
+ /**
677
+ * Draw a rectangle on the PDF.
678
+ * @param options - Rectangle options (coordinates are percentages 0-100)
679
+ * @returns Annotation ID
680
+ */
681
+ drawRect: (options: DrawRectOptions) => string;
682
+ /**
683
+ * Draw a circle on the PDF.
684
+ * @param options - Circle options (coordinates are percentages 0-100)
685
+ * @returns Annotation ID
686
+ */
687
+ drawCircle: (options: DrawCircleOptions) => string;
688
+ /**
689
+ * Add a note annotation.
690
+ * @param options - Note options
691
+ * @returns Annotation ID
692
+ */
693
+ addNote: (options: AddNoteOptions) => string;
694
+ /**
695
+ * Remove a specific annotation by ID.
696
+ */
697
+ removeAnnotation: (id: string) => void;
698
+ /**
699
+ * Clear all annotations.
700
+ */
701
+ clearAnnotations: () => void;
702
+ /**
703
+ * Go to a specific page. Returns a Promise that resolves when scroll completes.
704
+ * @param page - Page number (1-indexed)
705
+ * @param options - Navigation options
706
+ * @returns Promise that resolves when the page is visible
707
+ */
708
+ goToPage: (page: number, options?: GoToPageOptions) => Promise<void>;
709
+ /**
710
+ * Go to the next page.
711
+ */
712
+ nextPage: () => void;
713
+ /**
714
+ * Go to the previous page.
715
+ */
716
+ previousPage: () => void;
717
+ /**
718
+ * Get the current page number.
719
+ */
720
+ getCurrentPage: () => number;
721
+ /**
722
+ * Get total number of pages.
723
+ */
724
+ getNumPages: () => number;
725
+ /**
726
+ * Set the zoom level.
727
+ * @param scale - Zoom scale (1.0 = 100%)
728
+ */
729
+ setZoom: (scale: number) => void;
730
+ /**
731
+ * Get the current zoom level.
732
+ */
733
+ getZoom: () => number;
734
+ /**
735
+ * Zoom in.
736
+ */
737
+ zoomIn: () => void;
738
+ /**
739
+ * Zoom out.
740
+ */
741
+ zoomOut: () => void;
742
+ /**
743
+ * Search for text in the PDF.
744
+ * @param query - Search query
745
+ * @param options - Search options
746
+ * @returns Search results
747
+ */
748
+ search: (query: string, options?: SearchOptions) => Promise<SearchResult[]>;
749
+ /**
750
+ * Go to the next search result.
751
+ */
752
+ nextSearchResult: () => void;
753
+ /**
754
+ * Go to the previous search result.
755
+ */
756
+ previousSearchResult: () => void;
757
+ /**
758
+ * Clear search results.
759
+ */
760
+ clearSearch: () => void;
761
+ /**
762
+ * Search for text and highlight all matches in one operation.
763
+ * @param query - Text to search for
764
+ * @param options - Search and highlight options
765
+ * @returns Structured result with match count and highlight IDs
766
+ */
767
+ searchAndHighlight: (query: string, options?: SearchAndHighlightOptions) => Promise<SearchAndHighlightResult>;
768
+ /**
769
+ * Agent-friendly tools with structured responses.
770
+ * Each method returns { success, data?, error? } for easy agent integration.
771
+ */
772
+ agentTools: AgentTools;
773
+ /**
774
+ * Coordinate conversion utilities for working with PDF page coordinates.
775
+ */
776
+ coordinates: CoordinateHelpers;
777
+ /**
778
+ * Get the underlying PDF document (pdfjs-dist PDFDocumentProxy).
779
+ */
780
+ getDocument: () => PDFDocumentProxy | null;
781
+ /**
782
+ * Check if the document is loaded.
783
+ */
784
+ isLoaded: () => boolean;
785
+ }
472
786
 
473
787
  /**
474
788
  * Main PDF Viewer component.
@@ -496,10 +810,27 @@ interface PDFViewerEventMap {
496
810
  declare const PDFViewer: react.NamedExoticComponent<PDFViewerProps>;
497
811
 
498
812
  /**
499
- * SSR-safe PDF Viewer component.
500
- * Wraps the inner viewer with the context provider.
813
+ * PDF Viewer component with imperative API.
814
+ *
815
+ * @example
816
+ * ```tsx
817
+ * const viewerRef = useRef<PDFViewerHandle>(null);
818
+ *
819
+ * <PDFViewerClient
820
+ * ref={viewerRef}
821
+ * src="/document.pdf"
822
+ * onDocumentLoad={() => {
823
+ * // Highlight text when document loads
824
+ * viewerRef.current?.highlightText("important", { color: "yellow" });
825
+ * }}
826
+ * />
827
+ *
828
+ * // Call methods anytime
829
+ * viewerRef.current?.goToPage(5);
830
+ * viewerRef.current?.drawRect({ page: 1, x: 10, y: 20, width: 30, height: 10 });
831
+ * ```
501
832
  */
502
- declare const PDFViewerClient: react.NamedExoticComponent<PDFViewerProps>;
833
+ declare const PDFViewerClient: react.MemoExoticComponent<react.ForwardRefExoticComponent<PDFViewerProps & react.RefAttributes<PDFViewerHandle>>>;
503
834
 
504
835
  interface DocumentContainerProps {
505
836
  className?: string;
@@ -1020,6 +1351,52 @@ interface MinimapProps {
1020
1351
  */
1021
1352
  declare const Minimap: react.NamedExoticComponent<MinimapProps>;
1022
1353
 
1354
+ interface FloatingZoomControlsProps {
1355
+ /** Position of the controls */
1356
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
1357
+ /** Additional class name */
1358
+ className?: string;
1359
+ /** Show fit to width button */
1360
+ showFitToWidth?: boolean;
1361
+ /** Show fit to page button */
1362
+ showFitToPage?: boolean;
1363
+ /** Show zoom percentage */
1364
+ showZoomLevel?: boolean;
1365
+ }
1366
+ /**
1367
+ * Floating zoom controls for easy zoom adjustment.
1368
+ * Shows +/- buttons and optionally fit-to-width/fit-to-page buttons.
1369
+ */
1370
+ declare const FloatingZoomControls: react.NamedExoticComponent<FloatingZoomControlsProps>;
1371
+
1372
+ interface PDFThumbnailNavProps {
1373
+ /** Scale for thumbnails (default: 0.15) */
1374
+ thumbnailScale?: number;
1375
+ /** Orientation of the thumbnail strip */
1376
+ orientation?: 'horizontal' | 'vertical';
1377
+ /** Maximum number of thumbnails visible at once */
1378
+ maxVisible?: number;
1379
+ /** Custom class name */
1380
+ className?: string;
1381
+ /** Callback when a thumbnail is clicked */
1382
+ onThumbnailClick?: (page: number) => void;
1383
+ /** Gap between thumbnails in pixels (default: 8) */
1384
+ gap?: number;
1385
+ /** Show page numbers below thumbnails (default: true) */
1386
+ showPageNumbers?: boolean;
1387
+ }
1388
+ /**
1389
+ * PDFThumbnailNav provides a navigable strip of PDF page thumbnails.
1390
+ * Syncs with the current PDF viewer via store subscription.
1391
+ *
1392
+ * Features:
1393
+ * - Virtualized rendering (only visible thumbnails are rendered)
1394
+ * - Auto-scrolls to keep current page visible
1395
+ * - Click to navigate to page
1396
+ * - Horizontal or vertical orientation
1397
+ */
1398
+ declare const PDFThumbnailNav: react.NamedExoticComponent<PDFThumbnailNavProps>;
1399
+
1023
1400
  interface PDFErrorBoundaryProps {
1024
1401
  /** Child components to render */
1025
1402
  children: ReactNode;
@@ -1058,6 +1435,8 @@ interface SearchActions {
1058
1435
  nextResult: () => void;
1059
1436
  previousResult: () => void;
1060
1437
  goToResult: (index: number) => void;
1438
+ setCaseSensitive: (value: boolean) => void;
1439
+ setWholeWord: (value: boolean) => void;
1061
1440
  toggleCaseSensitive: () => void;
1062
1441
  toggleWholeWord: () => void;
1063
1442
  getCurrentResult: () => SearchResult | null;
@@ -2032,4 +2411,256 @@ declare function createAgentAPI(stores: AgentAPIStores): AgentAPI;
2032
2411
  */
2033
2412
  type AgentAPIInstance = ReturnType<typeof createAgentAPI>;
2034
2413
 
2035
- export { type AgentAPI, type AgentAPIInstance, type AgentAPIStores, type AgentActions, type AgentContext, type AgentHighlightParams, type AgentState, type AgentStore, type AgentStoreApi, type Annotation, type AnnotationActions, AnnotationLayer, type AnnotationLayerProps, type AnnotationState, type AnnotationStore, type AnnotationStoreApi, type AnnotationTool, AnnotationToolbar, type AnnotationToolbarProps, type AnnotationType, type AskAboutContext, AskAboutOverlay, type AskAboutOverlayProps, AskAboutTrigger, type AskAboutTriggerProps, type Bookmark, BookmarksPanel, type BookmarksPanelProps, CanvasLayer, type CanvasLayerProps, type ContextMenuItem, ContinuousScrollContainer, type ContinuousScrollContainerProps, DocumentContainer, type DocumentContainerProps, type DrawingAnnotation, DrawingCanvas, type DrawingCanvasProps, type DrawingPath, DualPageContainer, type DualPageContainerProps, type ExportData, FocusRegionLayer, type FocusRegionLayerProps, type FocusedRegion, type Highlight, type HighlightColor, HighlightLayer, type HighlightLayerProps, HighlightPopover, type HighlightPopoverProps, type HighlightRect, HighlightsPanel, type HighlightsPanelProps, type LoadDocumentOptions, type LoadDocumentResult, Minimap, type MinimapProps, MobileSidebar, type MobileSidebarProps, MobileToolbar, type MobileToolbarProps, type NoteAnnotation, type OutlineItem, OutlinePanel, type OutlinePanelProps, type PDFDocumentLoadedEvent, PDFErrorBoundary, type PDFErrorBoundaryProps, PDFPage, type PDFPageProps, type PDFPageState, type PDFRegion, PDFViewer, PDFViewerClient, PDFViewerContext, type PDFViewerContextValue, type PDFViewerController, type PDFViewerControllerOptions, type PDFViewerEventMap, type PDFViewerProps, PDFViewerProvider, type PDFViewerProviderProps, type PageDimensions, type Plugin, type PluginAPI, PluginManager, type PluginManagerOptions, type QuickNote, QuickNoteButton, type QuickNoteButtonProps, QuickNotePopover, type QuickNotePopoverProps, type ScrollMode, type SearchActions, SearchPanel, type SearchPanelProps, type SearchResult, type SearchState, type SearchStore, type SearchStoreApi, SelectionToolbar, type SelectionToolbarProps, type ShapeAnnotation, ShapePreview, type ShapePreviewProps, ShapeRenderer, type ShapeRendererProps, type ShapeType, Sidebar, type SidebarPanel, type SidebarPanelConfig, type SidebarProps, StickyNote, type StickyNoteProps, type StoredStudentData, type StudentActions, type StudentData, type StudentModeCallbacks, type StudentModeProps, type StudentState, type StudentStore, type StudentStoreApi, type Takeaway, TakeawaysPanel, type TakeawaysPanelProps, TextLayer, type TextLayerProps, type TextSelection, type Theme, ThumbnailPanel, type ThumbnailPanelProps, Toolbar, type ToolbarItem, type ToolbarProps, type UseAgentContextOptions, type UseAgentContextReturn, type UseAnnotationsOptions, type UseAnnotationsReturn, type UseAskAboutOptions, type UseAskAboutReturn, type UseBookmarksOptions, type UseBookmarksReturn, type UseHighlightsOptions, type UseHighlightsReturn, type UsePageNavigationOptions, type UsePluginsOptions, type UsePluginsReturn, type UseQuickNotesOptions, type UseQuickNotesReturn, type UseStudentProgressOptions, type UseStudentProgressReturn, type UseTextSelectionOptions, type UseTouchGesturesOptions, type UseZoomOptions, type ViewMode, type ViewerActions, type ViewerState, type ViewerStore, type ViewerStoreApi, VirtualizedDocumentContainer, type VirtualizedDocumentContainerProps, type WithErrorBoundaryProps, clearHighlights, clearStudentData, cn, createAgentAPI, createAgentStore, createAnnotationStore, createPDFViewer, createPluginManager, createSearchStore, createStudentStore, createViewerStore, downloadAnnotationsAsJSON, downloadAnnotationsAsMarkdown, downloadFile, exportAnnotationsAsJSON, exportAnnotationsAsMarkdown, exportHighlightsAsJSON, exportHighlightsAsMarkdown, generateDocumentId, getAllDocumentIds, getAllStudentDataDocumentIds, getMetadata, getOutline, getPage, getPageTextContent, getPluginManager, getStorageStats, importHighlightsFromJSON, initializePDFJS, isPDFJSInitialized, loadDocument, loadHighlights, loadStudentData, quickViewer, saveHighlights, saveStudentData, useAgentContext, useAgentStore, useAnnotationStore, useAnnotations, useAskAbout, useBookmarks, useHighlights, useIsMobile, useIsTouchDevice, usePDFViewer, usePDFViewerStores, usePageNavigation, usePlugins, useQuickNotes, useSearchStore, useStudentProgress, useStudentStore, useTextSelection, useTouchGestures, useViewerStore, useZoom, withErrorBoundary };
2414
+ interface TextMatch {
2415
+ /** The matched text */
2416
+ text: string;
2417
+ /** Position rects on the page */
2418
+ rects: HighlightRect[];
2419
+ /** Page number where the match was found */
2420
+ pageNumber: number;
2421
+ /** Character index where the match starts in the page text */
2422
+ startIndex: number;
2423
+ }
2424
+ interface FindTextOptions {
2425
+ /** Case sensitive search (default: false) */
2426
+ caseSensitive?: boolean;
2427
+ /** Match whole words only (default: false) */
2428
+ wholeWord?: boolean;
2429
+ }
2430
+ interface CharPosition {
2431
+ char: string;
2432
+ rect: HighlightRect;
2433
+ }
2434
+ /**
2435
+ * Extract text content with character positions from a PDF page.
2436
+ */
2437
+ declare function extractPageText(document: PDFDocumentProxy, pageNumber: number): Promise<{
2438
+ fullText: string;
2439
+ charPositions: CharPosition[];
2440
+ }>;
2441
+ /**
2442
+ * Find all occurrences of text on a specific page.
2443
+ */
2444
+ declare function findTextOnPage(document: PDFDocumentProxy, pageNumber: number, query: string, options?: FindTextOptions): Promise<TextMatch[]>;
2445
+ /**
2446
+ * Find all occurrences of text across multiple pages.
2447
+ */
2448
+ declare function findTextInDocument(document: PDFDocumentProxy, query: string, options?: FindTextOptions & {
2449
+ pageRange?: number[];
2450
+ }): Promise<TextMatch[]>;
2451
+ /**
2452
+ * Merge adjacent rects into larger rects.
2453
+ */
2454
+ declare function mergeAdjacentRects(rects: HighlightRect[]): HighlightRect[];
2455
+ /**
2456
+ * Get the full text content of a page as a string.
2457
+ */
2458
+ declare function getPageText(document: PDFDocumentProxy, pageNumber: number): Promise<string>;
2459
+ /**
2460
+ * Count occurrences of text on a page without extracting positions.
2461
+ */
2462
+ declare function countTextOnPage(document: PDFDocumentProxy, pageNumber: number, query: string, options?: FindTextOptions): Promise<number>;
2463
+
2464
+ /**
2465
+ * Convert PDF coordinates to viewport (screen) coordinates.
2466
+ * PDF coordinates have origin at bottom-left, viewport at top-left.
2467
+ *
2468
+ * @param x - X coordinate in PDF space
2469
+ * @param y - Y coordinate in PDF space
2470
+ * @param scale - Current zoom scale
2471
+ * @param pageHeight - Height of the page in PDF units
2472
+ * @returns Viewport coordinates { x, y }
2473
+ */
2474
+ declare function pdfToViewport(x: number, y: number, scale: number, pageHeight: number): {
2475
+ x: number;
2476
+ y: number;
2477
+ };
2478
+ /**
2479
+ * Convert viewport (screen) coordinates to PDF coordinates.
2480
+ * Viewport coordinates have origin at top-left, PDF at bottom-left.
2481
+ *
2482
+ * @param x - X coordinate in viewport space
2483
+ * @param y - Y coordinate in viewport space
2484
+ * @param scale - Current zoom scale
2485
+ * @param pageHeight - Height of the page in PDF units
2486
+ * @returns PDF coordinates { x, y }
2487
+ */
2488
+ declare function viewportToPDF(x: number, y: number, scale: number, pageHeight: number): {
2489
+ x: number;
2490
+ y: number;
2491
+ };
2492
+ /**
2493
+ * Convert percentage-based coordinates to PDF coordinates.
2494
+ * Useful for positioning elements based on relative position.
2495
+ *
2496
+ * @param xPercent - X coordinate as percentage (0-100)
2497
+ * @param yPercent - Y coordinate as percentage (0-100)
2498
+ * @param pageWidth - Width of the page in PDF units
2499
+ * @param pageHeight - Height of the page in PDF units
2500
+ * @returns PDF coordinates { x, y }
2501
+ */
2502
+ declare function percentToPDF(xPercent: number, yPercent: number, pageWidth: number, pageHeight: number): {
2503
+ x: number;
2504
+ y: number;
2505
+ };
2506
+ /**
2507
+ * Convert PDF coordinates to percentage-based coordinates.
2508
+ *
2509
+ * @param x - X coordinate in PDF space
2510
+ * @param y - Y coordinate in PDF space
2511
+ * @param pageWidth - Width of the page in PDF units
2512
+ * @param pageHeight - Height of the page in PDF units
2513
+ * @returns Percentage coordinates { x, y } (0-100)
2514
+ */
2515
+ declare function pdfToPercent(x: number, y: number, pageWidth: number, pageHeight: number): {
2516
+ x: number;
2517
+ y: number;
2518
+ };
2519
+ /**
2520
+ * Convert percentage coordinates to viewport (screen) pixels.
2521
+ *
2522
+ * @param xPercent - X coordinate as percentage (0-100)
2523
+ * @param yPercent - Y coordinate as percentage (0-100)
2524
+ * @param pageWidth - Width of the page in PDF units
2525
+ * @param pageHeight - Height of the page in PDF units
2526
+ * @param scale - Current zoom scale
2527
+ * @returns Viewport coordinates { x, y }
2528
+ */
2529
+ declare function percentToViewport(xPercent: number, yPercent: number, pageWidth: number, pageHeight: number, scale: number): {
2530
+ x: number;
2531
+ y: number;
2532
+ };
2533
+ /**
2534
+ * Convert viewport (screen) pixels to percentage coordinates.
2535
+ *
2536
+ * @param x - X coordinate in viewport space
2537
+ * @param y - Y coordinate in viewport space
2538
+ * @param pageWidth - Width of the page in PDF units
2539
+ * @param pageHeight - Height of the page in PDF units
2540
+ * @param scale - Current zoom scale
2541
+ * @returns Percentage coordinates { x, y } (0-100)
2542
+ */
2543
+ declare function viewportToPercent(x: number, y: number, pageWidth: number, pageHeight: number, scale: number): {
2544
+ x: number;
2545
+ y: number;
2546
+ };
2547
+ /**
2548
+ * Apply rotation to coordinates.
2549
+ * Rotates point around the center of the page.
2550
+ *
2551
+ * @param x - X coordinate
2552
+ * @param y - Y coordinate
2553
+ * @param rotation - Rotation in degrees (0, 90, 180, 270)
2554
+ * @param pageWidth - Width of the page
2555
+ * @param pageHeight - Height of the page
2556
+ * @returns Rotated coordinates { x, y }
2557
+ */
2558
+ declare function applyRotation(x: number, y: number, rotation: number, pageWidth: number, pageHeight: number): {
2559
+ x: number;
2560
+ y: number;
2561
+ };
2562
+ /**
2563
+ * Remove rotation from coordinates.
2564
+ * Inverse of applyRotation.
2565
+ *
2566
+ * @param x - X coordinate
2567
+ * @param y - Y coordinate
2568
+ * @param rotation - Rotation in degrees (0, 90, 180, 270)
2569
+ * @param pageWidth - Width of the page (original, before rotation)
2570
+ * @param pageHeight - Height of the page (original, before rotation)
2571
+ * @returns Unrotated coordinates { x, y }
2572
+ */
2573
+ declare function removeRotation(x: number, y: number, rotation: number, pageWidth: number, pageHeight: number): {
2574
+ x: number;
2575
+ y: number;
2576
+ };
2577
+ /**
2578
+ * Calculate the bounding box dimensions after rotation.
2579
+ *
2580
+ * @param width - Original width
2581
+ * @param height - Original height
2582
+ * @param rotation - Rotation in degrees
2583
+ * @returns Rotated dimensions { width, height }
2584
+ */
2585
+ declare function getRotatedDimensions(width: number, height: number, rotation: number): {
2586
+ width: number;
2587
+ height: number;
2588
+ };
2589
+ /**
2590
+ * Convert a rectangle from one coordinate space to another.
2591
+ *
2592
+ * @param rect - Rectangle with x, y, width, height
2593
+ * @param fromScale - Source scale
2594
+ * @param toScale - Target scale
2595
+ * @returns Scaled rectangle
2596
+ */
2597
+ declare function scaleRect(rect: {
2598
+ x: number;
2599
+ y: number;
2600
+ width: number;
2601
+ height: number;
2602
+ }, fromScale: number, toScale: number): {
2603
+ x: number;
2604
+ y: number;
2605
+ width: number;
2606
+ height: number;
2607
+ };
2608
+ /**
2609
+ * Check if a point is inside a rectangle.
2610
+ *
2611
+ * @param point - Point coordinates { x, y }
2612
+ * @param rect - Rectangle { x, y, width, height }
2613
+ * @returns True if point is inside rectangle
2614
+ */
2615
+ declare function isPointInRect(point: {
2616
+ x: number;
2617
+ y: number;
2618
+ }, rect: {
2619
+ x: number;
2620
+ y: number;
2621
+ width: number;
2622
+ height: number;
2623
+ }): boolean;
2624
+ /**
2625
+ * Check if two rectangles intersect.
2626
+ *
2627
+ * @param rectA - First rectangle
2628
+ * @param rectB - Second rectangle
2629
+ * @returns True if rectangles intersect
2630
+ */
2631
+ declare function doRectsIntersect(rectA: {
2632
+ x: number;
2633
+ y: number;
2634
+ width: number;
2635
+ height: number;
2636
+ }, rectB: {
2637
+ x: number;
2638
+ y: number;
2639
+ width: number;
2640
+ height: number;
2641
+ }): boolean;
2642
+ /**
2643
+ * Get the intersection of two rectangles.
2644
+ *
2645
+ * @param rectA - First rectangle
2646
+ * @param rectB - Second rectangle
2647
+ * @returns Intersection rectangle or null if no intersection
2648
+ */
2649
+ declare function getRectIntersection(rectA: {
2650
+ x: number;
2651
+ y: number;
2652
+ width: number;
2653
+ height: number;
2654
+ }, rectB: {
2655
+ x: number;
2656
+ y: number;
2657
+ width: number;
2658
+ height: number;
2659
+ }): {
2660
+ x: number;
2661
+ y: number;
2662
+ width: number;
2663
+ height: number;
2664
+ } | null;
2665
+
2666
+ export { type AddNoteOptions, type AgentAPI, type AgentAPIInstance, type AgentAPIStores, type AgentActions, type AgentContext, type AgentHighlightParams, type AgentState, type AgentStore, type AgentStoreApi, type AgentToolResult, type AgentTools, type Annotation, type AnnotationActions, AnnotationLayer, type AnnotationLayerProps, type AnnotationState, type AnnotationStore, type AnnotationStoreApi, type AnnotationTool, AnnotationToolbar, type AnnotationToolbarProps, type AnnotationType, type AskAboutContext, AskAboutOverlay, type AskAboutOverlayProps, AskAboutTrigger, type AskAboutTriggerProps, type Bookmark, BookmarksPanel, type BookmarksPanelProps, CanvasLayer, type CanvasLayerProps, type CharPosition, type ContextMenuItem, ContinuousScrollContainer, type ContinuousScrollContainerProps, type CoordinateHelpers, DocumentContainer, type DocumentContainerProps, type DrawCircleOptions, type DrawRectOptions, type DrawingAnnotation, DrawingCanvas, type DrawingCanvasProps, type DrawingPath, DualPageContainer, type DualPageContainerProps, type ExportData, type FindTextOptions, FloatingZoomControls, type FloatingZoomControlsProps, FocusRegionLayer, type FocusRegionLayerProps, type FocusedRegion, type GoToPageOptions, type Highlight, type HighlightColor, HighlightLayer, type HighlightLayerProps, HighlightPopover, type HighlightPopoverProps, type HighlightRect, type HighlightTextOptions, HighlightsPanel, type HighlightsPanelProps, type LoadDocumentOptions, type LoadDocumentResult, Minimap, type MinimapProps, MobileSidebar, type MobileSidebarProps, MobileToolbar, type MobileToolbarProps, type NoteAnnotation, type OutlineItem, OutlinePanel, type OutlinePanelProps, type PDFDocumentLoadedEvent, PDFErrorBoundary, type PDFErrorBoundaryProps, PDFPage, type PDFPageProps, type PDFPageState, type PDFRegion, PDFThumbnailNav, type PDFThumbnailNavProps, PDFViewer, PDFViewerClient, PDFViewerContext, type PDFViewerContextValue, type PDFViewerController, type PDFViewerControllerOptions, type PDFViewerEventMap, type PDFViewerHandle, type PDFViewerProps, PDFViewerProvider, type PDFViewerProviderProps, type PageCoordinates, type PageDimensions, type PageDimensionsInfo, type Plugin, type PluginAPI, PluginManager, type PluginManagerOptions, type QuickNote, QuickNoteButton, type QuickNoteButtonProps, QuickNotePopover, type QuickNotePopoverProps, type ScrollMode, type ScrollToPageRequest, type SearchActions, type SearchAndHighlightOptions, type SearchAndHighlightResult, type SearchOptions, SearchPanel, type SearchPanelProps, type SearchResult, type SearchState, type SearchStore, type SearchStoreApi, SelectionToolbar, type SelectionToolbarProps, type ShapeAnnotation, ShapePreview, type ShapePreviewProps, ShapeRenderer, type ShapeRendererProps, type ShapeType, Sidebar, type SidebarPanel, type SidebarPanelConfig, type SidebarProps, StickyNote, type StickyNoteProps, type StoredStudentData, type StudentActions, type StudentData, type StudentModeCallbacks, type StudentModeProps, type StudentState, type StudentStore, type StudentStoreApi, type Takeaway, TakeawaysPanel, type TakeawaysPanelProps, TextLayer, type TextLayerProps, type TextMatch, type TextSelection, type Theme, ThumbnailPanel, type ThumbnailPanelProps, Toolbar, type ToolbarItem, type ToolbarProps, type UseAgentContextOptions, type UseAgentContextReturn, type UseAnnotationsOptions, type UseAnnotationsReturn, type UseAskAboutOptions, type UseAskAboutReturn, type UseBookmarksOptions, type UseBookmarksReturn, type UseHighlightsOptions, type UseHighlightsReturn, type UsePageNavigationOptions, type UsePluginsOptions, type UsePluginsReturn, type UseQuickNotesOptions, type UseQuickNotesReturn, type UseStudentProgressOptions, type UseStudentProgressReturn, type UseTextSelectionOptions, type UseTouchGesturesOptions, type UseZoomOptions, type ViewMode, type ViewerActions, type ViewerState, type ViewerStore, type ViewerStoreApi, VirtualizedDocumentContainer, type VirtualizedDocumentContainerProps, type WithErrorBoundaryProps, applyRotation, clearHighlights, clearStudentData, cn, countTextOnPage, createAgentAPI, createAgentStore, createAnnotationStore, createPDFViewer, createPluginManager, createSearchStore, createStudentStore, createViewerStore, doRectsIntersect, downloadAnnotationsAsJSON, downloadAnnotationsAsMarkdown, downloadFile, exportAnnotationsAsJSON, exportAnnotationsAsMarkdown, exportHighlightsAsJSON, exportHighlightsAsMarkdown, extractPageText, findTextInDocument, findTextOnPage, generateDocumentId, getAllDocumentIds, getAllStudentDataDocumentIds, getMetadata, getOutline, getPage, getPageText, getPageTextContent, getPluginManager, getRectIntersection, getRotatedDimensions, getStorageStats, importHighlightsFromJSON, initializePDFJS, isPDFJSInitialized, isPointInRect, loadDocument, loadHighlights, loadStudentData, mergeAdjacentRects, pdfToPercent, pdfToViewport, percentToPDF, percentToViewport, quickViewer, removeRotation, saveHighlights, saveStudentData, scaleRect, useAgentContext, useAgentStore, useAnnotationStore, useAnnotations, useAskAbout, useBookmarks, useHighlights, useIsMobile, useIsTouchDevice, usePDFViewer, usePDFViewerStores, usePageNavigation, usePlugins, useQuickNotes, useSearchStore, useStudentProgress, useStudentStore, useTextSelection, useTouchGestures, useViewerStore, useZoom, viewportToPDF, viewportToPercent, withErrorBoundary };