Syncfusion TypeScript PdfViewer – UI Sample Generator
Generate Code for the User's Project (default)
Trigger keywords: "how to", "add pdfviewer", "code sample", "show me", "example", "snippet", "integrate", "component", "create sample", "typescript sample".
Purpose: Generate minimal, copy-pasteable TypeScript (.ts) and HTML code that the user can integrate directly into their TypeScript EJ2 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 (check for @syncfusion/ej2-pdfviewer or @syncfusion/ej2 dependency)
tsconfig.json (TypeScript configuration)
webpack.config.js (EJ2 quickstart uses webpack)
src/index.ts or src/app.ts (main TypeScript entry point)
src/index.html (HTML container file)
- Output: Confirm the detected application type is a TypeScript EJ2 webpack project (NOT a React/Vue/Angular project) before proceeding.
- CRITICAL: This skill generates vanilla TypeScript code using the EJ2
PdfViewer class. Do NOT generate React, Angular, or Vue component code.
Step 2 — Generate Code from Reference Files Only (REQUIRED)
- Before generating: Confirm that Step 1 is complete
- Read the relevant
references/*.md file(s) for the requested feature
- Cross-reference EVERY API, property, and method against these tables
- CLASS-BASED APPROACH (MANDATORY - TypeScript EJ2 PATTERNS ONLY):
- Import
PdfViewer and required module classes from @syncfusion/ej2-pdfviewer
- Use
PdfViewer.Inject(...) to inject required feature modules
- Instantiate with
new PdfViewer({ ... }) or new PdfViewer() and set properties
- Mount to DOM using
viewer.appendTo('#ElementId')
- NEVER use JSX, TSX, React hooks, or component-based syntax
- NEVER use
<PdfViewerComponent>, <Inject services={...}>, useState, useRef, or useEffect
- 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. 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 setup: clone quickstart, install packages, import CSS, create PdfViewer instance with documentPath and resourceUrl, and appendTo HTML container. |
"basic setup", "minimal example", "getting started", "how to load PDF" |
| general-properties.md |
Configure core viewer properties (width, height, document path, locale, resourceUrl, serviceUrl, AJAX settings, scroll settings, commandManager). |
"configuration", "server settings", "locale", "document path setup", "width height" |
| 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: Bookmark API methods are accessed on the pdfviewer instance directly (e.g., pdfviewer.bookmark.openBookmarkPane()). Requires BookmarkView to be injected and enableBookmark: true. |
"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" |
� Comments & Panels
| File |
Purpose |
Route When User Asks About |
| general-properties.md |
Configure core viewer properties including isCommandPanelOpen to show/hide the comments panel programmatically. See "Controlling Command Panel (Comments Panel)" section. REQUIREMENT: Set enableAnnotation: true for the command panel to be functional. PROPERTY: isCommandPanelOpen is read/write boolean (not read-only). |
"show comments panel", "hide comments panel", "toggle comments", "command panel", "show/hide comments", "isCommandPanelOpen", "comments panel", "annotation comments" |
�🔍 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 using toolbarSettings. |
"customize toolbar", "hide toolbar items", "remove toolbar buttons", "toolbar configuration" |
| toolbar-methods.md |
Programmatically show/hide toolbars and enable/disable toolbar items at runtime using methods like showToolbar(). |
"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 |
| context-menu.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). Use TextFieldSettings, CheckBoxFieldSettings, RadioButtonFieldSettings, etc. for proper type casting. CRITICAL: Form field bounds use capitalized properties (X, Y, Width, Height), NOT lowercase. TIMING CRITICAL: Always add form fields inside the documentLoad event callback - calling before document loads causes "formFieldCollections is not a function" error. |
"form field defaults", "form field styles", "configure form fields", "form field properties", "add text field", "add form field", "add textbox", "add checkbox", "programmatically add field", "addFormField", "TextFieldSettings" |
| 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 { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation,
ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer';
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView,
BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
let pdfviewer: PdfViewer = new PdfViewer();
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
pdfviewer.appendTo('#PdfViewer');
🔄 DOCUMENT LIFECYCLE REQUIREMENTS (CRITICAL)
When to Use documentLoad Event
Certain operations MUST be performed inside the documentLoad event callback, not immediately after instantiation:
Operations that REQUIRE documentLoad:
- ✅ Adding form fields programmatically (
formDesigner.addFormField())
- ✅ Adding annotations (
annotation.addAnnotation())
- ✅ Accessing form field collections (
formFieldCollections)
- ✅ Accessing document metadata
- ✅ Modifying document-dependent properties
Operations safe at instantiation time:
- ✅ Setting
enableToolbar, enableAnnotation, etc.
- ✅ Setting viewer properties like
width, height
- ✅ Configuring settings objects
Example: Correct Timing for Form Fields
❌ WRONG - Causes "formFieldCollections.findIndex is not a function":
let pdfviewer = new PdfViewer({
documentPath: 'https://...',
resourceUrl: 'https://...'
});
pdfviewer.appendTo('#PdfViewer');
// ERROR! formFieldCollections not yet initialized
pdfviewer.formDesigner.addFormField('Textbox', { ... });
✅ CORRECT - Inside documentLoad callback:
let pdfviewer = new PdfViewer({
documentPath: 'https://...',
resourceUrl: 'https://...',
documentLoad: () => {
// SAFE - Document fully loaded, formFieldCollections initialized
pdfviewer.formDesigner.addFormField('Textbox', { ... });
}
});
pdfviewer.appendTo('#PdfViewer');
⚙️ SETTINGS CONFIGURATION BEST PRACTICES
When generating code with settings (toolbarSettings, annotationSettings, annotationSelectorSettings, arrowSettings, rectangleSettings, etc.), follow these guidelines:
Rule 1: Simple Settings → Pass directly to the PdfViewer constructor
Use this approach when:
- Configuring only 1-3 properties
- Settings are straightforward without complex enums or custom types
Example (DO THIS):
import { PdfViewer, Toolbar, Annotation } from '@syncfusion/ej2-pdfviewer';
PdfViewer.Inject(Toolbar, Annotation);
let pdfviewer: PdfViewer = new PdfViewer({
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',
annotationSelectorSettings: {
selectionBorderColor: '#0000ff',
resizerBorderColor: '#ff0000',
resizerSize: 8
}
});
pdfviewer.appendTo('#PdfViewer');
Benefits:
- ✅ No extra imports needed
- ✅ Simple and readable
- ✅ Less code clutter
- ✅ Type checking still works
Rule 2: Complex Settings → Define as Typed Constant (OUTSIDE instantiation)
Use this approach when:
- Configuring 4+ properties OR multiple related settings
- Using enums or complex configurations
- Need to reuse the same configuration in multiple places
- Settings are complex enough to warrant separate definition
Example (DO THIS ONLY FOR COMPLEX CASES):
import { PdfViewer, Toolbar, Annotation, AnnotationResizerLocation, CursorType } from '@syncfusion/ej2-pdfviewer';
import { AnnotationSelectorSettingsModel } from '@syncfusion/ej2-pdfviewer';
PdfViewer.Inject(Toolbar, Annotation);
// Define constant OUTSIDE instantiation 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
};
let pdfviewer: PdfViewer = new PdfViewer({
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',
annotationSelectorSettings: annotationSelectorConfig
});
pdfviewer.appendTo('#PdfViewer');
When to import types and enums:
Benefits:
- ✅ Type-safe configuration
- ✅ Proper enum usage
- ✅ Reusable across multiple viewer instances
- ✅ Clean instantiation code
Rule 3: NEVER Over-Engineer Simple Cases
❌ DO NOT DO THIS (Over-engineered):
import { PdfViewer, Toolbar } from '@syncfusion/ej2-pdfviewer';
import { ToolbarSettingsModel } from '@syncfusion/ej2-pdfviewer';
PdfViewer.Inject(Toolbar);
// Unnecessary constant for 2 simple properties
const toolbarSettings: ToolbarSettingsModel = {
showTooltip: true
};
let pdfviewer: PdfViewer = new PdfViewer({
toolbarSettings: toolbarSettings
});
pdfviewer.appendTo('#PdfViewer');
✅ DO THIS INSTEAD (Simple & Clean):
import { PdfViewer, Toolbar } from '@syncfusion/ej2-pdfviewer';
PdfViewer.Inject(Toolbar);
let pdfviewer: PdfViewer = new PdfViewer({
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',
toolbarSettings: { showTooltip: true }
});
pdfviewer.appendTo('#PdfViewer');
Common Pitfalls and Corrections
Extract Pages API location: extractPages() is a method of PdfViewer, not of pageOrganizer. Call pdfviewer.extractPages('1-3'), not pdfviewer.pageOrganizer.extractPages('1-3'). The PageOrganizer service enables the UI and capabilities, but programmatic extraction uses the viewer instance.
Loading extracted/serialized PDFs: pdfviewer.load(document, password?) accepts two parameters. When loading output returned by extractPages(...), provide the password parameter as an empty string if the document is not protected, for example: pdfviewer.load(extractedPdf, ''). Supply the actual password only for password-protected PDFs.
Event timing for document-dependent operations: Perform annotation and form field operations inside documentLoad to avoid initialization errors (e.g., formFieldCollections availability).
1---2name: syncfusion-javascript-pdf-viewer3description: Implements the Syncfusion Javascript (ES6) is case-sensitive PDF Viewer (PdfViewer) for embedding, configuring, and loading PDF documents. Use this when rendering PDFs in a TypeScript application using the EJ2 class-based approach, embedding viewer controls, or generating TypeScript and HTML code for PDF display and interaction.4---56# Syncfusion TypeScript PdfViewer – UI Sample Generator78## Generate Code for the User's Project *(default)*910**Trigger keywords:** "how to", "add pdfviewer", "code sample", "show me", "example", "snippet", "integrate", "component", "create sample", "typescript sample".1112**Purpose:** Generate minimal, copy-pasteable TypeScript (`.ts`) and HTML code that the user can integrate directly into their TypeScript EJ2 project.1314**Workflow:**15**⚠️ CRITICAL — Feature Support Policy (STRICT MODE):**16 17**FUNDAMENTAL RULE:** Only generate code using APIs and properties that are EXPLICITLY listed in the reference files. ANY deviation is a VIOLATION.18 19- **MANDATORY CHECKS BEFORE GENERATING ANY CODE:**20 1. Search the reference files for the exact API/property name21 2. Verify it appears in the Method Reference, Properties, or Events tables22 3. If NOT found in ANY reference file, STOP immediately23 4. Do NOT generate or suggest undocumented APIs under any circumstances24 25- **STRICT ENFORCEMENT - ZERO TOLERANCE:**26 - **NO custom properties** - Only use properties from reference file tables27 - **NO invented methods** - Only use methods from reference file tables28 - **NO workarounds with undefined APIs** - Forbidden29 - **NO assumptions** about undocumented behavior - Forbidden30 - **NO alternative implementations** using guess-work - Forbidden31 - **NO pretending support exists** - Forbidden32 33- **MANDATORY RESPONSE FOR UNSUPPORTED FEATURES:**34 - **If a requested scenario/feature/API is NOT listed in any reference file, you MUST respond with:**35 ```36 "This feature is not supported in the current Syncfusion TypeScript PDF Viewer implementation."37 ```38 - **Then list what IS supported** from the appropriate reference file39 - **Never suggest alternatives** unless explicitly documented in reference files40 41- **REFERENCE FILE HIERARCHY:**42 - Each reference file contains complete, authoritative documentation for its domain43 - The tables (Method Reference, Properties, Events) are the SOURCE OF TRUTH44 - Content outside these tables in reference files is explanatory only45 - Do NOT extend beyond what appears in the reference file tables46 47- **AUDIT YOUR GENERATION:**48 - Before providing any code, verify EVERY API used appears in a reference file table49 - Document which reference file each API comes from50 - If you cannot cite a reference file table entry, DELETE that code51 52- **This is a CRITICAL REQUIREMENT.** Violations compromise the skill's integrity and reliability.53 54#### Step 1 — Detect the Application Type *(REQUIRED - DO NOT SKIP)*55- **Use file_search and read_file tools to inspect workspace project files:**56 - `package.json` (check for `@syncfusion/ej2-pdfviewer` or `@syncfusion/ej2` dependency)57 - `tsconfig.json` (TypeScript configuration)58 - `webpack.config.js` (EJ2 quickstart uses webpack)59 - `src/index.ts` or `src/app.ts` (main TypeScript entry point)60 - `src/index.html` (HTML container file)61- **Output:** Confirm the detected application type is a **TypeScript EJ2 webpack project** (NOT a React/Vue/Angular project) before proceeding.62- **CRITICAL:** This skill generates **vanilla TypeScript** code using the EJ2 `PdfViewer` class. Do NOT generate React, Angular, or Vue component code.63 64#### Step 2 — Generate Code from Reference Files Only *(REQUIRED)*65- **Before generating:** Confirm that Step 1 is complete66- Read the relevant `references/*.md` file(s) for the requested feature67- Cross-reference EVERY API, property, and method against these tables68- **CLASS-BASED APPROACH (MANDATORY - TypeScript EJ2 PATTERNS ONLY):**69 - Import `PdfViewer` and required module classes from `@syncfusion/ej2-pdfviewer`70 - Use `PdfViewer.Inject(...)` to inject required feature modules71 - Instantiate with `new PdfViewer({ ... })` or `new PdfViewer()` and set properties72 - Mount to DOM using `viewer.appendTo('#ElementId')`73 - **NEVER use JSX, TSX, React hooks, or component-based syntax**74 - **NEVER use `<PdfViewerComponent>`, `<Inject services={...}>`, `useState`, `useRef`, or `useEffect`**75- **MANDATORY:** Before generating ANY code, verify that reference files exist and are accessible76- **Read the appropriate reference file(s)** for the requested feature:77 - Use `read_file` tool on relevant `references/*.md` files78 - Confirm file contains Methods/Properties/Events tables79 - Verify tables are complete and readable80- **If reference file is missing or cannot be read:**81 - STOP code generation82 - Respond: "Reference file for this feature is not available. Please ensure all reference files are present in the `references/` directory."83 - List the missing reference file name84- **This is a BLOCKER step:** Cannot proceed without reference file validation85- If an API/property does NOT appear in the reference file table, DO NOT USE IT86- Do NOT invent, guess, or suggest any API, method, property, class, or namespace not explicitly present in the reference files87 88---8990## Reference File Routing Guide9192All templates and operation snippets live in `references/*.md`. Each file is a focused snippet or template the agent will combine when generating samples.9394**Flow:** Always start with [getting-started.md](references/getting-started.md), then merge matched features into its anchors. If no keyword matches, return only the basic sample.9596### Checklist Before Generating Code9798- [ ] **Count the settings properties:** 1-3? → Pass inline in constructor | 4+? → Extract to typed constant99- [ ] **Are enums involved?** Yes → Must use typed constant with enum imports | No → Can pass inline100- [ ] **Is it reused elsewhere?** Yes → Use constant | No → Prefer inline101- [ ] **Do I need type safety?** Yes → Import the model type | No → Skip model type import102- [ ] **Do I need enums?** Yes → Import required enums from `@syncfusion/ej2-pdfviewer` | No → Skip enum imports103- [ ] **Package name correct?** Always import from `@syncfusion/ej2-pdfviewer` — NEVER from `@syncfusion/ej2-typescript-pdfviewer`104105### 🎯 Core Setup & Configuration106107| File | Purpose | **Route When User Asks About** |108|---|---|---|109| [getting-started.md](references/getting-started.md) | Minimal PdfViewer setup: clone quickstart, install packages, import CSS, create `PdfViewer` instance with `documentPath` and `resourceUrl`, and `appendTo` HTML container. | "basic setup", "minimal example", "getting started", "how to load PDF" |110| [general-properties.md](references/general-properties.md) | Configure core viewer properties (width, height, document path, locale, resourceUrl, serviceUrl, AJAX settings, scroll settings, commandManager). | "configuration", "server settings", "locale", "document path setup", "width height" |111| [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" |112113### 📐 Navigation & Page Management114115| File | Purpose | **Route When User Asks About** |116|---|---|---|117| [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" |118| [bookmark-navigation.md](references/bookmark-navigation.md) | Navigate using PDF bookmarks/table of contents in the bookmark panel. **CRITICAL: Bookmark API methods are accessed on the `pdfviewer` instance directly (e.g., `pdfviewer.bookmark.openBookmarkPane()`). Requires `BookmarkView` to be injected and `enableBookmark: true`.** | "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" |119| [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" |120| [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" |121122### � Comments & Panels123124| File | Purpose | **Route When User Asks About** |125|---|---|---|126| [general-properties.md](references/general-properties.md) | Configure core viewer properties including `isCommandPanelOpen` to show/hide the comments panel programmatically. See "Controlling Command Panel (Comments Panel)" section. **REQUIREMENT:** Set `enableAnnotation: true` for the command panel to be functional. **PROPERTY:** `isCommandPanelOpen` is read/write boolean (not read-only). | "show comments panel", "hide comments panel", "toggle comments", "command panel", "show/hide comments", "isCommandPanelOpen", "comments panel", "annotation comments" |127128### �🔍 Viewing & Interaction129130| File | Purpose | **Route When User Asks About** |131|---|---|---|132| [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" |133| [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" |134| [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" |135| [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" |136137### 🛠️ Toolbar & Context Menu138139#### Toolbar Configuration140141| File | Purpose | **Route When User Asks About** |142|---|---|---|143| [toolbar-settings.md](references/toolbar-settings.md) | Configure toolbar visibility, tooltip behavior, and customize/remove toolbar items using `toolbarSettings`. | "customize toolbar", "hide toolbar items", "remove toolbar buttons", "toolbar configuration" |144| [toolbar-methods.md](references/toolbar-methods.md) | Programmatically show/hide toolbars and enable/disable toolbar items at runtime using methods like `showToolbar()`. | "show/hide toolbar dynamically", "toggle toolbar", "enable/disable toolbar items programmatically" |145146##### ⚠️ STRICT VALIDATION FOR TOOLBAR ITEM NAMES147148**When generating toolbar configurations, you MUST follow these rules to prevent incorrect toolbar item names:**1491501. **ALWAYS reference exact item names from `toolbar-settings.md`**151 - Do NOT invent, guess, or assume toolbar item names152 - Do NOT apply naming pattern logic to derive names153 - Use ONLY names listed in the "Available Primary Toolbar Items", "Available Annotation Toolbar Items", and "Available Form Designer Items" sections in `toolbar-settings.md`1541552. **VALIDATE item names character-by-character**156 - Case sensitivity matters: `HighlightTool` ≠ `HighlightOption`157 - Exact names only: `AnnotationEditTool` ≠ `AnotatetionEditTool`158 - No abbreviations or shortcuts1591603. **Before generating toolbar configuration code:**161 - [ ] Open `toolbar-settings.md` reference file162 - [ ] Locate: "Available Primary Toolbar Items" section163 - [ ] Locate: "Available Annotation Toolbar Items" section164 - [ ] Locate: "Available Form Designer Items" section165 - [ ] Copy exact names from THESE SECTIONS ONLY166 - [ ] Cross-check every single item name character-by-character167 - [ ] If ANY item name is not in the reference sections, DO NOT USE IT168 - [ ] Consult the "❌ COMMON MISTAKES TO AVOID" table in `toolbar-settings.md` if unsure1691704. **Common errors to prevent:**171 - ❌ `AnotatetionEditTool` → ✅ `AnnotationEditTool` (typo)172 - ❌ `CalibrationOption` → ✅ `CalibrateTool` (wrong suffix)173 - ❌ `ShapeAnnotationOption` → ✅ `ShapeTool` (annotation toolbar version)174 - ❌ `InkAnnotationOption` → ✅ `InkAnnotationTool` (annotation toolbar version)175 - For complete list of mistakes to avoid, see `toolbar-settings.md` "❌ COMMON MISTAKES TO AVOID" table176177#### Context Menu Customization178179| File | Purpose | **Route When User Asks About** |180|---|---|---|181| [context-menu.md](references/context-menu.md) | Customize context menu items and handle context menu events. | "right-click menu", "context menu", "custom context menu", "disable context menu items" |182183### 📝 Annotations184185| File | Purpose | **Route When User Asks About** |186|---|---|---|187| [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" |188| [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" |189| [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" |190| [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" |191192### 📄 Forms193194| File | Purpose | **Route When User Asks About** |195|---|---|---|196| [form-field-settings.md](references/form-field-settings.md) | Configure default properties for form fields (text, checkbox, radio, dropdown, signature). Use `TextFieldSettings`, `CheckBoxFieldSettings`, `RadioButtonFieldSettings`, etc. for proper type casting. **CRITICAL:** Form field bounds use capitalized properties (X, Y, Width, Height), NOT lowercase. **TIMING CRITICAL:** Always add form fields inside the `documentLoad` event callback - calling before document loads causes "formFieldCollections is not a function" error. | "form field defaults", "form field styles", "configure form fields", "form field properties", "add text field", "add form field", "add textbox", "add checkbox", "programmatically add field", "addFormField", "TextFieldSettings" |197| [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" |198199### 📋 Document Actions200201| File | Purpose | **Route When User Asks About** |202|---|---|---|203| [download.md](references/download.md) | Enable/configure PDF download functionality with custom filenames. | "download PDF", "save PDF", "export document", "download button" |204| [print.md](references/print.md) | Configure and trigger PDF printing functionality. | "print PDF", "print document", "printing options", "print button" |205| [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" |206207### ⚙️ Advanced Features208209| File | Purpose | **Route When User Asks About** |210|---|---|---|211| [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" |212| [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" |213214---215216## Quick Start Example217218```typescript219import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation,220 ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer';221222PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView,223 BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);224225let pdfviewer: PdfViewer = new PdfViewer();226pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";227pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";228pdfviewer.appendTo('#PdfViewer');229```230231## 🔄 DOCUMENT LIFECYCLE REQUIREMENTS (CRITICAL)232233### When to Use `documentLoad` Event234235Certain operations MUST be performed inside the `documentLoad` event callback, not immediately after instantiation:236237**Operations that REQUIRE `documentLoad`:**238- ✅ Adding form fields programmatically (`formDesigner.addFormField()`)239- ✅ Adding annotations (`annotation.addAnnotation()`)240- ✅ Accessing form field collections (`formFieldCollections`)241- ✅ Accessing document metadata242- ✅ Modifying document-dependent properties243244**Operations safe at instantiation time:**245- ✅ Setting `enableToolbar`, `enableAnnotation`, etc.246- ✅ Setting viewer properties like `width`, `height`247- ✅ Configuring settings objects248249### Example: Correct Timing for Form Fields250251**❌ WRONG - Causes "formFieldCollections.findIndex is not a function":**252```typescript253let pdfviewer = new PdfViewer({254 documentPath: 'https://...',255 resourceUrl: 'https://...'256});257pdfviewer.appendTo('#PdfViewer');258259// ERROR! formFieldCollections not yet initialized260pdfviewer.formDesigner.addFormField('Textbox', { ... });261```262263**✅ CORRECT - Inside documentLoad callback:**264```typescript265let pdfviewer = new PdfViewer({266 documentPath: 'https://...',267 resourceUrl: 'https://...',268 documentLoad: () => {269 // SAFE - Document fully loaded, formFieldCollections initialized270 pdfviewer.formDesigner.addFormField('Textbox', { ... });271 }272});273pdfviewer.appendTo('#PdfViewer');274```275276---277278## ⚙️ SETTINGS CONFIGURATION BEST PRACTICES279280**When generating code with settings (toolbarSettings, annotationSettings, annotationSelectorSettings, arrowSettings, rectangleSettings, etc.), follow these guidelines:**281282### Rule 1: Simple Settings → Pass directly to the PdfViewer constructor283284**Use this approach when:**285- Configuring only 1-3 properties286- Settings are straightforward without complex enums or custom types287288**Example (DO THIS):**289```typescript290import { PdfViewer, Toolbar, Annotation } from '@syncfusion/ej2-pdfviewer';291292PdfViewer.Inject(Toolbar, Annotation);293294let pdfviewer: PdfViewer = new PdfViewer({295 documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',296 resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',297 annotationSelectorSettings: {298 selectionBorderColor: '#0000ff',299 resizerBorderColor: '#ff0000',300 resizerSize: 8301 }302});303pdfviewer.appendTo('#PdfViewer');304```305306**Benefits:**307- ✅ No extra imports needed308- ✅ Simple and readable309- ✅ Less code clutter310- ✅ Type checking still works311312---313314### Rule 2: Complex Settings → Define as Typed Constant (OUTSIDE instantiation)315316**Use this approach when:**317- Configuring 4+ properties OR multiple related settings318- Using enums or complex configurations319- Need to reuse the same configuration in multiple places320- Settings are complex enough to warrant separate definition321322**Example (DO THIS ONLY FOR COMPLEX CASES):**323324```typescript325import { PdfViewer, Toolbar, Annotation, AnnotationResizerLocation, CursorType } from '@syncfusion/ej2-pdfviewer';326import { AnnotationSelectorSettingsModel } from '@syncfusion/ej2-pdfviewer';327328PdfViewer.Inject(Toolbar, Annotation);329330// Define constant OUTSIDE instantiation with proper types and enums331const annotationSelectorConfig: AnnotationSelectorSettingsModel = {332 selectionBorderColor: '#0000ff',333 selectionBorderThickness: 2,334 resizerBorderColor: '#ff0000',335 resizerFillColor: '#4070ff',336 resizerSize: 8,337 resizerShape: 'Square',338 selectorLineDashArray: [5, 6],339 resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges,340 resizerCursorType: CursorType.grab341};342343let pdfviewer: PdfViewer = new PdfViewer({344 documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',345 resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',346 annotationSelectorSettings: annotationSelectorConfig347});348pdfviewer.appendTo('#PdfViewer');349```350351**When to import types and enums:**352- [ ] Import model types (e.g., `AnnotationSelectorSettingsModel`) for TypeScript type checking353- [ ] Import any enums used in the settings (e.g., `AnnotationResizerLocation`, `CursorType`)354- [ ] Keep imports minimal - import ONLY what is used355356**Benefits:**357- ✅ Type-safe configuration358- ✅ Proper enum usage359- ✅ Reusable across multiple viewer instances360- ✅ Clean instantiation code361362---363364### Rule 3: NEVER Over-Engineer Simple Cases365366**❌ DO NOT DO THIS (Over-engineered):**367```typescript368import { PdfViewer, Toolbar } from '@syncfusion/ej2-pdfviewer';369import { ToolbarSettingsModel } from '@syncfusion/ej2-pdfviewer';370371PdfViewer.Inject(Toolbar);372373// Unnecessary constant for 2 simple properties374const toolbarSettings: ToolbarSettingsModel = {375 showTooltip: true376};377378let pdfviewer: PdfViewer = new PdfViewer({379 toolbarSettings: toolbarSettings380});381pdfviewer.appendTo('#PdfViewer');382```383384**✅ DO THIS INSTEAD (Simple & Clean):**385```typescript386import { PdfViewer, Toolbar } from '@syncfusion/ej2-pdfviewer';387388PdfViewer.Inject(Toolbar);389390let pdfviewer: PdfViewer = new PdfViewer({391 documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',392 resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',393 toolbarSettings: { showTooltip: true }394});395pdfviewer.appendTo('#PdfViewer');396```397398## Common Pitfalls and Corrections399400- Extract Pages API location: `extractPages()` is a method of `PdfViewer`, not of `pageOrganizer`. Call `pdfviewer.extractPages('1-3')`, not `pdfviewer.pageOrganizer.extractPages('1-3')`. The `PageOrganizer` service enables the UI and capabilities, but programmatic extraction uses the viewer instance.401402- Loading extracted/serialized PDFs: `pdfviewer.load(document, password?)` accepts two parameters. When loading output returned by `extractPages(...)`, provide the password parameter as an empty string if the document is not protected, for example: `pdfviewer.load(extractedPdf, '')`. Supply the actual password only for password-protected PDFs.403404- Event timing for document-dependent operations: Perform annotation and form field operations inside `documentLoad` to avoid initialization errors (e.g., `formFieldCollections` availability).405406---