Syncfusion React Pdfviewer – UI Sample Generator
Target package: @syncfusion/ej2-react-pdfviewer
Generate Code for the User's Project (default)
Trigger keywords: "how to", "add pdfviewer", "code sample", "show me", "example", "snippet", "integrate", "component", "create sample", "react sample".
Purpose: Generate minimal, copy-pasteable TS and HTML code that the user can integrate directly into their React project.
Workflow:
⚠️ CRITICAL — Feature Support Policy (STRICT MODE):
FUNDAMENTAL RULE: Only generate code using APIs and properties that are EXPLICITLY listed in the reference files. ANY deviation is a VIOLATION.
MANDATORY CHECKS BEFORE GENERATING ANY CODE:
- Search the reference files for the exact API/property name
- Verify it appears in the Method Reference, Properties, or Events tables
- If NOT found in ANY reference file, STOP immediately
- Do NOT generate or suggest undocumented APIs under any circumstances
STRICT ENFORCEMENT - ZERO TOLERANCE:
- NO custom properties - Only use properties from reference file tables
- NO invented methods - Only use methods from reference file tables
- NO workarounds with undefined APIs - Forbidden
- NO assumptions about undocumented behavior - Forbidden
- NO alternative implementations using guess-work - Forbidden
- NO pretending support exists - Forbidden
MANDATORY RESPONSE FOR UNSUPPORTED FEATURES:
REFERENCE FILE HIERARCHY:
- Each reference file contains complete, authoritative documentation for its domain
- The tables (Method Reference, Properties, Events) are the SOURCE OF TRUTH
- Content outside these tables in reference files is explanatory only
- Do NOT extend beyond what appears in the reference file tables
AUDIT YOUR GENERATION:
- Before providing any code, verify EVERY API used appears in a reference file table
- Document which reference file each API comes from
- If you cannot cite a reference file table entry, DELETE that code
This is a CRITICAL REQUIREMENT. Violations compromise the skill's integrity and reliability.
Step 1 — Detect the Application Type (REQUIRED - DO NOT SKIP)
- Use file_search and read_file tools to inspect workspace project files:
package.json (project configuration and dependencies)
tsconfig.json (TypeScript configuration)
App.tsx or App.jsx (root component)
vite.config.ts or webpack.config.js (build configuration)
- Any existing
.tsx or .jsx files in src/ folder
- Output: Confirm the detected application type is a React TypeScript or JavaScript project before proceeding.
Step 2 — Generate Code from Reference Files Only (REQUIRED)
- Before generating: Confirm that Steps 1 are complete
- Read the relevant
references/*.md file(s) for the requested feature
- Cross-reference EVERY API, property, and method against these tables
- COMPONENT-BASED APPROACH (MANDATORY - REACT PATTERNS ONLY):
- Use JSX/TSX syntax for React component composition
- Configure all PDF Viewer properties directly as component props
- Use React hooks (useState, useRef, useEffect) when programmatic access is needed
- MANDATORY: Before generating ANY code, verify that reference files exist and are accessible
- Read the appropriate reference file(s) for the requested feature:
- Use
read_file tool on relevant references/*.md files
- Confirm file contains Methods/Properties/Events tables
- Verify tables are complete and readable
- If reference file is missing or cannot be read:
- STOP code generation
- Respond: "Reference file for this feature is not available. Please ensure all reference files are present in the
references/ directory."
- List the missing reference file name
- This is a BLOCKER step: Cannot proceed without reference file validation
- If an API/property does NOT appear in the reference file table, DO NOT USE IT
- Do NOT invent, guess, or suggest any API, method, property, class, or namespace not explicitly present in the reference files
Reference File Routing Guide
All templates and operation snippets live in references/*.md. Each file is a focused snippet or template the agent will combine when generating samples.
Flow: Always start with getting-started.md, then merge matched features into its anchors (PROPS, EVENTS, UI_BUTTONS, HANDLERS). If no keyword matches, return only the basic sample.
Checklist Before Generating Code
🎯 Core Setup & Configuration
| File |
Purpose |
Route When User Asks About |
| getting-started.md |
Minimal PDFViewer with documentPath, height, and width. Base template for all samples. |
"basic setup", "minimal example", "getting started", "how to load PDF" |
| general-properties.md |
Configure core viewer properties (server URL, document path, locale, resource base path). |
"configuration", "server settings", "locale", "document path setup" |
| enable-properties.md |
Enable/disable specific features (toolbar, annotations, forms, navigation, text selection, download, print). |
"disable toolbar", "hide features", "enable/disable", "read-only mode", "restrict features" |
📐 Navigation() & Page Management
| File |
Purpose |
Route When User Asks About |
| page-navigation.md |
Navigate between pages (first, last, next, previous page), go to specific page numbers. |
"page navigation", "go to page", "next page", "previous page", "jump to page" |
| bookmark-navigation.md |
Navigate using PDF bookmarks/table of contents in the bookmark panel. CRITICAL: All bookmark methods MUST be accessed via viewerRef.current.bookmark.* (e.g., viewerRef.current.bookmark.openBookmarkPane()), NOT directly on viewerRef.current |
"bookmarks", "bookmark", "table of contents", "TOC navigation", "outline panel", "get bookmarks", "retrieve bookmarks", "fetch bookmarks", "bookmarks programmatically", "getBookmarks", "goToBookmark", "bookmark API", "list bookmarks", "open bookmark", "close bookmark" |
| hyperlink-navigation.md |
Configure hyperlink navigation behavior and external link handling in PDFs. |
"hyperlinks", "external links", "URL navigation", "clickable links", "url", "link" |
| thumbnail-navigation.md |
Display and navigate using page thumbnails in the thumbnail panel. |
"thumbnails", "preview pages", "thumbnail panel", "thumbnail","page previews" |
🔍 Viewing & Interaction
| File |
Purpose |
Route When User Asks About |
| magnification.md |
Configure zoom levels, zoom modes, and magnification controls (fit-to-page, fit-to-width). |
"zoom", "magnification", "fit to page", "zoom levels", "scale document" |
| interaction-mode.md |
Switch between Selection mode (text selection) and Panning mode (touch scrolling). |
"text selection", "panning", "scroll mode", "interaction mode", "touch navigation" |
| text-selection.md |
Enable text selection, copying text, and text selection events. |
"select text", "copy text", "highlight text to copy", "text selection mode" |
| text-search.md |
Implement text search functionality with search options and navigation. |
"search text", "find in PDF", "search functionality", "highlight search results" |
🛠️ Toolbar & Context Menu
Toolbar Configuration
| File |
Purpose |
Route When User Asks About |
| toolbar-settings.md |
Configure toolbar visibility, tooltip behavior, and customize/remove toolbar items. |
"customize toolbar", "hide toolbar items", "remove toolbar buttons", "toolbar configuration" |
| toolbar-methods.md |
Programmatically show/hide toolbars and enable/disable toolbar items at runtime. |
"show/hide toolbar dynamically", "toggle toolbar", "enable/disable toolbar items programmatically" |
⚠️ STRICT VALIDATION FOR TOOLBAR ITEM NAMES
When generating toolbar configurations, you MUST follow these rules to prevent incorrect toolbar item names:
ALWAYS reference exact item names from toolbar-settings.md
- Do NOT invent, guess, or assume toolbar item names
- Do NOT apply naming pattern logic to derive names
- Use ONLY names listed in the "Available Primary Toolbar Items", "Available Annotation Toolbar Items", and "Available Form Designer Items" sections in
toolbar-settings.md
VALIDATE item names character-by-character
- Case sensitivity matters:
HighlightTool ≠ HighlightOption
- Exact names only:
AnnotationEditTool ≠ AnotatetionEditTool
- No abbreviations or shortcuts
Before generating toolbar configuration code:
Common errors to prevent:
- ❌
AnotatetionEditTool → ✅ AnnotationEditTool (typo)
- ❌
CalibrationOption → ✅ CalibrateTool (wrong suffix)
- ❌
ShapeAnnotationOption → ✅ ShapeTool (annotation toolbar version)
- ❌
InkAnnotationOption → ✅ InkAnnotationTool (annotation toolbar version)
- For complete list of mistakes to avoid, see
toolbar-settings.md "❌ COMMON MISTAKES TO AVOID" table
Context Menu Customization
| File |
Purpose |
Route When User Asks About |
| contextmenu.md |
Customize context menu items and handle context menu events. |
"right-click menu", "context menu", "custom context menu", "disable context menu items" |
📝 Annotations
| File |
Purpose |
Route When User Asks About |
| annotation-settings.md |
Configure annotation appearance (colors, opacity, styles) and behavior for all annotation types. |
"annotation colors", "annotation styles", "customize annotation appearance", "annotation defaults" |
| annotation-events.md |
Handle annotation lifecycle events (add, delete, move, resize, select, property change). |
"annotation events", "when annotation is added", "annotation change detection", "annotation callbacks" |
| shape-label-settings.md |
Customize shape and measure annotation labels (position, color, font, visibility). |
"annotation labels", "shape labels", "measurement labels", "label customization" |
| redaction-annotation.md |
Create, configure, and apply redaction annotations to permanently remove sensitive content. |
"redaction", "redact content", "remove sensitive data", "black out text", "permanent removal" |
📄 Forms
| File |
Purpose |
Route When User Asks About |
| form-field-settings.md |
Configure default properties for form fields (text, checkbox, radio, dropdown, signature). |
"form field defaults", "form field styles", "configure form fields", "form field properties" |
| form-field-events.md |
Handle form field interaction events (focus, blur, value change, validation). |
"form field events", "when field changes", "form validation events", "field interaction callbacks" |
📋 Document Actions
| File |
Purpose |
Route When User Asks About |
| download.md |
Enable/configure PDF download functionality with custom filenames. |
"download PDF", "save PDF", "export document", "download button" |
| print.md |
Configure and trigger PDF printing functionality. |
"print PDF", "print document", "printing options", "print button" |
| organize-pages.md |
Reorder, rotate, insert, remove, copy, import, and extract PDF pages. |
"reorder pages", "rotate pages", "add blank pages", "remove pages", "rearrange pages", "merge PDFs" |
⚙️ Advanced Features
| File |
Purpose |
Route When User Asks About |
| api-methods.md |
Programmatic control: load documents, manage forms, annotations, extract text, undo/redo, navigation APIs. |
"load PDF programmatically", "API methods", "export form data", "extract text", "undo/redo", "programmatic control" |
| events.md |
Complete list of all PDFViewer events (document load, download, annotations, forms, search, navigation). |
"event list", "all events", "available events", "event reference", "event handlers" |
Quick Start Example
import * as ReactDOM from 'react-dom/client';
import * as React from 'react';
import './index.css';
import {
PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation,
BookmarkView, ThumbnailView, Print, TextSelection, Annotation, TextSearch,
FormFields, FormDesigner, Inject
} from '@syncfusion/ej2-react-pdfviewer';
function App() {
return (
<div>
<div className='control-section'>
<PdfViewerComponent
id="container"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
style={{ 'height': '640px' }}>
<Inject services={[
Toolbar, Magnification, Navigation, Annotation, LinkAnnotation,
BookmarkView, ThumbnailView, Print, TextSelection, TextSearch,
FormFields, FormDesigner
]} />
</PdfViewerComponent>
</div>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById('sample'));
root.render(<App />);
⚙️ SETTINGS CONFIGURATION BEST PRACTICES
When generating code with settings (toolbarSettings, annotationSettings, annotationSelectorSettings, arrowSettings, rectangleSettings, etc.), follow these guidelines to prevent unnecessary imports and over-engineering:
Rule 1: Simple Settings → Define INLINE in Component Props
Use this approach when:
- Configuring only 1-3 properties
- Settings are straightforward without complex enums or custom types
- No need for TypeScript typed constants
Example (DO THIS):
<PdfViewerComponent
id="container"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
annotationSelectorSettings={{
selectionBorderColor: '#0000ff',
selectionBorderThickness: 2,
resizerBorderColor: '#ff0000',
resizerFillColor: '#4070ff',
resizerSize: 8,
}}
style={{ height: '640px' }}
>
<Inject services={[Annotation]} />
</PdfViewerComponent>
Benefits:
- ✅ No extra imports needed
- ✅ Simple and readable
- ✅ Less code clutter
- ✅ Type checking still works
Rule 2: Complex Settings → Define as Typed Constant (OUTSIDE component)
Use this approach when:
- Configuring 4+ properties OR multiple related settings
- Using enums or complex configurations
- Need to reuse the same configuration across multiple components
- Settings are complex enough to warrant separate definition
Example (DO THIS ONLY FOR COMPLEX CASES):
import { PdfViewerComponent, Inject, Annotation } from '@syncfusion/ej2-react-pdfviewer';
import type { AnnotationSelectorSettingsModel } from '@syncfusion/ej2-react-pdfviewer';
import { AnnotationResizerLocation, CursorType } from '@syncfusion/ej2-react-pdfviewer';
// Define constant OUTSIDE component with proper types and enums
const annotationSelectorConfig: AnnotationSelectorSettingsModel = {
selectionBorderColor: '#0000ff',
selectionBorderThickness: 2,
resizerBorderColor: '#ff0000',
resizerFillColor: '#4070ff',
resizerSize: 8,
resizerShape: 'Square',
selectorLineDashArray: [5, 6],
resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges,
resizerCursorType: CursorType.grab,
};
export function App() {
return (
<PdfViewerComponent
id="container"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
annotationSelectorSettings={annotationSelectorConfig}
style={{ height: '640px' }}
>
<Inject services={[Annotation]} />
</PdfViewerComponent>
);
}
When to import types and enums:
Benefits:
- ✅ Type-safe configuration
- ✅ Proper enum usage
- ✅ Reusable across multiple components
- ✅ Clean component code
Rule 3: NEVER Over-Engineer Simple Cases
❌ DO NOT DO THIS (Over-engineered):
import { PdfViewerComponent, Inject, Annotation } from '@syncfusion/ej2-react-pdfviewer';
import type { ToolbarSettingsModel } from '@syncfusion/ej2-react-pdfviewer';
// Unnecessary constant for 2 simple properties
const toolbarSettings: ToolbarSettingsModel = {
showTooltip: true,
};
export function App() {
return (
<PdfViewerComponent
toolbarSettings={toolbarSettings}
// ... rest of props
/>
);
}
✅ DO THIS INSTEAD (Simple & Clean):
<PdfViewerComponent
toolbarSettings={{ showTooltip: true }}
// ... rest of props
/>
1---2name: syncfusion-react-pdf-viewer3description: Implements the Syncfusion React PDF Viewer (PdfViewerComponent) for embedding, configuring, and loading PDF documents. Use this when rendering PDFs in a React application, embedding viewer controls, or generating TSX/HTML code for PDF display and interaction.4---56# Syncfusion React Pdfviewer – UI Sample Generator78Target package: `@syncfusion/ej2-react-pdfviewer`910## Generate Code for the User's Project *(default)*1112**Trigger keywords:** "how to", "add pdfviewer", "code sample", "show me", "example", "snippet", "integrate", "component", "create sample", "react sample".1314**Purpose:** Generate minimal, copy-pasteable TS and HTML code that the user can integrate directly into their React project.1516**Workflow:**17**⚠️ CRITICAL — Feature Support Policy (STRICT MODE):**18 19**FUNDAMENTAL RULE:** Only generate code using APIs and properties that are EXPLICITLY listed in the reference files. ANY deviation is a VIOLATION.20 21- **MANDATORY CHECKS BEFORE GENERATING ANY CODE:**22 1. Search the reference files for the exact API/property name23 2. Verify it appears in the Method Reference, Properties, or Events tables24 3. If NOT found in ANY reference file, STOP immediately25 4. Do NOT generate or suggest undocumented APIs under any circumstances26 27- **STRICT ENFORCEMENT - ZERO TOLERANCE:**28 - **NO custom properties** - Only use properties from reference file tables29 - **NO invented methods** - Only use methods from reference file tables30 - **NO workarounds with undefined APIs** - Forbidden31 - **NO assumptions** about undocumented behavior - Forbidden32 - **NO alternative implementations** using guess-work - Forbidden33 - **NO pretending support exists** - Forbidden34 35- **MANDATORY RESPONSE FOR UNSUPPORTED FEATURES:**36 - **If a requested scenario/feature/API is NOT listed in any reference file, you MUST respond with:**37 ```38 "This feature is not supported in the current Syncfusion React PDF Viewer implementation."39 ```40 - **Then list what IS supported** from the appropriate reference file41 - **Never suggest alternatives** unless explicitly documented in reference files42 43- **REFERENCE FILE HIERARCHY:**44 - Each reference file contains complete, authoritative documentation for its domain45 - The tables (Method Reference, Properties, Events) are the SOURCE OF TRUTH46 - Content outside these tables in reference files is explanatory only47 - Do NOT extend beyond what appears in the reference file tables48 49- **AUDIT YOUR GENERATION:**50 - Before providing any code, verify EVERY API used appears in a reference file table51 - Document which reference file each API comes from52 - If you cannot cite a reference file table entry, DELETE that code53 54- **This is a CRITICAL REQUIREMENT.** Violations compromise the skill's integrity and reliability.55 56#### Step 1 — Detect the Application Type *(REQUIRED - DO NOT SKIP)*57- **Use file_search and read_file tools to inspect workspace project files:**58 - `package.json` (project configuration and dependencies)59 - `tsconfig.json` (TypeScript configuration)60 - `App.tsx` or `App.jsx` (root component)61 - `vite.config.ts` or `webpack.config.js` (build configuration)62 - Any existing `.tsx` or `.jsx` files in src/ folder63- **Output:** Confirm the detected application type is a React TypeScript or JavaScript project before proceeding.64 65#### Step 2 — Generate Code from Reference Files Only *(REQUIRED)*66- **Before generating:** Confirm that Steps 1 are complete67- Read the relevant `references/*.md` file(s) for the requested feature68- Cross-reference EVERY API, property, and method against these tables69- **COMPONENT-BASED APPROACH (MANDATORY - REACT PATTERNS ONLY):**70 - Use JSX/TSX syntax for React component composition71 - Configure all PDF Viewer properties directly as component props72 - Use React hooks (useState, useRef, useEffect) when programmatic access is needed73- **MANDATORY:** Before generating ANY code, verify that reference files exist and are accessible74- **Read the appropriate reference file(s)** for the requested feature:75 - Use `read_file` tool on relevant `references/*.md` files76 - Confirm file contains Methods/Properties/Events tables77 - Verify tables are complete and readable78- **If reference file is missing or cannot be read:**79 - STOP code generation80 - Respond: "Reference file for this feature is not available. Please ensure all reference files are present in the `references/` directory."81 - List the missing reference file name82- **This is a BLOCKER step:** Cannot proceed without reference file validation83- If an API/property does NOT appear in the reference file table, DO NOT USE IT84- Do NOT invent, guess, or suggest any API, method, property, class, or namespace not explicitly present in the reference files85 86---8788## Reference File Routing Guide8990All templates and operation snippets live in `references/*.md`. Each file is a focused snippet or template the agent will combine when generating samples.9192**Flow:** Always start with [getting-started.md](references/getting-started.md), then merge matched features into its anchors (PROPS, EVENTS, UI_BUTTONS, HANDLERS). If no keyword matches, return only the basic sample.9394### Checklist Before Generating Code9596- [ ] **Count the settings properties:** 1-3? → Use inline | 4+? → Use constant97- [ ] **Are enums involved?** Yes → Must use typed constant with imports | No → Can use inline98- [ ] **Is it reused elsewhere?** Yes → Use constant | No → Prefer inline99- [ ] **Do I need type safety?** Yes → Import `type { SettingsModel }` | No → Skip type import100- [ ] **Do I need enums?** Yes → Import required enums | No → Skip enum imports101- [ ] **Is the component prop simple enough?** Yes → Keep inline | No → Extract to constant102103### 🎯 Core Setup & Configuration104105| File | Purpose | **Route When User Asks About** |106|---|---|---|107| [getting-started.md](references/getting-started.md) | Minimal PDFViewer with documentPath, height, and width. Base template for all samples. | "basic setup", "minimal example", "getting started", "how to load PDF" |108| [general-properties.md](references/general-properties.md) | Configure core viewer properties (server URL, document path, locale, resource base path). | "configuration", "server settings", "locale", "document path setup" |109| [enable-properties.md](references/enable-properties.md) | Enable/disable specific features (toolbar, annotations, forms, navigation, text selection, download, print). | "disable toolbar", "hide features", "enable/disable", "read-only mode", "restrict features" |110111### 📐 Navigation() & Page Management112113| File | Purpose | **Route When User Asks About** |114|---|---|---|115| [page-navigation.md](references/page-navigation.md) | Navigate between pages (first, last, next, previous page), go to specific page numbers. | "page navigation", "go to page", "next page", "previous page", "jump to page" |116| [bookmark-navigation.md](references/bookmark-navigation.md) | Navigate using PDF bookmarks/table of contents in the bookmark panel. **CRITICAL: All bookmark methods MUST be accessed via `viewerRef.current.bookmark.*` (e.g., `viewerRef.current.bookmark.openBookmarkPane()`), NOT directly on `viewerRef.current`** | "bookmarks", "bookmark", "table of contents", "TOC navigation", "outline panel", "get bookmarks", "retrieve bookmarks", "fetch bookmarks", "bookmarks programmatically", "getBookmarks", "goToBookmark", "bookmark API", "list bookmarks", "open bookmark", "close bookmark" |117| [hyperlink-navigation.md](references/hyperlink-navigation.md) | Configure hyperlink navigation behavior and external link handling in PDFs. | "hyperlinks", "external links", "URL navigation", "clickable links", "url", "link" |118| [thumbnail-navigation.md](references/thumbnail-navigation.md) | Display and navigate using page thumbnails in the thumbnail panel. | "thumbnails", "preview pages", "thumbnail panel", "thumbnail","page previews" |119120### 🔍 Viewing & Interaction121122| File | Purpose | **Route When User Asks About** |123|---|---|---|124| [magnification.md](references/magnification.md) | Configure zoom levels, zoom modes, and magnification controls (fit-to-page, fit-to-width). | "zoom", "magnification", "fit to page", "zoom levels", "scale document" |125| [interaction-mode.md](references/interaction-mode.md) | Switch between Selection mode (text selection) and Panning mode (touch scrolling). | "text selection", "panning", "scroll mode", "interaction mode", "touch navigation" |126| [text-selection.md](references/text-selection.md) | Enable text selection, copying text, and text selection events. | "select text", "copy text", "highlight text to copy", "text selection mode" |127| [text-search.md](references/text-search.md) | Implement text search functionality with search options and navigation. | "search text", "find in PDF", "search functionality", "highlight search results" |128129### 🛠️ Toolbar & Context Menu130131#### Toolbar Configuration132133| File | Purpose | **Route When User Asks About** |134|---|---|---|135| [toolbar-settings.md](references/toolbar-settings.md) | Configure toolbar visibility, tooltip behavior, and customize/remove toolbar items. | "customize toolbar", "hide toolbar items", "remove toolbar buttons", "toolbar configuration" |136| [toolbar-methods.md](references/toolbar-methods.md) | Programmatically show/hide toolbars and enable/disable toolbar items at runtime. | "show/hide toolbar dynamically", "toggle toolbar", "enable/disable toolbar items programmatically" |137138##### ⚠️ STRICT VALIDATION FOR TOOLBAR ITEM NAMES139140**When generating toolbar configurations, you MUST follow these rules to prevent incorrect toolbar item names:**1411421. **ALWAYS reference exact item names from `toolbar-settings.md`**143 - Do NOT invent, guess, or assume toolbar item names144 - Do NOT apply naming pattern logic to derive names145 - Use ONLY names listed in the "Available Primary Toolbar Items", "Available Annotation Toolbar Items", and "Available Form Designer Items" sections in `toolbar-settings.md`1461472. **VALIDATE item names character-by-character**148 - Case sensitivity matters: `HighlightTool` ≠ `HighlightOption`149 - Exact names only: `AnnotationEditTool` ≠ `AnotatetionEditTool`150 - No abbreviations or shortcuts1511523. **Before generating toolbar configuration code:**153 - [ ] Open `toolbar-settings.md` reference file154 - [ ] Locate: "Available Primary Toolbar Items" section155 - [ ] Locate: "Available Annotation Toolbar Items" section156 - [ ] Locate: "Available Form Designer Items" section157 - [ ] Copy exact names from THESE SECTIONS ONLY158 - [ ] Cross-check every single item name character-by-character159 - [ ] If ANY item name is not in the reference sections, DO NOT USE IT160 - [ ] Consult the "❌ COMMON MISTAKES TO AVOID" table in `toolbar-settings.md` if unsure1611624. **Common errors to prevent:**163 - ❌ `AnotatetionEditTool` → ✅ `AnnotationEditTool` (typo)164 - ❌ `CalibrationOption` → ✅ `CalibrateTool` (wrong suffix)165 - ❌ `ShapeAnnotationOption` → ✅ `ShapeTool` (annotation toolbar version)166 - ❌ `InkAnnotationOption` → ✅ `InkAnnotationTool` (annotation toolbar version)167 - For complete list of mistakes to avoid, see `toolbar-settings.md` "❌ COMMON MISTAKES TO AVOID" table168169#### Context Menu Customization170171| File | Purpose | **Route When User Asks About** |172|---|---|---|173| [contextmenu.md](references/contextmenu.md) | Customize context menu items and handle context menu events. | "right-click menu", "context menu", "custom context menu", "disable context menu items" |174175### 📝 Annotations176177| File | Purpose | **Route When User Asks About** |178|---|---|---|179| [annotation-settings.md](references/annotation-settings.md) | Configure annotation appearance (colors, opacity, styles) and behavior for all annotation types. | "annotation colors", "annotation styles", "customize annotation appearance", "annotation defaults" |180| [annotation-events.md](references/annotation-events.md) | Handle annotation lifecycle events (add, delete, move, resize, select, property change). | "annotation events", "when annotation is added", "annotation change detection", "annotation callbacks" |181| [shape-label-settings.md](references/shape-label-settings.md) | Customize shape and measure annotation labels (position, color, font, visibility). | "annotation labels", "shape labels", "measurement labels", "label customization" |182| [redaction-annotation.md](references/redaction-annotation.md) | Create, configure, and apply redaction annotations to permanently remove sensitive content. | "redaction", "redact content", "remove sensitive data", "black out text", "permanent removal" |183184### 📄 Forms185186| File | Purpose | **Route When User Asks About** |187|---|---|---|188| [form-field-settings.md](references/form-field-settings.md) | Configure default properties for form fields (text, checkbox, radio, dropdown, signature). | "form field defaults", "form field styles", "configure form fields", "form field properties" |189| [form-field-events.md](references/form-field-events.md) | Handle form field interaction events (focus, blur, value change, validation). | "form field events", "when field changes", "form validation events", "field interaction callbacks" |190191### 📋 Document Actions192193| File | Purpose | **Route When User Asks About** |194|---|---|---|195| [download.md](references/download.md) | Enable/configure PDF download functionality with custom filenames. | "download PDF", "save PDF", "export document", "download button" |196| [print.md](references/print.md) | Configure and trigger PDF printing functionality. | "print PDF", "print document", "printing options", "print button" |197| [organize-pages.md](references/organize-pages.md) | Reorder, rotate, insert, remove, copy, import, and extract PDF pages. | "reorder pages", "rotate pages", "add blank pages", "remove pages", "rearrange pages", "merge PDFs" |198199### ⚙️ Advanced Features200201| File | Purpose | **Route When User Asks About** |202|---|---|---|203| [api-methods.md](references/api-methods.md) | Programmatic control: load documents, manage forms, annotations, extract text, undo/redo, navigation APIs. | "load PDF programmatically", "API methods", "export form data", "extract text", "undo/redo", "programmatic control" |204| [events.md](references/events.md) | Complete list of all PDFViewer events (document load, download, annotations, forms, search, navigation). | "event list", "all events", "available events", "event reference", "event handlers" |205206## Quick Start Example207208```tsx209import * as ReactDOM from 'react-dom/client';210import * as React from 'react';211import './index.css';212import { 213 PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation, 214 BookmarkView, ThumbnailView, Print, TextSelection, Annotation, TextSearch, 215 FormFields, FormDesigner, Inject 216} from '@syncfusion/ej2-react-pdfviewer';217218function App() {219 return (220 <div>221 <div className='control-section'>222 <PdfViewerComponent223 id="container"224 documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"225 style={{ 'height': '640px' }}>226 <Inject services={[ 227 Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, 228 BookmarkView, ThumbnailView, Print, TextSelection, TextSearch, 229 FormFields, FormDesigner 230 ]} />231 </PdfViewerComponent>232 </div>233 </div>234 );235}236237const root = ReactDOM.createRoot(document.getElementById('sample'));238root.render(<App />);239```240241## ⚙️ SETTINGS CONFIGURATION BEST PRACTICES242243**When generating code with settings (toolbarSettings, annotationSettings, annotationSelectorSettings, arrowSettings, rectangleSettings, etc.), follow these guidelines to prevent unnecessary imports and over-engineering:**244245### Rule 1: Simple Settings → Define INLINE in Component Props246247**Use this approach when:**248- Configuring only 1-3 properties249- Settings are straightforward without complex enums or custom types250- No need for TypeScript typed constants251252**Example (DO THIS):**253```tsx254<PdfViewerComponent255 id="container"256 documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"257 annotationSelectorSettings={{258 selectionBorderColor: '#0000ff',259 selectionBorderThickness: 2,260 resizerBorderColor: '#ff0000',261 resizerFillColor: '#4070ff',262 resizerSize: 8,263 }}264 style={{ height: '640px' }}265>266 <Inject services={[Annotation]} />267</PdfViewerComponent>268```269270**Benefits:**271- ✅ No extra imports needed272- ✅ Simple and readable273- ✅ Less code clutter274- ✅ Type checking still works275276---277278### Rule 2: Complex Settings → Define as Typed Constant (OUTSIDE component)279280**Use this approach when:**281- Configuring 4+ properties OR multiple related settings282- Using enums or complex configurations283- Need to reuse the same configuration across multiple components284- Settings are complex enough to warrant separate definition285286**Example (DO THIS ONLY FOR COMPLEX CASES):**287288```tsx289import { PdfViewerComponent, Inject, Annotation } from '@syncfusion/ej2-react-pdfviewer';290import type { AnnotationSelectorSettingsModel } from '@syncfusion/ej2-react-pdfviewer';291import { AnnotationResizerLocation, CursorType } from '@syncfusion/ej2-react-pdfviewer';292293// Define constant OUTSIDE component with proper types and enums294const annotationSelectorConfig: AnnotationSelectorSettingsModel = {295 selectionBorderColor: '#0000ff',296 selectionBorderThickness: 2,297 resizerBorderColor: '#ff0000',298 resizerFillColor: '#4070ff',299 resizerSize: 8,300 resizerShape: 'Square',301 selectorLineDashArray: [5, 6],302 resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges,303 resizerCursorType: CursorType.grab,304};305306export function App() {307 return (308 <PdfViewerComponent309 id="container"310 documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"311 annotationSelectorSettings={annotationSelectorConfig}312 style={{ height: '640px' }}313 >314 <Inject services={[Annotation]} />315 </PdfViewerComponent>316 );317}318```319320**When to import types and enums:**321- [ ] Import `type { SettingsNameModel }` for TypeScript type checking322- [ ] Import any enums that are used in the settings (e.g., `AnnotationResizerLocation`, `CursorType`)323- [ ] Keep imports minimal - import ONLY what is used in the settings324325**Benefits:**326- ✅ Type-safe configuration327- ✅ Proper enum usage328- ✅ Reusable across multiple components329- ✅ Clean component code330331---332333### Rule 3: NEVER Over-Engineer Simple Cases334335**❌ DO NOT DO THIS (Over-engineered):**336```tsx337import { PdfViewerComponent, Inject, Annotation } from '@syncfusion/ej2-react-pdfviewer';338import type { ToolbarSettingsModel } from '@syncfusion/ej2-react-pdfviewer';339340// Unnecessary constant for 2 simple properties341const toolbarSettings: ToolbarSettingsModel = {342 showTooltip: true,343};344345export function App() {346 return (347 <PdfViewerComponent348 toolbarSettings={toolbarSettings}349 // ... rest of props350 />351 );352}353```354355**✅ DO THIS INSTEAD (Simple & Clean):**356```tsx357<PdfViewerComponent358 toolbarSettings={{ showTooltip: true }}359 // ... rest of props360/>361```362363---