/** * This class should be used to create custom Immutable Record. It will overwrite the default * `Immutable#equals()` method to include the class name. if we don't do this, two different classes * with the same default value set will be treated as equal. * * @example * // With regular `Immutable.Record` * class A extends Record({ foo: 'bar' }) {} * class B extends Record({ foo: 'bar' }) {} * const a = new A() * const b = new B() * is(a, b) // true * * // With `InheritableImmutableRecord` * class A extends InheritableImmutableRecord { * static defaultValues = { foo: 'bar' } * } * mergeImmutableRecordDefaults(A) * class B extends InheritableImmutableRecord { * static defaultValues = { foo: 'bar' } * } * mergeImmutableRecordDefaults(B) * const a = new A() * const b = new B() * is(a, b) // false */ declare class __dangerousImmutableRecordFactory> { has(key: unknown): boolean; get(key: K): TProps[K]; set(key: K, value: TProps[K]): this; delete(key: K): this; clear(): this; update(key: K, updater: (value: TProps[K]) => TProps[K]): this; merge(...collections: Array>): this; mergeWith(merger: (previous?: unknown, next?: unknown, key?: string) => unknown, ...collections: Array | Iterable<[string, unknown]>>): this; mergeDeep(...collections: Array | Iterable<[string, unknown]>>): this; mergeDeepWith(merger: (previous?: unknown, next?: unknown, key?: string) => unknown, ...collections: Array | Iterable<[string, unknown]>>): this; setIn(keyPath: Iterable, value: unknown): this; deleteIn(keyPath: Iterable): this; removeIn(keyPath: Iterable): this; updateIn(keyPath: Iterable, notSetValue: unknown, updater: (value: unknown) => unknown): this; updateIn(keyPath: Iterable, updater: (value: unknown) => unknown): this; mergeIn(keyPath: Iterable, ...collections: Array | Iterable<[string, unknown]>>): this; mergeDeepIn(keyPath: Iterable, ...collections: Array | Iterable<[string, unknown]>>): this; withMutations(mutator: (mutable: this) => unknown): this; asMutable(): this; asImmutable(): this; getIn(keyPath: Iterable, notSetValue?: unknown): unknown; toJS(): TProps; toJSON(): TProps; equals(other: unknown): boolean; toSeq(): Seq.Keyed; } /** * @class * Base action type from which all Actions inherit. You can not instantiate from this type. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record}. * @summary Base action type from which all Actions inherit. */ export declare abstract class Action extends InheritableImmutableRecord { /** * Actions can be chained by adding them to this immutable List. */ subActions?: Immutable.List | null | undefined; protected constructor(args?: ActionProperties); } declare type ActionCreators = typeof textComparisonActionCreators; declare type ActionFlags = 'includeExclude' | 'includeNoValueFields' | 'exportFormat' | 'getMethod' | 'submitCoordinated' | 'xfdf' | 'includeAppendSaves' | 'includeAnnotations' | 'submitPDF' | 'canonicalFormat' | 'excludeNonUserAnnotations' | 'excludeFKey' | 'embedForm'; /** @inline */ declare type ActionProperties = { subActions?: Immutable.List | null; }; export declare namespace Actions { export { Action, GoToAction, GoToEmbeddedAction, GoToRemoteAction, HideAction, JavaScriptAction, LaunchAction, NamedAction, ResetFormAction, SubmitFormAction, URIAction }; } declare type ActionTriggerEventType = 'onPointerEnter' | 'onPointerLeave' | 'onPointerDown' | 'onPointerUp' | 'onPageOpen' | 'onPageClose' | 'onPageVisible' | 'onPageHidden'; declare interface AddPageConfiguration { backgroundColor: Color; pageWidth: number; pageHeight: number; rotateBy: Rotation; insets?: Rect; } /** * Payload for sending changes to AI services * * @public */ declare interface AIADocumentChangePayload { id: string; type: string; text: string; contextBefore: string; contextAfter: string; page: number; } /** * Base response item from AI services representing a single document change. * Contains the essential information about a text modification detected during comparison. * * @example * // Typical structure of a change item * { * id: "change-456", * type: "deletion", * text: "old contract terms", * page: 1, * contextBefore: "The following ", * contextAfter: " are no longer valid" * } */ export declare interface AIADocumentChangeResponseItem { /** Unique identifier for this change, used for tracking and correlation */ id: string; /** Type of change operation (e.g., "insertion", "deletion", "modification") */ type: string; /** The actual text content that was changed */ text: string; /** Zero-based page number where this change occurred */ page: number; /** Text content appearing before the change for context. */ contextBefore?: string; /** Text content appearing after the change for context. */ contextAfter?: string; } /** * Response from AI analysis service containing a high-level summary and categorization * of document changes. This is returned when using `NutrientViewer.AIComparisonOperationType.ANALYZE`. * * @example * // After running an ANALYZE operation * if (NutrientViewer.isAIDocumentAnalysisResult(result)) { * console.log(`Summary: ${result.summary}`); * // Example: "The document has undergone significant legal revisions with updated terminology and new clauses." * * console.log(`Categories: ${result.categories.join(', ')}`); * // Example: ["Legal Changes", "Terminology Updates", "Content Addition"] * * // Access detailed changes * console.log(`Total changes: ${result.changes.changes.size}`); * } */ export declare interface AIADocumentChangesAnalysisResponse { /** AI-generated natural language summary describing the overall nature of changes between the compared documents */ summary: string; /** Array of AI-detected change categories representing the types of modifications (e.g., "Formatting", "Content Addition", "Legal Changes", "Rewording") */ categories: string[]; /** The underlying standard document comparison result containing detailed text hunks and change operations */ changes: DocumentComparison.DocumentComparisonResult; } /** * Response from AI tagging service containing categorized change information. * This is returned when using `NutrientViewer.AIComparisonOperationType.TAG`. * * @example * // After running a TAG operation * if (NutrientViewer.isAIDocumentTaggingResult(result)) { * result.references.forEach((ref, index) => { * console.log(`Change ${index + 1}: ${ref.text}`); * console.log(`Categories: ${ref.tag.join(', ')}`); * console.log(`Page: ${ref.page}`); * }); * } */ export declare interface AIADocumentChangesTaggingResponse { /** * Array where each * item corresponds to a specific change and includes category tags assigned by the AI service. * Each reference contains the change details plus an array of category strings that classify * the type of modification (e.g., ["Legal", "Formatting"] for a legal change with formatting updates). * */ references: AIADocumentChangeTaggingItem[]; } /** * Individual change item with AI-assigned category tags from the tagging service. * Extends the base response item with categorization information. * * @example * // Typical structure of a tagged change * { * id: "change-123", * type: "insertion", * text: "confidential information", * page: 2, * contextBefore: "regarding the ", * contextAfter: " shall not be disclosed", * tag: ["Legal", "Confidentiality"] * } */ export declare interface AIADocumentChangeTaggingItem extends AIADocumentChangeResponseItem { /** Array of category strings assigned by AI to classify this change. */ tag: string[]; } /** * AI Assistant configuration namespace containing all public types. * * This namespace provides TypeScript interfaces and configuration options for integrating * the AI Assistant feature into your application. Use types from this namespace to * configure AI Assistant behavior, security policies, and custom skills. * * @namespace * @example * ```typescript * import { AIAssistant } from 'nutrient' * * const config: AIAssistant.Configuration = { * sessionId: 'user-session-123', * jwt: 'your-jwt-token', * backendUrl: 'https://ai-assistant.example.com' * } * ``` */ export declare namespace AIAssistant { /** * Configuration for the AI Assistant feature. * * Contains authentication details, backend connection information, and optional * customization settings for AI Agent behavior. * * @example * ```typescript * NutrientViewer.load({ * // ... other config * aiAssistant: { * sessionId: 'session-123', * jwt: 'eyJhbGciOiJIUzI1NiIs...', * backendUrl: 'https://localhost:4000' * } * }) * ``` */ export interface Configuration { /** * Session identifier for the AI Assistant conversation. * * Use a unique identifier to create a new session, or reuse an existing session ID * to restore a previous conversation. The ID must contain only alphanumeric characters. * * @example * ```typescript * sessionId: 'userdocsession20250128' * sessionId: 'session123abc' * ``` */ sessionId: string; /** * JSON Web Token (JWT) for authenticating requests to the AI Assistant backend. * * This token must be issued by your authentication service and should contain * user identity claims. The token is sent with every request to the backend. * * @example * ```typescript * jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' * ``` */ jwt: string; /** * URL of the AI Assistant service backend. * * This should be the base URL where your AI Assistant service is deployed. * The URL must include the protocol (http/https) but exclude trailing slashes. * * @example * ```typescript * backendUrl: 'https://ai-assistant.example.com' // ✓ correct * backendUrl: 'https://ai-assistant.example.com/' // ✗ avoid trailing slash * ``` */ backendUrl: string; /** * Optional user identifier for tracking and rate limiting. * * Provide a unique identifier for the current user. This enables per-user * rate limiting, usage analytics, and audit logging. Must contain only * alphanumeric characters. * * @example * ```typescript * userId: 'userabc12345' * userId: 'user123' * ``` */ userId?: string; /** * AI Agent preset or custom agent ID. * * Selects a base agent configuration with different capabilities and behavior. * * | Preset | Purpose | * |------------|--------------------------------------------------------------------------------| * | `chat` | Read-only Q&A mode. This agent can summarize, extract data, and answer questions. | * | `agentic` | Full autonomous agent. This agent can read, write, add annotations, fill forms, and redact documents. | * | `base` | Base configuration. This agent uses defaults for all settings and is intended for customization. | * * @default 'agentic' * @example * ```typescript * agentId: 'chat' // Use the read-only chat preset * ``` */ agentId?: 'chat' | 'agentic' | 'base' | string; /** * Advanced configuration for customizing AI Assistant agent behavior. * * Customize the system prompt, define specialized skills, configure tool execution * approval policies. * * @example * ```typescript * NutrientViewer.load({ * aiAssistant: { * sessionId: 'session-123', * jwt: 'token-here', * backendUrl: 'https://localhost:4000', * agentConfiguration: { * systemPromptTemplate: 'You are an expert legal document assistant.', * skills: [ * { * name: 'contract-review', * description: 'Analyze contracts for key terms', * content: 'Focus on liability and payment terms...' * } * ], * toolApproval: { * defaults: { default: 'allow', write: 'ask' } * } * } * } * }); * ``` */ agentConfiguration?: AgentConfiguration; } /** * Advanced configuration for AI Agent behavior and capabilities. * * Customize the agent's system instructions, define domain-specific skills, * control tool execution policies. * * This interface enables fine-grained control over how the AI Agent processes * requests, what knowledge it has access to, and which operations require user approval. * * @example * ```typescript * const config: AIAssistant.AgentConfiguration = { * systemPromptTemplate: 'You are an expert legal document assistant.', * skills: [ * { * name: 'contract-review', * description: 'Analyze contracts for key terms and risks', * content: '1. Identify all parties\n2. Extract key dates\n3. Highlight liability clauses' * } * ], * toolApproval: { * defaults: { default: 'allow', write: 'ask' } * } * } * ``` */ export interface AgentConfiguration { /** * Custom system prompt template for defining agent personality and behavior. * * Defines the base instructions, role, and guidelines that shape how the agent * processes requests and responds to users. This is the primary mechanism for * customizing the agent's expertise and behavior patterns. * * Keep prompts concise but descriptive. Focus on the agent's role, key principles, * and important constraints. * * @example * ```typescript * systemPromptTemplate: `You are an expert legal document analyst. * Your role is to: * - Identify and explain key contractual terms * - Highlight potential risks or unusual clauses * - Always cite the specific section numbers * - If uncertain, clearly state your limitations` * ``` * * @default A general-purpose document assistant prompt */ systemPromptTemplate?: string; /** * Seed messages for shaping agent behavior across all interactions. * * Messages injected before the conversation history on every model invocation. * Useful for few-shot prompting, additional constraints, and behavioral priming * that should persist across all conversation turns. * * **Important**: Seed messages are NOT persisted to the conversation history * and are injected fresh on each request. * * **Common use cases**: * - Few-shot learning: Include human/ai example pairs * - Additional instructions: Constraints that complement systemPromptTemplate * - Behavioral priming: Consistent patterns to reinforce across all responses * * @example * ```typescript * seedMessages: [ * { * type: 'human', * content: 'Analyze the indemnification clause in this contract.' * }, * { * type: 'ai', * content: 'I found the indemnification clause on page 3, section 5.2...' * } * ] * ``` */ seedMessages?: Array<{ /** * The sender type for this message. * * - `'human'`: User/human messages (used in few-shot examples) * - `'ai'`: Assistant responses (used in few-shot examples) */ type: 'human' | 'ai'; /** * The text content of the message. * * Use clear, concise language. For few-shot examples, make responses * representative of the desired behavior. */ content: string; }>; /** * User identifier for rate limiting and authorization. * * Provide a unique identifier for the current user to enable * per-user rate limiting and usage tracking. * * @example * ```typescript * userId: 'user12345' * ``` */ userId?: string; /** * Domain-specific skills for the AI Agent. * * Define specialized knowledge, instructions, or workflows that the agent * can access and apply when relevant to user requests. Skills allow you to * inject domain expertise without modifying the system prompt. * * The agent decides when to use each skill based on the skill description * and the user's request. Use descriptive names and clear instructions. * * @example * ```typescript * skills: [ * { * name: 'contract-review', * description: 'Analyze contracts for key terms and identify potential risks', * content: `When reviewing a contract: * 1. Identify all parties and signatories * 2. Extract critical dates (effective date, expiration, renewal) * 3. Summarize payment terms and amounts * 4. Highlight liability and indemnification clauses * 5. Flag unusual or potentially risky terms` * } * ] * ``` */ skills?: Array<{ /** * Unique identifier for this skill. * * Used internally by the agent to reference and invoke this skill. * Should be lowercase with hyphens (e.g., 'contract-analysis', 'data-extraction'). * Minimum 1 character, no spaces. * * @example * ```typescript * name: 'legal-clause-analysis' * ``` */ name: string; /** * Description of when and how to use this skill. * * Helps the agent decide when to apply this knowledge based on user requests. * Be specific about the skill's purpose and ideal use cases. Keep it under * 500 characters. * * @example * ```typescript * description: 'Use when analyzing legal contracts, identifying liability clauses, or explaining terms' * ``` */ description?: string; /** * Detailed knowledge and instructions for this skill. * * The actual content the agent uses when applying this skill. Include step-by-step * instructions, examples, or knowledge the agent should follow. Maximum 50,000 characters. * * @example * ```typescript * content: `Legal Contract Analysis Process: * * 1. PARTIES: Identify all parties, signatories, and roles * 2. DATES: Extract effective date, expiration, renewal dates * 3. PAYMENT: Summarize amounts, payment terms, billing cycles * 4. LIABILITY: Identify indemnification and liability caps * 5. TERMINATION: Note termination conditions and notice periods` * ``` */ content: string; }>; /** * Tool execution approval policies for security and user control. * * Controls which tools can execute automatically and which require user approval. * Use this to implement security policies, prevent unintended modifications, or * require confirmation for sensitive operations. * * **Resolution order** (first match wins): * 1. Pattern-based rules (if defined) * 2. Tool category defaults (read/write based on tool metadata) * 3. Fallback default setting * * @example * ```typescript * // Basic: Allow reads, ask for writes * toolApproval: { * defaults: { * default: 'allow', * read: 'allow', * write: 'ask' * } * } * ``` * * @example * ```typescript * // Advanced: Pattern-based rules with defaults * toolApproval: { * defaults: { default: 'allow' }, * rules: [ * { pattern: '*_delete_*', approval: 'deny' }, * { pattern: 'mcp__*_modify_*', approval: 'ask' } * ] * } * ``` */ toolApproval?: { /** * Default approval settings for tools by category. * * These defaults apply when no rule matches. The resolution order is: * 1. Check if a pattern rule matches (first match wins) * 2. Check tool's readOnlyHint - use 'read' or 'write' setting * 3. Fall back to 'default' setting */ defaults: { /** * Fallback approval mode for all tools not matching a rule or category. * * Used when: * - No pattern rule matches * - Tool has no readOnlyHint annotation * - No category-specific default is configured * * Values: * - `"allow"`: Executes immediately without user intervention * - `"ask"`: Pauses execution and requests user confirmation * - `"deny"`: Rejects the tool call */ default: 'allow' | 'ask' | 'deny'; /** * Approval mode for read-only tools. * * Applies to tools marked with `readOnlyHint: true`. * Typically used for safe operations like searching, analyzing, or retrieving data. * * Values: * - `"allow"`: Executes immediately without user intervention * - `"ask"`: Pauses execution and requests user confirmation * - `"deny"`: Rejects the tool call */ read?: 'allow' | 'ask' | 'deny'; /** * Approval mode for write/modification tools. * * Applies to tools marked with `readOnlyHint: false` that modify documents or state. * Recommended to set to 'ask' for user control over document changes. * * Values: * - `"allow"`: Executes immediately without user intervention * - `"ask"`: Pauses execution and requests user confirmation * - `"deny"`: Rejects the tool call */ write?: 'allow' | 'ask' | 'deny'; }; /** * Pattern-based rules for fine-grained tool control. * * Rules are evaluated in order - the first matching pattern determines the approval mode. * Place more specific patterns before general ones. * * Patterns use standard glob syntax where `*` matches any characters. */ rules?: Array<{ /** * Glob pattern to match against tool names. * * Tool names follow the format: `[namespace]__[server]__[function_name]` * * Common patterns: * - `"mcp__nutrient_*"`: All Nutrient MCP tools * - `"mcp__nutrient-ai-assistant__find_document"`: Specific tool * - `"mcp__nutrient-web-sdk__read_annotations"`: Web SDK tool * - `"mcp__*"`: All MCP tools from any server * - `"mcp__*__*_delete_*"`: Any MCP tool with delete in the name * * @example * ```typescript * pattern: "mcp__nutrient-websdk__add_annotation" * ``` */ pattern: string; /** * Approval mode for tools matching this pattern. * * Values: * - `"allow"`: Executes immediately without user intervention * - `"ask"`: Pauses execution and requests user confirmation * - `"deny"`: Rejects the tool call (will not execute) */ approval: 'allow' | 'ask' | 'deny'; }>; }; } } declare function AIAssistantMixin>(Base: T): { new (...args: any[]): { }; } & T; /** * Data structure for AI comparison results */ export declare interface AIComparisonData { /** AI-generated summary of document changes */ summary: string; /** Array of AI-detected change categories */ categories: string[]; /** Standard document comparison result */ changes: DocumentComparison.DocumentComparisonResult; /** Current phase of the AI comparison process */ phase: IAIComparisonPhase; /** Error information if comparison failed */ error: AIComparisonError | null; /** Changes tagged with categories (optional) */ taggedChanges?: AIADocumentChangeTaggingItem[]; /** Transformed changes for AI processing (optional) */ transformedChanges?: AIADocumentChangePayload[]; /** Enhanced changes with AI properties (optional) */ aiEnhancedChanges?: List; } /** * Error information for AI comparison */ export declare interface AIComparisonError { /** The phase where the error occurred ('ANALYSIS' | 'TAGGING') */ phase: 'ANALYSIS' | 'TAGGING'; /** Human-readable error message */ message: string; /** Additional error details (optional) */ details?: unknown; } /** * Describes types of AI operations for document comparison. * These operations can be used with `ComparisonOperationType.AI`. * * @enum */ declare const AIComparisonOperationType: { /** Analyze and summarize differences between documents. */ readonly ANALYZE: "analyze"; /** Tag changes with specified categories. */ readonly TAG: "tag"; }; /** * Phases of the AI comparison process */ declare enum AIComparisonPhase { /** Initial state before comparison starts */ IDLE = "IDLE", /** Loading documents or initializing */ LOADING = "LOADING", /** AI is analyzing document differences */ ANALYZING = "ANALYZING", /** AI is tagging changes with categories */ TAGGING = "TAGGING", /** Comparison process completed successfully */ COMPLETED = "COMPLETED", /** Error occurred during comparison */ ERROR = "ERROR", } /** * Result returned by AI-powered document comparison operations. This union type represents * the response from {@link NutrientViewer.Instance#compareDocuments} when using * {@link NutrientViewer.ComparisonOperationType}.AI. * * The result type depends on the AI operation performed: * * - **Analysis Operation** (`NutrientViewer.AIComparisonOperationType.ANALYZE`): * Returns {@link AIADocumentChangesAnalysisResponse} containing: * - `summary`: AI-generated summary describing the overall nature of changes * - `categories`: Array of AI-detected change types (e.g., "Formatting", "Content Addition") * - `changes`: Standard {@link DocumentComparison.DocumentComparisonResult} with detailed differences * * - **Tagging Operation** (`NutrientViewer.AIComparisonOperationType.TAG`): * Returns {@link AIADocumentChangesTaggingResponse} containing: * - `references`: Array where each item corresponds to a change with assigned category tags * - `changes`: Standard {@link DocumentComparison.DocumentComparisonResult} with detailed differences * * Use the provided type guards to determine which specific result type you received: * - {@link NutrientViewer.isAIDocumentAnalysisResult} - Check for analysis results * - {@link NutrientViewer.isAIDocumentTaggingResult} - Check for tagging results * - {@link NutrientViewer.isAIDocumentComparisonResult} - Check for any AI result * * @example * const analyzeOperation = new NutrientViewer.ComparisonOperation( * NutrientViewer.ComparisonOperationType.AI, * { operationType: NutrientViewer.AIComparisonOperationType.ANALYZE } * ); * * instance.compareDocuments(documents, analyzeOperation) * .then((result) => { * if (NutrientViewer.isAIDocumentAnalysisResult(result)) { * console.log('Summary:', result.summary); * console.log('Categories:', result.categories); * } * }); * * @see {@link NutrientViewer.Instance#compareDocuments} * @see {@link NutrientViewer.AIComparisonOperationType} * @see {@link AIADocumentChangesAnalysisResponse} * @see {@link AIADocumentChangesTaggingResponse} * @see {@link NutrientViewer.isAIDocumentAnalysisResult} * @see {@link NutrientViewer.isAIDocumentTaggingResult} */ export declare type AIDocumentComparisonResult = AIADocumentChangesAnalysisResponse | AIADocumentChangesTaggingResponse; /** * Enhanced TextComparisonChange with AI-related properties * * @inline */ declare interface AIEnhancedTextComparisonChange extends TextComparisonChange { aiId?: string; categories?: string[]; aiProcessed?: boolean; } /** * Specifies the alignment of an UI element relative to its parent container. * * @enum */ declare const Alignment: { /** Aligns the element to the start of the container (left in LTR, right in RTL layout). */ readonly START: "START"; /** Aligns the element to the end of the container (right in LTR, left in RTL layout). */ readonly END: "END"; }; declare const allowedTextComparisonInnerToolbarItem: string[]; declare const allowedTextComparisonToolbarItem: string[]; declare const allowedToolbarTypes: ((typeof extraToolbarTypes)[number] | (typeof defaultToolbarTypes)[number])[]; /** * @class * Base annotation type from which all annotations inherit. You can not instantiate from this type. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record}. * @public * @summary Base annotation type from which all annotations inherit. * @hideconstructor * @abstract * @see {@link NutrientViewer.Instance#getSelectedAnnotations} | {@link NutrientViewer.Instance#setSelectedAnnotations} * @see {@link NutrientViewer.Instance#setEditableAnnotationTypes} | {@link NutrientViewer.Instance#setIsEditableAnnotation} * @see {@link NutrientViewer.Instance#create} | {@link NutrientViewer.Instance#delete} * @see {@link NutrientViewer.Instance#getAnnotations} | {@link NutrientViewer.Instance#ensureChangesSaved} * @see {@link NutrientViewer.Instance#hasUnsavedChanges} | {@link NutrientViewer.Instance#save} * @see {@link NutrientViewer.Instance#setAnnotationCreatorName} | {@link NutrientViewer.Instance#update} * @see {@link Configuration#editableAnnotationTypes} | {@link Configuration#isEditableAnnotation} * @see {@link NutrientViewer.EventName.ANNOTATIONS_LOAD} | {@link NutrientViewer.EventName.ANNOTATIONS_CHANGE} * @see {@link NutrientViewer.EventName.ANNOTATIONS_CREATE} | {@link NutrientViewer.EventName.ANNOTATIONS_UPDATE} * @see {@link NutrientViewer.EventName.ANNOTATIONS_DELETE} | {@link NutrientViewer.EventName.ANNOTATIONS_PRESS} * @see {@link NutrientViewer.EventName.ANNOTATIONS_WILL_SAVE} | {@link NutrientViewer.EventName.ANNOTATIONS_DID_SAVE} * @see {@link NutrientViewer.EventName.ANNOTATIONS_FOCUS} | {@link NutrientViewer.EventName.ANNOTATIONS_BLUR} * @see {@link NutrientViewer.EventName.ANNOTATIONS_WILL_CHANGE} | {@link NutrientViewer.EventName.ANNOTATION_SELECTION_CHANGE} */ export declare class Annotation extends InheritableImmutableRecord { /** * A unique identifier to describe the annotation. When an annotation is created in the UI, the * viewer has to generate a unique ID. * * When changes are saved to the underlying annotation provider, we call * {@link Instance#ensureChangesSaved} to make sure the annotation has been persisted * from the provider. */ id: ID; /** * An optional field that may be used to identify the annotation. * * By default, we'll set that to the same value as the automatically generated * {@link Annotation#id}. */ name: null | string; /** * An optional annotation subject, representing a short description of * the subject being addressed by the annotation. This property has no effect * on the annotation rendering. */ subject: null | string; /** * When the annotation is extracted directly from a PDF file, the `pdfObjectId` refers to the * identifier that was used in the PDF document. * * This ID is optional since newly created annotations using the SYNCProvider annotation provider * won't have a `pdfObjectId` assigned. * * @default null */ pdfObjectId: null | number; /** * The page index on which the annotation is placed. It's important to notice that an annotation * can only ever be on one page. If you create for example an ink annotation with lines on two * pages, two annotation records will be created. * * `pageIndex` is zero-based and has a maximum value of `totalPageCount - 1`. */ pageIndex: number; /** * Position of this annotation on the page. It's necessary that this spans all visible points of * the annotation, otherwise hit testing and other features may not work. */ boundingBox: Rect; /** * A transparency value that is applied to the complete annotation. The value is capped between 0 * and 1 inclusive. * * @default 1 */ opacity: number; /** * An optional note that can be set on any annotation. * * This value is displayed in the Nutrient Web SDK UI for all annotations except * {@link NutrientViewer.Annotations.NoteAnnotation | NoteAnnotation}, {@link NutrientViewer.Annotations.TextAnnotation | TextAnnotation}, {@link NutrientViewer.Annotations.WidgetAnnotation | WidgetAnnotation} and {@link NutrientViewer.Annotations.CommentMarkerAnnotation | CommentMarkerAnnotation}. */ note: null | string; /** * The name of the creator of the annotation. This is a general purpose string which can easily be * spoofed and might not reflect the actual creator of the annotation. */ creatorName: null | string; /** * The date of the annotation creation. */ createdAt: Date; /** * The date of last annotation update. */ updatedAt: Date; /** * The annotation flag that prevents the annotation from being rendered in the UI. * * The annotation may still be part of the printed page, depending of the value of the * {@link Annotations.Annotation#noPrint} flag. * * @default false */ noView: boolean; /** * The annotation flag that prevents the annotation from being printed. * * @default false */ noPrint: boolean; /** * The annotation flag that prevents the annotation from being modified. * * @default false */ locked: boolean; /** * The annotation flag that prevents the annotation content from being modified. * * @default false */ lockedContents: boolean; /** * The annotation flag that makes the annotation read only. * * @default false */ readOnly: boolean; /** * If set, do not display or print the annotation or allow it to interact with the user. * * @default false */ hidden: boolean; /** * Annotations can store additional user-specified data. * * NutrientViewer will not use or evaluate `customData` in the UI directly. * You have full control over this property. For new annotations, this defaults to null. * * customData will be stored as JSON through `JSON.serialize()` and `JSON.parse()`, and * so must be a plain JSON-serializable object. * * @example * Adding a new {@link EllipseAnnotation} with custom data attached: * ```ts * const annotation = new NutrientViewer.Annotations.EllipseAnnotation({ * pageIndex: 0, * boundingBox: new NutrientViewer.Geometry.Rect({ * top: 10, * left: 10, * width: 100, * height: 100 * }), * customData: { * circleId: "my-circle" * } * }); * ``` */ customData: null | Record; noZoom: boolean; noRotate: boolean; additionalActions: AnnotationAdditionalActionsType | null; rotation: number; /** * The blend mode defines how the color of the annotation will be applied to its background. * * @default "normal" */ blendMode: IBlendMode; isCommentThreadRoot: boolean; isAnonymous: boolean; /** * This property is used to define the permission scope for this annotation. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ group?: string | null; /** * This property defines whether this annotation can be edited or not. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly isEditable?: boolean; /** * This property defines whether this annotation can be deleted or not. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly isDeletable?: boolean; /** * This property defines whether the user has permission to edit the group of this annotation. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly canSetGroup?: boolean; canReply?: boolean; APStreamCache?: { cache: string; } | { attach: string; }; action: Action | null; constructor(options?: Partial); } declare namespace Annotation_2 { export { Annotation, HighlightAnnotation, ImageAnnotation, InkAnnotation, ShapeAnnotation, LineAnnotation, RectangleAnnotation, EllipseAnnotation, PolygonAnnotation, PolylineAnnotation, LinkAnnotation, NoteAnnotation, SquiggleAnnotation, StampAnnotation, StrikeOutAnnotation, TextAnnotation, TextMarkupAnnotation, UnderlineAnnotation, UnknownAnnotation, WidgetAnnotation, CommentMarkerAnnotation, RedactionAnnotation, MediaAnnotation }; } /** @inline */ declare type AnnotationAdditionalActionsType = { onPointerEnter?: Action; onPointerLeave?: Action; onPointerDown?: Action; onPointerUp?: Action; onPageOpen?: Action; onPageClose?: Action; onPageVisible?: Action; onPageHidden?: Action; }; /** @inline */ declare type AnnotationBackendJSON = { [P in keyof K]?: NonNullable } & { [P in Intersection]-?: Exclude, undefined> }; declare type AnnotationJSONToAnnotation = AnnotationSerializerTypeMap[GetTypeFromAnnotationJSON]['annotation']; /** * @deprecated Use {@link Serializers.AnnotationJSONUnion} instead. * @hidden */ export declare type AnnotationJSONUnion = Serializers.AnnotationJSONUnion; /** * @class * * Represents an annotation note. Used as a note annotation when hovering over note icon or when * the note icon is selected. This annotation is not persisted in the document nor returned by the public API. */ declare class AnnotationNote extends NoteAnnotation { /** * Root annotation this note belongs to. */ parentAnnotation?: AnnotationsUnion; /** * Calculated position of this note on the page in PDF coordinates. */ position: Point; notePosition?: Point; } /** @inline */ declare interface AnnotationNoteProps extends INoteAnnotation { parentAnnotation: AnnotationsUnion | null; position: Point; notePosition?: Point; } declare function AnnotationPermissionMixin>(Base: T): { new (...args: any[]): { /** * Returns a deep copy of the latest editableAnnotationTypes. This value changes whenever * {@link Instance.setEditableAnnotationTypes} is called. * * Mutating this object will have no effect. * * @public */ readonly editableAnnotationTypes: Set_2>; /** * This method is used to update the editable annotation types. * * When one of the supplied {@link NutrientViewer.Annotations.Annotation} is invalid, this method will throw an * {@link Error} that contains a detailed error message. * * @example * ```ts * // Only allow editing ink annotations * instance.setEditableAnnotationTypes([NutrientViewer.Annotations.InkAnnotation]); * instance.editableAnnotationTypes === [NutrientViewer.Annotations.InkAnnotation]; // => true * ``` * * @public * @throws {Error} Will throw an error when the supplied array is not valid. */ setEditableAnnotationTypes(editableAnnotationTypes: Class[]): void; /** * This method is used to update the isEditableAnnotation callback * * When the supplied callback is invalid it will throw a {@link Error} that contains a * detailed error message. * * @example * Only allow editing annotations from a specific creator name * ```ts * instance.setIsEditableAnnotation((annotation) => annotation.creatorName === "Alice"); * ``` * * @public * @throws {Error} Will throw an error when the supplied array is not valid. */ setIsEditableAnnotation(isEditableAnnotationCallback: IsEditableAnnotationCallback): void; }; } & T; /** * Describes and persists the properties of an annotation preset. * * Annotation presets are sets of property-value pairs for annotations that can be applied as default * annotations settings for toolbar items. When an annotation toolbar setting is changed by the user, * the annotation preset associated with the toolbar item that triggered the annotation toolbar is updated. * If the associated annotation preset doesn't exist, it's created with the settings that have changed. * * For properties not included in an annotation preset, the default values used when creating * an annotation are those of the annotation type. * * @example * Creating an annotation preset and adding it to the available annotation presets. * ```ts * const myAnnotationPresets = instance.annotationPresets * myAnnotationPresets['my-annotation-preset'] = { * strokeWidth: 2, * } * instance.setAnnotationPresets(myAnnotationPresets); * ``` * * @summary Annotation preset properties. * @see {@link Configuration#annotationPresets} * @see {@link Instance#setAnnotationPresets} * @see {@link Events.AnnotationPresetsUpdateEvent} */ export declare type AnnotationPreset = Record; declare type AnnotationPreset_2 = AnnotationPreset; /** * This callback can be used in the {@link NutrientViewer.Instance#setAnnotationPresets | setAnnotationPresets()} * method to do atomic updates to the current annotation presets. * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setAnnotationPresets(presets => { * presets.custom = { * strokeWidth: 10, * }; * return presets; * }); * ``` * * @param currentAnnotationPresets - The current annotation presets * @returns The new annotation presets */ export declare type AnnotationPresetCallback = (currentAnnotationPresets: Record) => Record; /** @inline */ declare type AnnotationPresetID = string; declare type AnnotationPresetID_2 = AnnotationPresetID; export declare namespace AnnotationPresets { export { serializePreset as toSerializableObject, unserializePreset as fromSerializableObject }; } declare function AnnotationPresetsMixin>(Base: T): { new (...args: any[]): { /** * Returns a deep copy of the latest annotation presets. This value changes whenever the user * interacts with NutrientViewer or whenever {@link Instance.setAnnotationPresets} is called. * * Mutating this object will have no effect. */ readonly annotationPresets: { [key: string]: AnnotationPreset; }; /** * Get the current active annotation preset ID */ readonly currentAnnotationPreset: string | null | undefined; /** * This method is used to update the annotation presets. * * It makes it possible to add new {@link AnnotationPreset | annotation presets} and edit or remove existing ones. * * When you pass in an `object` with keyed {@link AnnotationPreset}, the current annotation presets * will be immediately updated. Calling this method is also idempotent. * * If you pass in a function, it will be immediately invoked and will receive the current annotation presets as argument. You can use this to modify the object based on its * current value. This type of update is guaranteed to be atomic - the value of `currentAnnotationPresets` can't change in between. See: {@link AnnotationPresetCallback} * * When one of the supplied {@link AnnotationPreset} is invalid, this method will throw an {@link Error} that contains a detailed error message. * * Since `annotationPresets` is a regular JavaScript `object`, it can be manipulated using standard `Object` * methods. * * @example * The new changes will be applied immediately * ```ts * instance.setAnnotationPresets(newAnnotationPresets); * instance.annotationPresets === newAnnotationPresets; // => true * ``` * * @example * Adding an annotation preset for an ellipse annotation variant. * ```ts * const myAnnotationPreset = { * dashedEllipse: { * strokeDashArray: [3, 3], * } * } * instance.setAnnotationPresets(annotationPresets => ({ ...annotationPresets, myAnnotationPreset })) * ``` * * @throws {Error} Will throw an error when the supplied annotation preset `object` is not valid. * @param stateOrFunction - Either a * new AnnotationPresets `object` which would overwrite the existing one, or a callback that will get * invoked with the current annotation presets and is expected to return the new annotation presets `object`. */ setAnnotationPresets(stateOrFunction: Record | AnnotationPresetCallback): void; /** * This method is used to set the current active annotation preset. * * It makes it possible to specify what annotation preset should be used when new annotations * are created in the UI by passing the annotation preset key string as argument. * * The current annotation preset is set when the toolbar annotation buttons are used to create * annotations. This method allows to set the current annotation preset programmatically, as well * as resetting it by passing `null` as argument. * * When the supplied key does not correspond with an existing {@link AnnotationPreset}, * this method will throw an {@link Error} that contains a detailed error message. * * @example * The new changes will be applied immediately * ```ts * instance.setCurrentAnnotationPreset("ink"); * instance.currentAnnotationPreset === "ink"; // => true * ``` * * @example * Setting an annotation preset for a closed arrow line annotation. * ```ts * instance.setAnnotationPresets(annotationPresets => { * return { * ...annotationPresets, * line: { * ...annotationPresets.line, * lineCaps: { * end: "closedArrow" * } * } * } * }); * instance.setCurrentAnnotationPreset("line"); * instance.setViewState(viewState => * viewState.set("interactionMode", NutrientViewer.InteractionMode.SHAPE_LINE), * ); * ``` * * @public * @param annotationPresetID - Annotation preset name. * @throws {Error} Will throw an error when the supplied annotation preset key does not exist. */ setCurrentAnnotationPreset(annotationPresetID?: string | null): void; }; } & T; /** @inline */ declare type AnnotationProperties = { id: string | null; name: string | null; subject: string | null; pdfObjectId: number | null; pageIndex: number | null; boundingBox: Rect | null; opacity: number | null; note: string | null; creatorName: string | null; createdAt: Date | null; updatedAt: Date | null; customData: Record | null; noView: boolean | null; noPrint: boolean | null; locked: boolean | null; lockedContents: boolean | null; readOnly: boolean | null; hidden: boolean | null; group: string | null | undefined; isEditable: boolean | undefined; isDeletable: boolean | undefined; canSetGroup: boolean | undefined; canReply: boolean | undefined; rotation: number; additionalActions: AnnotationAdditionalActionsType | null; noZoom: boolean; noRotate: boolean; isCommentThreadRoot: boolean; isAnonymous: boolean; APStreamCache: { cache: string; } | { attach: string; } | undefined; blendMode: IBlendMode; action: Action | null; [key: string]: unknown; }; declare type AnnotationReference = { fieldName: string; } | { pdfObjectId: number; }; /** * This callback is called whenever an annotation is about to be resized. You can use it to control resize behavior. * * @public * @param event - The event containing information regarding the resizing of the annotation * @returns The configuration of the resize behavior or undefined for default behavior. */ export declare type AnnotationResizeStartCallback = (event: AnnotationsResizeEvent) => AnnotationResizeStartCallbackConfiguration | undefined; /** * The configuration of the resizing behavior of the annotations * * @public * @inline */ declare type AnnotationResizeStartCallbackConfiguration = { /** Set to `true` to keep aspect ratio while resizing. */ maintainAspectRatio?: boolean; /** Minimum width of the annotation while resizing. */ minWidth?: number | undefined; /** Minimum height of the annotation while resizing. */ minHeight?: number | undefined; /** Maximum width of the annotation while resizing. */ maxWidth?: number | undefined; /** Maximum height of the annotation while resizing. */ maxHeight?: number | undefined; }; export declare namespace Annotations { export { fromSerializableObject, rotate, serializeAnnotation as toSerializableObject, Annotation, CommentMarkerAnnotation, EllipseAnnotation, HighlightAnnotation, ImageAnnotation, InkAnnotation, LineAnnotation, LinkAnnotation, TextMarkupAnnotation as MarkupAnnotation, MediaAnnotation, NoteAnnotation, PolygonAnnotation, PolylineAnnotation, RectangleAnnotation, RedactionAnnotation, ShapeAnnotation, SquiggleAnnotation, StampAnnotation, StrikeOutAnnotation, TextAnnotation, UnderlineAnnotation, UnknownAnnotation, WidgetAnnotation }; } declare type AnnotationsBackendJSONUnion = AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON | AnnotationBackendJSON; declare function AnnotationSelectionMixin>(Base: T): { new (...args: any[]): { /** * If multiple annotations are selected, this function will return the set of selected annotations. */ getSelectedAnnotations(): List | null; /** * Selects annotations in the user interface. If `annotationOrAnnotationId` is empty, the * current selection will be cleared instead. * * @param annotationsOrAnnotationsIds - The annotations * model or annotations IDs you want to set as selected. If `null` is used, the current selection * will be cleared instead. */ setSelectedAnnotations(annotationsOrAnnotationsIds?: List | null): void; /** * Group annotations in the user interface. * * @param annotationsOrAnnotationsId - The annotations * model or annotations IDs you want to be grouped. Annotations selected for grouping must be on the same page. * Annotations that are already grouped will be removed from the previous group and added to the new one. */ groupAnnotations(annotationsOrAnnotationsId?: List): void; /** * This function will return all annotations groups, if there are any annotations groups. * * @returns Annotations groups */ getAnnotationsGroups(): Map_2; }> | null; /** * If there are any annotations groups, this function will return all annotations groups. * deleteAnnotationsGroup * * @param annotationGroupId - The annotation group id. */ deleteAnnotationsGroup(annotationGroupId: string | null | undefined): void; /** * Selects an annotation in the user interface and enters edit mode. If `annotationOrAnnotationId` is empty, the * current selection will be cleared instead. * * This method works with {@link NutrientViewer.Annotations.TextAnnotation} and {@link NutrientViewer.Annotations.NoteAnnotation}. * When called with other annotation types that don't have any text it will simply select the annotation. * * @param annotationOrAnnotationId - The annotation * model or annotation ID you want to set as selected. If `null` is used, the current selection * will be cleared instead. * @param autoSelectText - Whether the text should be automatically selected. */ setEditingAnnotation(annotationOrAnnotationId?: (AnnotationsUnion | ID) | null, autoSelectText?: boolean | null): void; }; } & T; declare class AnnotationSerializer { static VERSION: number; annotation: AnnotationsUnion; constructor(annotation: AnnotationsUnion); toJSON(): Omit; static fromJSON(id: ID | null, json: IAnnotationJSON, options?: ICollaboratorPermissionsOptions): { group?: string | null | undefined; canSetGroup?: boolean; isEditable?: boolean; isDeletable?: boolean; blendMode?: IBlendMode | undefined; id: string | null; name: string | null; subject: string | null; pdfObjectId: number | null; pageIndex: number; opacity: number; boundingBox: Rect; noPrint: boolean; noZoom: boolean; noRotate: boolean; noView: boolean; hidden: boolean; locked: boolean; lockedContents: boolean; readOnly: boolean; action: Action | null | undefined; note: string | null; createdAt: Date; updatedAt: Date; creatorName: string | null; customData: Record | null; isCommentThreadRoot: boolean; isAnonymous: boolean; }; static blendModeObjectForAnnotation(json: IAnnotationJSON): { blendMode: IBlendMode; } | null; serializeFlags(): ("noView" | "noPrint" | "locked" | "lockedContents" | "readOnly" | "hidden" | "noZoom" | "noRotate")[] | null; } declare type AnnotationSerializerTypeMap = { 'pspdfkit/ink': { serializer: InkAnnotationSerializer; annotation: InkAnnotation; json: Serializers.InkAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/shape/line': { serializer: LineAnnotationSerializer; annotation: LineAnnotation; json: Serializers.LineAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/shape/rectangle': { serializer: RectangleAnnotationSerializer; annotation: RectangleAnnotation; json: Serializers.RectangleAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/shape/ellipse': { serializer: EllipseAnnotationSerializer; annotation: EllipseAnnotation; json: Serializers.EllipseAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/shape/polygon': { serializer: PolygonAnnotationSerializer; annotation: PolygonAnnotation; json: Serializers.PolygonAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/shape/polyline': { serializer: PolylineAnnotationSerializer; annotation: PolylineAnnotation; json: Serializers.PolylineAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/link': { serializer: LinkAnnotationSerializer; annotation: LinkAnnotation; json: Serializers.LinkAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/markup/highlight': { serializer: TextMarkupAnnotationSerializer; annotation: HighlightAnnotation; json: Serializers.TextMarkupAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/markup/squiggly': { serializer: TextMarkupAnnotationSerializer; annotation: SquiggleAnnotation; json: Serializers.TextMarkupAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/markup/strikeout': { serializer: TextMarkupAnnotationSerializer; annotation: StrikeOutAnnotation; json: Serializers.TextMarkupAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/markup/underline': { serializer: TextMarkupAnnotationSerializer; annotation: UnderlineAnnotation; json: Serializers.TextMarkupAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/markup/redaction': { serializer: RedactionAnnotationSerializer; annotation: RedactionAnnotation; json: Serializers.RedactionAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/text': { serializer: TextAnnotationSerializer; annotation: TextAnnotation; json: Serializers.TextAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/note': { serializer: NoteAnnotationSerializer; annotation: NoteAnnotation; json: Serializers.NoteAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/image': { serializer: ImageAnnotationSerializer; annotation: ImageAnnotation; json: Serializers.ImageAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/stamp': { serializer: StampAnnotationSerializer; annotation: StampAnnotation; json: Serializers.StampAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/widget': { serializer: WidgetAnnotationSerializer; annotation: WidgetAnnotation; json: Serializers.WidgetAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/comment-marker': { serializer: CommentMarkerAnnotationSerializer; annotation: CommentMarkerAnnotation; json: Serializers.CommentMarkerAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/unknown': { serializer: UnknownAnnotationSerializer; annotation: UnknownAnnotation; json: Serializers.UnknownAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; 'pspdfkit/media': { serializer: MediaAnnotationSerializer; annotation: MediaAnnotation; json: Serializers.MediaAnnotationJSON; jsonForBackend: AnnotationBackendJSON; }; }; declare function AnnotationsMixin>(Base: T): { new (...args: any[]): { /** * Returns a {@link NutrientViewer.Immutable.List} of {@link NutrientViewer.Annotations.Annotation} for the given * `pageIndex`. * * The list contains an immutable snapshot of the currently available annotations in the UI for * the page. This means, that the returned list could include *invalid* annotations. Think for * example of the following workflow: * * 1. The user creates a new text annotation on a page. * 2. Now, the users double clicks the annotation and removes the text. The annotation is now * invalid since it does not have any text. But since the annotation is not yet deselected, * we will keep it visible. * 3. Next, the user updates the color of the text by using the annotation toolbar. The * annotation will still be invalid although a change occurred. * 4. At the end, the user decides to type more text and deselects the annotation again. The * annotation is now valid. * * When you want to keep a reference to the latest annotations, you can listen for * - {@link NutrientViewer.EventName.ANNOTATIONS_CHANGE}, * - {@link NutrientViewer.EventName.ANNOTATIONS_WILL_SAVE}, or * - {@link NutrientViewer.EventName.ANNOTATIONS_DID_SAVE} to update your reference. * * If annotations for this page have not been loaded yet, the promise will resolve only after * we have received all annotations. * * @example * instance.getAnnotations(0).then(function (annotations) { * annotations.forEach(annotation => { * console.log(annotation.pageIndex); * }); * * // Filter annotations by type * annotations.filter(annotation => { * return annotation instanceof NutrientViewer.Annotations.InkAnnotation; * }) * * // Filter annotations at a specific point * const pointInFirstPage = new NutrientViewer.Geometry.Point({ x: 20, y: 30 }); * const annotationsAtPointInPage = annotationsOnFirstPage.filter(annotation => { * return annotation.boundingBox.isPointInside(pointInFirstPage); * }); * * // Get the number of currently loaded annotations * const totalAnnotations = annotations.size; * }) * * @param pageIndex - The page index for the annotations you want. * `pageIndex` is zero-based and has a maximum value of `totalPageCount - 1` * @returns Resolves to annotations for the given page. */ getAnnotations(pageIndex: number): Promise>; /** * Creates a new attachment and returns a Promise that resolves to the created attachments ID. * * @example * NutrientViewer.load(configuration).then(function(instance) { * instance.createAttachment(blob).then(function(attachmentId) { * console.log(attachmentId); * }); * }) * * @throws {Error} Will throw an error when the file can not be read. * @param blob - The attachment data as a Blob object. * @returns A promise that resolves to the attachment ID. */ createAttachment(blob: Blob): Promise; /** * Fetches an attachment or an embedded file based on its ID. * * @public * @example * NutrientViewer.load(configuration).then(function(instance) { * instance.getAttachment("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad").then(function(image) { * console.log(image); * }); * }) * * @throws {Error} Will throw an error when the file can not be read. * @param attachmentId - The ID of the attachments or embedded files that should be fetched. * @returns A promise that resolves to the attachment data. */ getAttachment(attachmentId: string): Promise; /** * Takes a {@link NutrientViewer.Annotations.TextAnnotation} and returns a new * {@link NutrientViewer.Annotations.TextAnnotation} where the bounding box is adjusted to fit the * annotation and inside the page. * * This is using the same calculations as the text annotation editor interface. * * @public * @example * textAnnotation = instance.calculateFittingTextAnnotationBoundingBox(textAnnotation); * * @param annotation - The text annotation that needs its * bounding box adjusted. * @returns The text annotation that has it's bounding box adjusted. */ calculateFittingTextAnnotationBoundingBox(annotation: TextAnnotation): TextAnnotation; /** * Returns a list containing the information of all the embedded files in the PDF. * * If you want to get the content of a particular embedded file, you can use {@link NutrientViewer.Instance#getAttachment} * * ```js * const embeddedFiles = await instance.getEmbeddedFiles() * * const fileContent = await instance.getAttachment(embeddedFiles.get(0).attachmentId) * ``` * * @example * const embeddedFilesInfo = await instance.getEmbeddedFiles(); * * @returns List of embedded files in the document with their individual information. */ getEmbeddedFiles(): Promise>; /** * This method is used to update the setOnAnnotationResizeStart callback * * When the supplied callback is invalid it will throw a {@link NutrientViewer.Error} that contains a * detailed error message. */ setOnAnnotationResizeStart(setOnAnnotationResizeStartCallback: AnnotationResizeStartCallback): void; /** * Returns a {@link NutrientViewer.Immutable.List} of {@link NutrientViewer.Annotations} for the given * form field or annotation. * * The list contains an immutable snapshot of the currently overlapping annotations for * the argument. * * If annotations for this page have not been loaded yet, the promise will resolve only after * we have received all annotations. * * @example * Get signature overlapping a signature form field * ```ts * * // The name of the field you want to check. * const formFieldName = "signature"; * * // First get all `FormFields` in the `Document`. * const formFields = await instance.getFormFields(); * * // Get a signature form with the specific name you want. * const field = formFields.find( * (formField) => * formField.name === formFieldName && formField instanceof NutrientViewer.FormFields.SignatureFormField * ); * * // Check if the signature form field has been signed * await instance.getOverlappingAnnotations(field); * // It will result in a list of annotations that overlaps the given signature form field. * // If no annotation overlaps the form field, the list will be empty. * ``` * * @example * Get annotations overlapping an ink annotation * ```ts * * const annotations = instance.getAnnotations(0); * const inkAnnotation = annotations.find( * (annotation) => * annotation instanceof NutrientViewer.Annotation.InkAnnotation * ); * await instance.getOverlappingAnnotations(inkAnnotation); * // It will result in a list of annotations that overlaps the given signature form field. * // If no annotation overlaps the form field, the list will be empty. * ``` * * @param annotationOrFormField - The annotation or the form field that needs to be checked for overlapping annotations. * @returns Resolves to a list of the annotations that overlap the given argument. */ getOverlappingAnnotations(annotationOrFormField: AnnotationsUnion | FormField): Promise>; }; } & T; /** * This event is emitted whenever an annotation is about to be resized. * * You can use this event to add custom resize behavior for individual annotations. * * @example * Log text annotation value * ```ts * instance.setOnAnnotationResizeStart((event) => { * if (event.annotation instanceof NutrientViewer.Annotations.TextAnnotation) { * return { * maintainAspectRatio: true * } * } * }); * ``` */ export declare type AnnotationsResizeEvent = { /** * The annotation that is resizing. * * Remember that annotations are `Immutable.map`. */ annotation: AnnotationsUnion; /** * This boolean represents if the user is holding the shift key. */ isShiftPressed: boolean; /** * This holds the name of the anchor the user is using the resize the annotation. */ resizeAnchor: ResizeAnchor; }; /** * The annotations sidebar options allows to specify options available for the annotations sidebar. * Currently, you can define a `includeContent` array in which you * can provide a list of annotation classes to be accepted as part of * the annotations sidebar, or also whether to include {@link Comment} * instances or not. By default, the value of `includeContent` is {@link NutrientViewer.defaultAnnotationsSidebarContent}. * * @summary Options available to the annotations sidebar * @example * Customizing the annotations sidebar to include only {@link NutrientViewer.Annotations.ImageAnnotation} instances * ```ts * NutrientViewer.load({ * initialViewState: new NutrientViewer.ViewState({ * sidebarOptions: { * [NutrientViewer.SidebarMode.ANNOTATIONS]: { * includeContent: [NutrientViewer.Annotations.ImageAnnotation] * } * } * }) * }); * ``` * * @default NutrientViewer.defaultAnnotationsSidebarContent * @see {@link ViewState#sidebarOptions} */ export declare type AnnotationsSidebarOptions = { /** * Array of annotation classes to be accepted as part of the annotations sidebar */ includeContent: Array>; }; export declare type AnnotationsUnion = InkAnnotation | LineAnnotation | RectangleAnnotation | EllipseAnnotation | PolygonAnnotation | PolylineAnnotation | LinkAnnotation | HighlightAnnotation | UnderlineAnnotation | StrikeOutAnnotation | SquiggleAnnotation | RedactionAnnotation | TextAnnotation | NoteAnnotation | ImageAnnotation | StampAnnotation | WidgetAnnotation | CommentMarkerAnnotation | UnknownAnnotation | MediaAnnotation; /** @inline */ declare type AnnotationsUnionClass = Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class | Class; /** * Indicates the reason why {@link Events.AnnotationsWillChangeEvent} was * emitted. */ export declare enum AnnotationsWillChangeReason { /** * The user starts drawing an annotation. */ DRAW_START = "DRAW_START", /** * The user stops drawing an annotation. */ DRAW_END = "DRAW_END", /** * The user starts typing text into an annotation. */ TEXT_EDIT_START = "TEXT_EDIT_START", /** * The user stops typing text into an annotation. */ TEXT_EDIT_END = "TEXT_EDIT_END", /** * The user starts choosing an item from the picker presented. * * Used for image annotations, stamp annotations and ink signature annotations. * * Note that the annotation included in this event will not have any matching * field values (including ID) compared to the annotation in a * {@link NutrientViewer.AnnotationsWillChangeReason.SELECT_END} event. This is * because the actual annotation hasn't been created yet. As a result, this * annotation is used only to identify the type of annotation being selected. * The only exception to this is the `inkSignature` field in a * {@link NutrientViewer.Annotations.InkAnnotation}, which is set to `true` to * distiguish it from a regular ink annotation. */ SELECT_START = "SELECT_START", /** * The user stops choosing an item from the picker presented. * * Used for image annotations, stamp annotations and ink signature * annotations. * * Note= An empty {@link Events.AnnotationsWillChangeEvent#annotations} * list indicates that the selection was cancelled. * * Note that this will not be fired when cancelling the system dialog for * selecting an image, because there is no way to detect when this occurs. */ SELECT_END = "SELECT_END", /** * The user starts moving an annotation around. */ MOVE_START = "MOVE_START", /** * The user stops moving an annotation around. */ MOVE_END = "MOVE_END", /** * The user starts resizing an annotation. */ RESIZE_START = "RESIZE_START", /** * The user stops resizing an annotation. */ RESIZE_END = "RESIZE_END", /** * The user starts rotating an annotation. */ ROTATE_START = "ROTATE_START", /** * The user stops rotating an annotation. */ ROTATE_END = "ROTATE_END", /** * The user initiates the delete process. This * will be emitted when the deletion confirmation * dialog appears. */ DELETE_START = "DELETE_START", /** * The user ends the delete process. This * will be emitted when the user confirms * or cancels the intention to delete an * annotation. * * An empty {@link Events.AnnotationsWillChangeEvent#annotations} * list indicates that the deletion was cancelled. */ DELETE_END = "DELETE_END", /** * The value of one of the properties of the * annotation is changed by the user. e.g. the * color or the stroke width. */ PROPERTY_CHANGE = "PROPERTY_CHANGE", } declare function AnnotationTabOrderMixin>(Base: T): { new (...args: any[]): { /** * *** Standalone only *** * * This method is used to retrieve the tab order of annotations in a given page. * * The tab order will be returned as an array of annotation IDs. * * In the case of widget annotations associated to a radio form field, all the widgets * associated to the same form field are rendered next to the first one found * in the provided `Array` of annotation IDs. * * @example * Get the tab order of annotations in page 0 * ```ts * instance.getPageTabOrder(0); * ``` * * @throws {Error} Will throw an error when the supplied page index is not a number. * @param pageIndex * @returns A promise that resolves to an ordered array of annotation IDs. */ getPageTabOrder(pageIndex: number): Promise; /** * *** Standalone only *** * * This method is used to set or modify the tab order of annotations in a given page. * * Using this method, it is possible to specify the order in which annotations are navigated when using the keyboard. * The tab order should be provided as an array of annotation IDs, or determined by a callback function. * * The method accepts a page index as the first argument, and a callback as the second. This callback will * be called with an array of annotations in the page sorted by their current tab order, and should return * an array of those annotations' `id`s following the new tab order. * * In the case of widget annotations associated to a radio form field, all the widgets associated to the same * form field will be rendered next to the first one found in the provided array of annotation IDs, and navigated accordingly. * * @example * Set the tab order of annotations in page 0 * ```ts * instance.setPageTabOrder(0, currentTabOrderedAnnotations => * ["annotation-id-1", "annotation-id-2"] * ); * ``` * * @example * Set the tab order of annotations in page 0, with a radio form field * ```ts * // 'radio-widget-id-2' will be rendered next to 'radio-widget-id-1', and navigated accordingly * instance.setPageTabOrder(0, currentTabOrderedAnnotations => * ["radio-widget-id-1", "annotation-id-1", "annotation-id-2", "radio-widget-id-2"] * ); * ``` * * @example * Sort page 1 annotations by their left position * ```ts * instance.setPageTabOrder( * 1, * currentTabOrderedAnnotations => currentTabOrderedAnnotations * .sort((a, b) => a.boundingBox.left - b.boundingBox.left) * .map(annotation => annotation.id) * ); * ``` * * @standalone * @throws {Error} Will throw an error when the supplied tab order is not valid. * @param pageIndex - The page index to set the tab order for. * @param annotationIdsSortCallback - A callback that will be invoked with the annotations in the current tab order, * and is expected to return the annotation IDs in the new tab order. */ setPageTabOrder(pageIndex: number, annotationIdsSortCallback: (tabOrderedAnnotations: AnnotationsUnion[]) => ID[]): Promise; }; } & T; /** @inline */ declare type AnnotationToolbarColorPresetConfig = { /** The array of colors to be displayed in a customized color picker dropdown */ presets: ColorPreset[]; /** Defines whether you want to render the custom color picker UI. The default value is `true`, meaning that by default we render the custom color picker in the color dropdown. */ showColorPicker?: boolean; }; /** * This callback allows users to customize the colors that will be displayed in our color dropdown picker, and to add a custom color picker UI to it. * * @returns The configuration of the customized color picker * @example * Customize different color dropdowns. * ```ts * NutrientViewer.load({ * annotationToolbarColorPresets: function ({ propertyName }) { * if (propertyName === "font-color") { * return { * presets: [ * { * color: new NutrientViewer.Color({ r: 0, g: 0, b: 0 }), * localization: { * id: "brightRed", * defaultMessage: "Bright Red", * }, * }, * { * color: new NutrientViewer.Color({ r: 100, g: 100, b: 180 }), * localization: { * id: "deepBlue", * defaultMessage: "deepBlue", * }, * }, * ], * }; * } * * if (propertyName === "stroke-color") { * return { * presets: [ * { * color: new NutrientViewer.Color({ r: 0, g: 0, b: 0 }), * localization: { * id: "brightRed", * defaultMessage: "Bright Red", * }, * }, * { * color: new NutrientViewer.Color({ r: 100, g: 100, b: 180 }), * localization: { * id: "deepBlue", * defaultMessage: "deepBlue", * }, * }, * ], * showColorPicker: false, * }; * } * }, * //... *}); * ``` * */ export declare type AnnotationToolbarColorPresetsCallback = (options: { /** * options.propertyName The annotation property for which we need to render a customized array of colors in the color dropdown. * The built-in color properties are: * * - 'color' * - 'stroke-color' * - 'fill-color' * - 'background-color' * - 'font-color' * - 'outline-color' * * Different annotations have different color properties, but all of them are listed above. If you pass a color property that it's not supported, you will get an error. */ propertyName: BuiltInColorProperty; /** array of default colors */ defaultAnnotationToolbarColorPresets: ColorPreset[]; }) => AnnotationToolbarColorPresetConfig | undefined; /** * Describes the properties of a Annotation Toolbar Item. * * Check out [our guides](https://www.nutrient.io/guides/web/customizing-the-interface/configure-the-annotation-toolbar/) * for more examples. * * @see {@link Instance#setAnnotationToolbarItems} | {@link Configuration#annotationToolbarItems} */ export declare type AnnotationToolbarItem = NodeAnnotationToolbarItem | IconAnnotationToolbarItem; /** * This callback can be run on individual annotation toolbars to modify their toolbar items. * * For more information, see {@link Configuration.annotationToolbarItems} * * @param annotation - The annotation that is going to be created or is currently selected. In case * the annotation is not yet created, `pageIndex` is `null`. In case of items for annotation toolbars used in interaction modes * like {@link NutrientViewer.InteractionMode.INK_ERASER}, `annotation` is `null`. * @param options - The object that can be helpful in implementing custom toolbar. */ export declare type AnnotationToolbarItemsCallback = (annotation: AnnotationsUnion | null, options: { /** The list of default items that are shown for this particular annotation. */ defaultAnnotationToolbarItems: BuiltInAnnotationToolbarItem[]; /** Whether the screen is in desktop layout. */ hasDesktopLayout: boolean; }) => AnnotationToolbarItem[]; /** * This callback is called whenever an annotation gets selected and can be used to * define and return an array of {@link ToolItem} that will be rendered in a tooltip * for the given annotation. * * If the callback returns an empty array then NutrientViewer won't show any tooltip for the selected annotation. * * @param annotation - The selected annotation. * @example * Register a AnnotationTooltipCallback handler to show a tooltip for text annotations only. * ```ts * NutrientViewer.load({ * annotationTooltipCallback: function(annotation) { * if (annotation instanceof NutrientViewer.Annotations.TextAnnotation) { * var toolItem = { * type: 'custom', * title: 'tooltip item for text annotations', * id: 'item-text-tooltip-annotation', * className: 'TooltipItem-Text', * onPress: function () { * console.log(annotation) * } * } * return [toolItem] * } else { * return [] * } * } * // ... * }); * ``` * */ export declare type AnnotationTooltipCallback = (annotation: AnnotationsUnion) => Array; declare type Args = T extends ((...args: infer A) => any) ? A : never; export declare class Attachment extends Attachment_base { data: Blob; } declare const Attachment_base: Record_2.Factory; /** * @class * Attachments are data that can be attached to annotations. An example for such an attachment is an * image attachment in an image annotation. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `attachment.set("data", new Blob(...))`. * @example * fetch("https://example.com/my-image.jpg") * .then(r => r.blob()) * .then(blob => instance.createAttachment(blob)) * .then(attachmentId => console.log(attachmentId)); * * @public * @summary An attachment, that can hold the data as a Blob. * @param args - An ArrayBuffer, which be used as the data of the attachment. * @default { data: null } */ declare type AttachmentProps = { /** * The attachment's data as a Blob. * * @default null */ data: Blob | null; }; /** * The attachments sidebar options allow to specify options available for the Attachments sidebar. * * @public * @summary Keyed list of options that apply to the attachments sidebar. * @example * Disabling preview of attachments. * ```ts * NutrientViewer.load({ * initialViewState: new NutrientViewer.ViewState({ * sidebarOptions: { * [NutrientViewer.SidebarMode.ATTACHMENTS]: { * disablePreview: true * } * } * }) * }); * ``` * * @see {@link ViewState#sidebarOptions} */ export declare type AttachmentsSidebarOptions = { /** * If true, the preview of the attachment will be disabled and attachments can only be downloaded. */ disablePreview: boolean; }; /** * When working with annotations and form field values, there are multiple options when the data can * get saved. The AutoSaveMode controls this behavior. * * @enum */ declare const AutoSaveMode: { /** Saves immediately whenever an attribute of the annotation changed, or whenever a form field value got updated. */ readonly IMMEDIATE: "IMMEDIATE"; /** Saves annotations automatically, when the user finishes editing an annotation. For form fields, this behaves like {@link AutoSaveMode.IMMEDIATE}. */ readonly INTELLIGENT: "INTELLIGENT"; /** * Never saves annotations or form field values automatically. Annotations and form field values can still be saved via {@link Instance#save} * * In this mode, document signatures validation information will not be automatically updated * if the document is modified, until changes are saved. */ readonly DISABLED: "DISABLED"; }; declare type BackendRequiredKeys = 'id' | 'v' | 'pageIndex' | 'type' | 'bbox'; declare interface BaseAnnotationJSON extends ICollaboratorPermissionsOptions { v: number; type?: 'pspdfkit/ink' | 'pspdfkit/shape/line' | 'pspdfkit/shape/rectangle' | 'pspdfkit/shape/ellipse' | 'pspdfkit/shape/polygon' | 'pspdfkit/shape/polyline' | 'pspdfkit/link' | 'pspdfkit/markup/highlight' | 'pspdfkit/markup/squiggly' | 'pspdfkit/markup/strikeout' | 'pspdfkit/markup/underline' | 'pspdfkit/markup/redaction' | 'pspdfkit/stamp' | 'pspdfkit/text' | 'pspdfkit/note' | 'pspdfkit/image' | 'pspdfkit/media' | 'pspdfkit/widget' | 'pspdfkit/comment-marker' | 'pspdfkit/unknown'; name?: string | null; id: string; subject?: string | null; pdfObjectId?: number | null; pageIndex: number; bbox: IRectJSON; opacity?: number; flags?: ('noPrint' | 'noZoom' | 'noRotate' | 'noView' | 'hidden' | 'locked' | 'lockedContents' | 'readOnly')[] | null; action?: Serializers.ActionJSON | null; note?: string | null; createdAt?: string | Date; updatedAt?: string | Date; creatorName?: string | null; customData?: Record | null; isCommentThreadRoot?: boolean; isAnonymous?: boolean; APStreamCache?: { cache: string; } | { attach: string; }; blendMode?: IBlendMode | null; } /** @inline */ declare interface BaseDocumentEditorFooterItem extends Omit { /** * ***required*** * * The type of a document editor footer item. * * It can either be `custom` for user defined items or one from the {@link NutrientViewer.defaultDocumentEditorFooterItems}. * * Note: It is ***not*** possible to override this option for built-in footer items. * * @example * // In your JavaScript * const documentEditorFooterItems = NutrientViewer.defaultDocumentEditorFooterItems * documentEditorFooterItems.push({ * type: 'custom', * // other properties... * }) * NutrientViewer.load({ * ...otherOptions, * documentEditorFooterItems * }); */ type: string; /** * Unique identifier for the item. * * This is useful to identify items whose `type` is `custom`. * * Note: It is ***not*** possible to override this option for built-in document editor footer items. * * @example * // In your JavaScript * const documentEditorFooterItems = NutrientViewer.defaultDocumentEditorFooterItems * documentEditorFooterItems.push({ * type: 'custom', * id: 'my-button', * // other properties... * }) * NutrientViewer.load({ * ...otherOptions, * documentEditorFooterItems * }); */ id?: string; /** * Useful to set a custom CSS class name on the item. * * For {@link NutrientViewer.defaultDocumentEditorFooterItems | default document editor footer items} the `className` is appended to the default * item ones. */ className?: string; } /** @inline */ declare interface BaseDocumentEditorToolbarItem extends Omit { /** * ***required*** * * The type of a document editor toolbar item. * * It can either be `custom` for user defined items or one from the {@link NutrientViewer.defaultDocumentEditorToolbarItems}. * * Note: It is ***not*** possible to override this option for built-in toolbar items. * * @example * // In your JavaScript * const documentEditorToolbarItems = NutrientViewer.defaultDocumentEditorToolbarItems * documentEditorToolbarItems.push({ * type: 'custom', * // other properties... * }) * NutrientViewer.load({ * ...otherOptions, * documentEditorToolbarItems * }); */ type: string; /** * Unique identifier for the item. * * This is useful to identify items whose `type` is `custom`. * * Note: It is ***not*** possible to override this option for built-in document editor toolbar items. * * @example * // In your JavaScript * const documentEditorToolbarItems = NutrientViewer.defaultDocumentEditorToolbarItems * documentEditorToolbarItems.push({ * type: 'custom', * id: 'my-button', * // other properties... * }) * NutrientViewer.load({ * ...otherOptions, * documentEditorToolbarItems * }); */ id?: string; /** * Useful to set a custom CSS class name on the item. * * For {@link NutrientViewer.defaultDocumentEditorToolbarItems | default document editor toolbar items} the `className` is appended to the default * item ones. */ className?: string; /** * Icon for the item. * * The icon should either be an URL, a base64 encoded image or the HTML for an inline SVG. * This property can override the {@link NutrientViewer.defaultDocumentEditorToolbarItems | default items}' ones. */ icon?: string; /** * Whether a custom item is selected or not. * * The selected status of {@link NutrientViewer.defaultDocumentEditorToolbarItems | default items} cannot be altered. * * Note: It is ***not*** possible to override this option for built-in document editor toolbar items. */ selected?: boolean; /** * Whether the item is disabled or not. * * The property can be used to force a {@link NutrientViewer.defaultDocumentEditorToolbarItems | default item} to be * disabled by setting it to `true`. */ disabled?: boolean; } declare interface BaseFormFieldJSON { v: 1; pdfObjectId?: number | null; annotationIds: Array; name: string; label: string; flags?: FormFieldFlags; id: string; additionalActions?: SerializedAdditionalActionsType | null; group?: IGroup; permissions?: IPermissions; } declare class BaseMixin {} /** * Base params passed to all slot render callbacks. * Contains the slot instance identifier. Will be enriched per-slot in future releases * with contextual information (e.g., selected annotation data, active mode). * * **Note:** * Adding new properties to params in future releases is a non-breaking change - * existing callbacks that only destructure `{ id }` will continue to work. */ declare type BaseSlotParams = { /** Unique identifier for the slot instance. */ id: string; }; /** * Sub-slot customization options for partial replacement of a component's regions. * * Instead of fully replacing a component, you can customize individual regions * (header, body, footer) while keeping the rest of the default UI intact. * Any region you don't specify keeps its default rendering. * * **Note:** * Not all components have visible defaults for every region. For example, a toolbar * may not have a default header — but you can still inject content above it by * providing a `header` callback. The region will be rendered even if the default is empty. * * @example * * Add a custom header above the search panel while keeping the default search UI: * * ```ts * NutrientViewer.load({ * ui: { * search: { * header: (instance, id) => ({ * render: () => { * const banner = document.createElement("div"); * banner.textContent = "Search powered by custom index"; * return banner; * }, * }), * }, * }, * }); * ``` * * @see {@link UI.SlotConfiguration} */ declare type BaseSlotUIOptions = { /** Insert or replace the header region (top area) of the component. */ header?: UI.SlotConfigurationCallback; /** Insert or replace the body region (main content area) of the component. */ body?: UI.SlotConfigurationCallback; /** Insert or replace the footer region (bottom area) of the component. */ footer?: UI.SlotConfigurationCallback; }; declare type BaseTextMarkupAnnotationJSON = Omit & { rects: [number, number, number, number][]; }; declare abstract class BaseTextMarkupSerializer extends AnnotationSerializer { annotation: RedactionAnnotation | TextMarkupAnnotation; constructor(annotation: RedactionAnnotation | TextMarkupAnnotation); toJSON(): BaseTextMarkupAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): { rects: List; group?: string | null | undefined; canSetGroup?: boolean; isEditable?: boolean; isDeletable?: boolean; blendMode?: IBlendMode | undefined; id: string | null; name: string | null; subject: string | null; pdfObjectId: number | null; pageIndex: number; opacity: number; boundingBox: Rect; noPrint: boolean; noZoom: boolean; noRotate: boolean; noView: boolean; hidden: boolean; locked: boolean; lockedContents: boolean; readOnly: boolean; action: Action | null | undefined; note: string | null; createdAt: Date; updatedAt: Date; creatorName: string | null; customData: Record | null; isCommentThreadRoot: boolean; isAnonymous: boolean; }; } declare let baseUrl: string | undefined; /** * Represents one of the available blend modes for highlight and ink annotations. * * @enum */ declare const BlendMode: { /** Default blend mode. The source color replaces the destination color. */ readonly normal: "normal"; /** Multiplies the source and destination colors, resulting in a darker color. */ readonly multiply: "multiply"; /** Inverts, multiplies, and inverts again, resulting in a lighter color. */ readonly screen: "screen"; /** Combines multiply and screen modes depending on the destination color. */ readonly overlay: "overlay"; /** Selects the darker of the source and destination colors. */ readonly darken: "darken"; /** Selects the lighter of the source and destination colors. */ readonly lighten: "lighten"; /** Brightens the destination color to reflect the source color. */ readonly colorDodge: "colorDodge"; /** Darkens the destination color to reflect the source color. */ readonly colorBurn: "colorBurn"; /** Multiplies or screens colors depending on the source color value. */ readonly hardLight: "hardLight"; /** Darkens or lightens colors depending on the source color value. */ readonly softLight: "softLight"; /** Subtracts the darker of the two colors from the lighter color. */ readonly difference: "difference"; /** Similar to difference but with lower contrast. */ readonly exclusion: "exclusion"; }; /** * @class * This record is used to persist the information for a bookmark. * * A bookmark is an object that registers a PDF action, usually triggered to go to a page. * @example * Creating a bookmark for the 3rd page of a document. * ```ts * const bookmark = new NutrientViewer.Bookmark({ * name: 'test bookmark', * action: new NutrientViewer.Actions.GoToAction({ pageIndex: 3 }) * }); * instance.create(bookmark); * ``` * * @public * @summary Bookmark element. * @hideconstructor * @see {@link Instance#create} | {@link Instance#delete} * @see {@link Instance#ensureChangesSaved} | {@link Instance#getBookmarks} * @see {@link Instance#hasUnsavedChanges} | {@link Instance#save} * @see {@link Instance#update} | {@link NutrientViewer.EventName.BOOKMARKS_CHANGE} * @see {@link NutrientViewer.EventName.BOOKMARKS_WILL_SAVE} | {@link NutrientViewer.EventName.BOOKMARKS_DID_SAVE} * @see {@link NutrientViewer.EventName.BOOKMARKS_LOAD} | {@link NutrientViewer.EventName.BOOKMARKS_CREATE} * @see {@link NutrientViewer.EventName.BOOKMARKS_UPDATE} | {@link NutrientViewer.EventName.BOOKMARKS_DELETE} */ export declare class Bookmark extends Bookmark_base { id: ID_2; action: Action; /** Bookmark serializer. Converts a bookmark to InstantJSON compliant objects. */ static toSerializableObject: typeof toJSON; /** Bookmark deserializer. Converts a bookmark object to a {@link NutrientViewer.Bookmark}. */ static fromSerializableObject: (bookmark: Serializers.BookmarkJSON) => Bookmark; } declare const Bookmark_base: Immutable.Record.Factory; /** @inline */ declare type BookmarkProps = { /** * A unique identifier to describe the bookmark. When a bookmark is created in the UI, the * viewer has to generate a unique ID. * * When changes are saved to the underlying bookmark provider, we call * {@link Instance#ensureChangesSaved} to make sure the annotation has been persisted * from the provider. */ id: ID_2 | null; /** * When the bookmark is extracted directly from a PDF file, the `pdfBookmarkId` refers to the * identifier that was used in the PDF document. * * This ID is optional since newly created bookmarks using the SYNCProvider annotation provider * won't have a `pdfBookmarkId` assigned. * * @default null */ pdfBookmarkId: ID_2 | null; /** * *optional* * * An optional name to associate to the bookmark. * * @default null */ name: string | null; /** * The action that will be triggered when the bookmark is either clicked or tapped. * * Please refer to {@link NutrientViewer.Actions} for an in-depth look at PDF actions. */ action: Action | null; }; declare function BookmarksMixin>(Base: T): { new (...args: any[]): { /** * Returns a {@link NutrientViewer.Immutable.List} of {@link Bookmark} for the current document. * * The list contains an immutable snapshot of the currently available bookmarks in the UI for * the page. * * When you want to keep a reference to the latest bookmarks, you can listen for * {@link NutrientViewer.EventName.BOOKMARKS_CHANGE}, * {@link NutrientViewer.EventName.BOOKMARKS_WILL_SAVE}, or * {@link NutrientViewer.EventName.BOOKMARKS_DID_SAVE} to update your reference. * * @example * instance.getBookmarks().then(function (bookmarks) { * bookmarks.forEach(bookmark => { * console.log(bookmark.name); * }); * * // Get the number of currently loaded bookmarks * const totalBookmarks = bookmarks.size; * }) * * @returns Resolves to bookmarks for the given page. */ getBookmarks(): Promise>; }; } & T; /** * Represents one of the available border styles for the widget annotations. * * @enum */ declare const BorderStyle: { /** A continuous solid line border. */ readonly solid: "solid"; /** A dashed line border with evenly spaced gaps. */ readonly dashed: "dashed"; /** A 3D border with a raised, beveled appearance. */ readonly beveled: "beveled"; /** A 3D border with a recessed, inset appearance. */ readonly inset: "inset"; /** A single line at the bottom of the widget, typically used for text fields. */ readonly underline: "underline"; }; /** * Performs processing via Nutrient Backend {@link https://www.nutrient.io/api/reference/public/#tag/Build-API|Build API}. * * * Document Engine (requires Document Engine >= 1.6.0) * * {@link https://www.nutrient.io/api/|DWS} * * In you are running in standalone mode, the resulting `ArrayBuffer` can be converted to PDF with {@link NutrientViewer.convertToPDF | NutrientViewer.convertToPDF()} (if it's not already PDF) * and then loaded with {@link NutrientViewer.load | NutrientViewer.load()}. * * @example * NutrientViewer.build( * // Authorize request. * { jwt: authPayload.jwt }, * // Instructions for the processing request. * { * parts: [ * // Use first input as the first part of the final document. * { file: "document" }, * // Use a sample DOCX document served from URL as the second part of the final document. * { * file: { * url: "https://www.nutrient.io/api/downloads/samples/docx/document.docx", * }, * }, * ], * }, * // Inputs required by the request. These will be uploaded with the request. The remote file served from URL does not need to be uploaded. * [{ name: "document", content: document }] *); * * @param authPayload - Information needed to authenticate processing request with Nutrient backend. * @param instructions - Build API instructions that describe the processing operation. * @param inputs - An array of all inputs required for the processing operation. * @returns Promise that resolves to an `ArrayBuffer` with the processing result. * In case of an error, rejects with a {@link NutrientViewer.Error} with detailed error message. * @since Document Engine 1.6.0 */ declare function build(authPayload: ProcessingAuthPayload, instructions: BuildInstructions, inputs?: BuildInput[]): Promise; /** * Represents a processing input referenced by {@link BuildInstructions} that needs to be uploaded with the processing request. * * @property name - Name of the input, used to reference the input in {@link BuildInstructions} * @property content - Content of the input that will be uploaded to the backend for processing. */ export declare type BuildInput = { name: string; content: ArrayBuffer | Blob; }; /** * The description of the processing operation performed via Build API. * * For a full reference of the Build API instructions, see the * {@link https://www.nutrient.io/api/reference/public/#tag/Build-API/Instructions-Schema | Instructions Schema}. */ export declare type BuildInstructions = { [key: string]: any; }; export declare interface BuiltInAnnotationToolbarItem { type: 'stroke-color' | 'fill-color' | 'background-color' | 'opacity' | 'line-width' | 'blend-mode' | 'spacer' | 'delete' | 'annotation-note' | 'border-color' | 'border-width' | 'border-style' | 'color' | 'linecaps-dasharray' | 'line-style' | 'font' | 'overlay-text' | 'outline-color' | 'apply-redactions' | 'measurementType' | 'measurementScale' | 'back' | 'crop-current' | 'crop-all' | 'close' | 'clockwise-rotation' | 'counterclockwise-rotation'; } /** @inline */ declare type BuiltInColorProperty = 'color' | 'stroke-color' | 'fill-color' | 'background-color' | 'font-color' | 'outline-color' | 'border-color'; declare type BuiltInDocumentEditorFooterItem = BuiltInDocumentEditorFooterItemType; /** @inline */ declare type BuiltInDocumentEditorFooterItemType = 'cancel' | 'spacer' | 'save-as' | 'save' | 'selected-pages' | 'loading-indicator'; /** @inline */ declare type BuiltInDocumentEditorToolbarItemType = 'add' | 'remove' | 'duplicate' | 'rotate-left' | 'rotate-right' | 'move' | 'move-left' | 'move-right' | 'import-document' | 'extract-pages' | 'spacer' | 'undo' | 'redo' | 'select-all' | 'select-none' | 'zoom-out' | 'zoom-in'; declare const builtInItems: readonly ["highlight", "strikeout", "underline", "squiggle", "redact-text-highlighter", "comment", "ai-assistant"]; /** * See {@link https://www.nutrient.io/baseline-ui/?path=/docs/theming--docs#theme-object-structure | BUI Theme documentation} for more information. * * @interface * */ export declare type BUITheme = typeof themeContract; /** * @class * A button that can be pressed. * * To retrieve a list of all form fields, use {@link Instance#getFormFields}. * @public * @summary A clickable button. */ export declare class ButtonFormField extends FormField { /** * The label for the button widget annotation. */ buttonLabel: string | null; } /** * Properties of the arrow line attached to a callout (text) annotation. * * @summary Callout arrow line properties. */ declare class Callout extends InheritableImmutableRecord { /** Starting point of the arrow line. */ start: Point | null; /** Knee point of the arrow line. */ knee: Point | null; /** Ending point of the arrow line. */ end: Point | null; /** The line cap style. */ cap: ILineCap | null; /** The inner rectangle inset. */ innerRectInset: Inset | null; static defaultValues: ICallout; } /** * The different possible validation states of the certificate chain. * * @enum */ export declare const CertificateChainValidationStatus: { /** * The certificate chain validates correctly. */ readonly ok: "ok"; /** * The certificate chain contains a self-signed certificate. */ readonly ok_but_self_signed: "ok_but_self_signed"; /** * Revocation check network error. Either due to invalid server URL or network timeout. * The certificate is valid with a warning. */ readonly ok_but_could_not_check_revocation: "ok_but_could_not_check_revocation"; /** * The certificate chain contains a certificate that has been classified as "untrusted". * * The certificate date is correct, but the identity is unknown because it has not been * included in the list of trusted certificates and none of its parents are trusted * certificates. */ readonly untrusted: "untrusted"; /** * The certificate used to sign the document has expired now. * Note that the certificate may be valid at the time the document was signed, * which is not checked. */ readonly expired: "expired"; /** * The certificate used to sign the document is not valid yet. */ readonly not_yet_valid: "not_yet_valid"; /** * The certificate is not valid. */ readonly invalid: "invalid"; /** * The certificate has been revoked. */ readonly revoked: "revoked"; /** * Could not fetch the contents of the signature. */ readonly failed_to_retrieve_signature_contents: "failed_to_retrieve_signature_contents"; /** * An unknown problem happened when the certificate trust chain was validated. * * Between the possible reasons for this could be that the signature is malformed, * the certificate chain is too long and other unknown conditions. */ readonly general_validation_problem: "general_validation_problem"; }; /** @inline */ declare type CertificateChainValidationStatusType = ValueOf; /** * An union of supported types of changes. */ export declare type Change = AnnotationsUnion | Bookmark | FormField | FormFieldValue | Comment_2; declare function ChangesMixin>(Base: T): { new (...args: any[]): { /** * With {@link NutrientViewer.AutoSaveMode} it's possible to define when local changes get saved, but * it's also possible to define the point to save changes yourself. * * By choosing {@link NutrientViewer.AutoSaveMode.DISABLED}, nothing gets saved automatically, but * by calling `save`, it's possible to manually trigger save. This can be useful when you want * to have full control when new changes get saved to your backend. * * @example * NutrientViewer.load(configuration).then(async (instance) => { * const annotation = new NutrientViewer.Annotations.InkAnnotation({ * pageIndex: 0, * lines: NutrientViewer.Immutable.List([ * NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.DrawingPoint({ x: 0, y: 0 }), * new NutrientViewer.Geometry.DrawingPoint({ x: 100, y: 100}), * ]) * ]) * }); * * await instance.create(annotation); * * await instance.save(); // Now the annotation gets saved. * }) * * @returns Promise that resolves once all changes are saved on remote server (in case of server-based backend) or in local backend (in case of standalone). If changes could not be saved, rejects with {@link NutrientViewer.SaveError}. */ save(): Promise; /** * Returns `true` if any local changes are not yet saved. This can be used in combination with * {@link Configuration.autoSaveMode} to implement fine grained save controls. * * Whenever changes are saved (for example, when calling {@link NutrientViewer.Instance#save}), * the method will return `false` again. * * @example * NutrientViewer.load(configuration).then(function(instance) { * instance.hasUnsavedChanges(); // => false * }); * * @returns Whether unsaved changes are present or not. */ hasUnsavedChanges(): boolean; /** * Creates new changes and assigns them IDs. * If you need to ensure that changes are persisted by the backend, please refer to: * {@link NutrientViewer.Instance#ensureChangesSaved}. * * This method returns a promise that will resolve to an array of records with the local IDs set. * * New changes will be made visible in the UI instantly. * * @example * NutrientViewer.load(configuration).then(function(instance) { * const annotation = new NutrientViewer.Annotations.InkAnnotation({ * pageIndex: 0, * lines: NutrientViewer.Immutable.List([ * NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.DrawingPoint({ x: 0, y: 0 }), * new NutrientViewer.Geometry.DrawingPoint({ x: 100, y: 100}), * ]) * ]) * }); * instance.create(annotation).then(function(createdAnnotations) { * console.log(createdAnnotations); * }); * }) * * @public * @param changes - A single change or a list/array of changes that should be created. * @returns A promise that resolves to an array of created changes or an error if some changes could not be created. */ create(changes: Change | Array | List): Promise>; /** * Updates object and changes its contents. * * If you need to ensure that changes are persisted by the backend, please refer to: * {@link Instance#ensureChangesSaved}. * * New changes will be made visible in the UI instantly. * * @example * const instance = await NutrientViewer.load(configuration); * // Get all annotations on the first page * const annotations = instance.getAnnotations(0); * // Grab the first one * const annotation = annotations.first(); * * const editedAnnotation = annotation.set("noPrint", true); * const updatedAnnotation = await instance.update(editedAnnotation); * * editedAnnotation === updatedAnnotation; // => true * * @public * @param changes - A single change or list/array of changes that should be updated. * @returns A promise that resolves to an array of changes or an error if some changes could not be updated. */ update(changes: Change | Array | List): Promise>; /** * Deletes a change. This can be called with a change ID. * * If you need to ensure that changes are persisted by the backend, please refer to: * {@link Instance#ensureChangesSaved}. * * Deleted changes will be made visible in the UI instantly. * * If the deleted change is a `NutrientViewer.Annotations.WidgetAnnotation` * (which can only be deleted if the Form Creator component is present in * the license, and the backend is using a Form Creator capable provider), * and the associated `NutrientViewer.FormField` only includes that annotation in * its `annotationIds` list, the form field will also be deleted. * * If there are more widget annotations remaining in the `annotationIds` list, * as could be the case for radio buttons, for example, the form field's * `annotationIds` property will be updated by removing the deleted * annotation's `id` from it. * * @example * NutrientViewer.load(configuration).then(function(instance) { * instance.delete(1).then(function() { * console.log("Object with ID 1 deleted."); * }); * }); * * @public * @param changeIds - A single id or a list/array of ids of changes that should be deleted. * @returns A promise that resolves to an array of deleted changes or an error if some changes could not be deleted. */ delete(changeIds: InstantID_2 | Change | Array | List): Promise>; /** * Ensures that changes have been saved to the backend and returns the current persisted state of * these changes. * * This method returns a promise that will resolve to an array of {@link Change}. * * @example * NutrientViewer.load(configuration).then(function(instance) { * instance.create(newAnnotation) * .then(instance.ensureChangesSaved) * .then(function() { * console.log('Annotation persisted by annotation provider'); * }); * }); * * @public * @param changes - A single change or a list/array of changes to ensure saved. * @returns A promise that resolves to an array of changes or an error if some changes could not be saved. */ ensureChangesSaved(changes: Change | Array | List): Promise>; }; } & T; /** * @class * A check box that can either be checked or unchecked. One check box form field can also be * associated to multiple single check box widgets. In this case, `option` contains the value of the * associated {@link NutrientViewer.FormOption} * * To retrieve a list of all form fields, use {@link NutrientViewer.Instance#getFormFields}. * @public * @summary A check box or a group of many check boxes. */ export declare class CheckBoxFormField extends FormField { /** * An immutable list of all selected form option values. If no options are defined, a checked * check box will have `values: List(["Yes"]);`. * * If the list is empty, no check box is checked. * * In order to modify it, {@link NutrientViewer.Instance.setFormFieldValues | instance.setFormFieldValues()} should be used. */ readonly values: List; /** * Similar to the `value` property. The default values are only used when a form needs to be reset. */ defaultValues: List; /** * A list of {@link NutrientViewer.FormOption}s. This is necessary for multiple check boxes in a group. * * See {@link NutrientViewer.FormOption} for more information. */ options: List; /** * Radio buttons and checkboxes can have multiple widgets with the same form value associated, but can be * selected independently. `optionIndexes` contains the value indexes that should be actually set. * * If set, the `value` field doesn't get used, and the widget found at the corresponding indexes in the form field's * `annotationIds` property are checked. * * If set on fields other than radio buttons or checkboxes, setting the form value will fail. */ optionIndexes?: List; } /** * @class * * Base form field type for all form fields that allow multiple choices: * * - {@link FormFields.ComboBoxFormField} * - {@link FormFields.ListBoxFormField} * @public * @summary Base form field for all fields allowing multiple choices. */ export declare class ChoiceFormField extends FormField { /** * A list of {@link FormOption}s. This is necessary for multiple check boxes in a group. * * See {@link FormOption} for more information. */ options: List; /** * An immutable list of all selected form option values. If no options are defined, a checked * check box will have `values: List(["Yes"]);`. * * If the list is empty, no check box is checked. * * In order to modify it, {@link Instance#setFormFieldValues | instance.setFormFieldValues()} should be used. */ readonly values: List; /** * Similar to the `value` property. The default values are only used when a form needs to be reset. */ readonly defaultValues: List; /** * If true, more than one of the field’s option items may be selected simultaneously. Otherwise, * no more than one item at a time may be selected. * * @default false */ multiSelect: boolean; /** * If true, the new value is committed as soon as a selection is made, without requiring the user * to exit the field. Otherwise, the new value is not committed until the user exits the field. * * Please note that {@link Instance#getFormFieldValues} will not return * the latest value for this field until the user leaves this field by default. If you * want this value to update on every change then set this to true. * * @default false */ commitOnChange: boolean; } /** @inline */ declare type Class = new (...args: any[]) => T; declare function CollaborationPermissionsMixin>(Base: T): { new (...args: any[]): { /** * This method is used to update the group that will be used by default in all the * newly created form-fields, comments and annotations. If you don't have permission to * change the group, you will get error when you try to add an annotation, comment or form-field. * * This method is no-op if Collaboration Permissions is not enabled. * * @public * @param group - The new group that you want to use for all the newly created form-fields, comments and annotations. */ setGroup(group: string): void; /** * This method can be used to change the default group back to original after it was changed to * something else using `instance.setGroup`. * * This method is no-op if Collaboration Permissions is not enabled. * * @public */ resetGroup(): void; }; } & T; /** * Creates a Collection. * * The type of Collection created is based on the input. * * * If an `Collection`, that same `Collection`. * * If an Array-like, an `Collection.Indexed`. * * If an Object with an Iterator defined, an `Collection.Indexed`. * * If an Object, an `Collection.Keyed`. * * This methods forces the conversion of Objects and Strings to Collections. * If you want to ensure that a Collection of one item is returned, use * `Seq.of`. * * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, * which is usually not what you want. You should turn your Iterator Object into * an iterable object by defining a Symbol.iterator (or @@iterator) method which * returns `this`. * * Note: `Collection` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ declare function Collection>(collection: I): I; declare function Collection(collection: Iterable): Collection.Indexed; declare function Collection(obj: {[key: string]: V;}): Collection.Keyed; /** * The `Collection` is a set of (key, value) entries which can be iterated, and * is the base class for all collections in `immutable`, allowing them to * make use of all the Collection methods (such as `map` and `filter`). * * Note: A collection is always iterated in the same order, however that order * may not always be well defined, as is the case for the `Map` and `Set`. * * Collection is the abstract base class for concrete data structures. It * cannot be constructed directly. * * Implementations should extend one of the subclasses, `Collection.Keyed`, * `Collection.Indexed`, or `Collection.Set`. */ declare module Collection { /** * @deprecated use `const { isKeyed } = require('immutable')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** * @deprecated use `const { isIndexed } = require('immutable')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** * @deprecated use `const { isAssociative } = require('immutable')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** * @deprecated use `const { isOrdered } = require('immutable')` */ function isOrdered(maybeOrdered: any): boolean; /** * Keyed Collections have discrete keys tied to each value. * * When iterating `Collection.Keyed`, each iteration will yield a `[K, V]` * tuple, in other words, `Collection#entries` is the default iterator for * Keyed Collections. */ module Keyed {} /** * Creates a Collection.Keyed * * Similar to `Collection()`, however it expects collection-likes of [K, V] * tuples if not constructed from a Collection.Keyed or JS Object. * * Note: `Collection.Keyed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; function Keyed(obj: {[key: string]: V;}): Collection.Keyed; interface Keyed extends Collection { /** * Deeply converts this Keyed collection to equivalent native JavaScript Object. * * Converts keys to Strings. */ toJS(): Object; /** * Shallowly converts this Keyed collection to equivalent native JavaScript Object. * * Converts keys to Strings. */ toJSON(): {[key: string]: V;}; /** * Shallowly converts this collection to an Array. */ toArray(): Array<[K, V]>; /** * Returns Seq.Keyed. * @override */ toSeq(): Seq.Keyed; // Sequence functions /** * Returns a new Collection.Keyed of the same type where the keys and values * have been flipped. * * * ```js * const { Map } = require('immutable') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` */ flip(): Collection.Keyed; /** * Returns a new Collection with other collections concatenated to this one. */ concat(...collections: Array>): Collection.Keyed; concat(...collections: Array<{[key: string]: C;}>): Collection.Keyed; /** * Returns a new Collection.Keyed with values passed through a * `mapper` function. * * ```js * const { Collection } = require('immutable') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` * * Note: `map()` always returns a new instance, even if it produced the * same value at every step. */ map( mapper: (value: V, key: K, iter: this) => M, context?: any) : Collection.Keyed; /** * Returns a new Collection.Keyed of the same type with keys passed through * a `mapper` function. * * * ```js * const { Map } = require('immutable') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` * * Note: `mapKeys()` always returns a new instance, even if it produced * the same key at every step. */ mapKeys( mapper: (key: K, value: V, iter: this) => M, context?: any) : Collection.Keyed; /** * Returns a new Collection.Keyed of the same type with entries * ([key, value] tuples) passed through a `mapper` function. * * * ```js * const { Map } = require('immutable') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } * ``` * * Note: `mapEntries()` always returns a new instance, even if it produced * the same entry at every step. */ mapEntries( mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any) : Collection.Keyed; /** * Flat-maps the Collection, returning a Collection of the same type. * * Similar to `collection.map(...).flatten(true)`. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, context?: any) : Collection.Keyed; /** * Returns a new Collection with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: V, key: K, iter: this) => value is F, context?: any) : Collection.Keyed; filter( predicate: (value: V, key: K, iter: this) => any, context?: any) : this; [Symbol.iterator](): IterableIterator<[K, V]>; } /** * Indexed Collections have incrementing numeric keys. They exhibit * slightly different behavior than `Collection.Keyed` for some methods in order * to better mirror the behavior of JavaScript's `Array`, and add methods * which do not make sense on non-indexed Collections such as `indexOf`. * * Unlike JavaScript arrays, `Collection.Indexed`s are always dense. "Unset" * indices and `undefined` indices are indistinguishable, and all indices from * 0 to `size` are visited when iterated. * * All Collection.Indexed methods return re-indexed Collections. In other words, * indices always start at 0 and increment until size. If you wish to * preserve indices, using them as keys, convert to a Collection.Keyed by * calling `toKeyedSeq`. */ module Indexed {} /** * Creates a new Collection.Indexed. * * Note: `Collection.Indexed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ function Indexed(collection: Iterable): Collection.Indexed; interface Indexed extends Collection { /** * Deeply converts this Indexed collection to equivalent native JavaScript Array. */ toJS(): Array; /** * Shallowly converts this Indexed collection to equivalent native JavaScript Array. */ toJSON(): Array; /** * Shallowly converts this collection to an Array. */ toArray(): Array; // Reading values /** * Returns the value associated with the provided index, or notSetValue if * the index is beyond the bounds of the Collection. * * `index` may be a negative number, which indexes back from the end of the * Collection. `s.get(-1)` gets the last item in the Collection. */ get(index: number, notSetValue: NSV): T | NSV; get(index: number): T | undefined; // Conversion to Seq /** * Returns Seq.Indexed. * @override */ toSeq(): Seq.Indexed; /** * If this is a collection of [key, value] entry tuples, it will return a * Seq.Keyed of those entries. */ fromEntrySeq(): Seq.Keyed; // Combination /** * Returns a Collection of the same type with `separator` between each item * in this Collection. */ interpose(separator: T): this; /** * Returns a Collection of the same type with the provided `collections` * interleaved into this collection. * * The resulting Collection includes the first item from each, then the * second from each, etc. * * * ```js * const { List } = require('immutable') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` * * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( * List([ 'A', 'B' ]), * List([ 'X', 'Y', 'Z' ]) * ) * // List [ 1, "A", "X", 2, "B", "Y"" ] * ``` * * Since `interleave()` re-indexes values, it produces a complete copy, * which has `O(N)` complexity. * * Note: `interleave` *cannot* be used in `withMutations`. */ interleave(...collections: Array>): this; /** * Splice returns a new indexed Collection by replacing a region of this * Collection with new values. If values are not provided, it only skips the * region to be removed. * * `index` may be a negative number, which indexes back from the end of the * Collection. `s.splice(-2)` splices after the second to last item. * * * ```js * const { List } = require('immutable') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` * * Since `splice()` re-indexes values, it produces a complete copy, which * has `O(N)` complexity. * * Note: `splice` *cannot* be used in `withMutations`. */ splice( index: number, removeNum: number, ...values: Array) : this; /** * Returns a Collection of the same type "zipped" with the provided * collections. * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ zip(other: Collection): Collection.Indexed<[T, U]>; zip(other: Collection, other2: Collection): Collection.Indexed<[T, U, V]>; zip(...collections: Array>): Collection.Indexed; /** * Returns a Collection "zipped" with the provided collections. * * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * * ```js * const a = List([ 1, 2 ]); * const b = List([ 3, 4, 5 ]); * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ zipAll(other: Collection): Collection.Indexed<[T, U]>; zipAll(other: Collection, other2: Collection): Collection.Indexed<[T, U, V]>; zipAll(...collections: Array>): Collection.Indexed; /** * Returns a Collection of the same type "zipped" with the provided * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); * const c = a.zipWith((a, b) => a + b, b); * // List [ 5, 7, 9 ] * ``` */ zipWith( zipper: (value: T, otherValue: U) => Z, otherCollection: Collection) : Collection.Indexed; zipWith( zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection) : Collection.Indexed; zipWith( zipper: (...any: Array) => Z, ...collections: Array>) : Collection.Indexed; // Search for value /** * Returns the first index at which a given value can be found in the * Collection, or -1 if it is not present. */ indexOf(searchValue: T): number; /** * Returns the last index at which a given value can be found in the * Collection, or -1 if it is not present. */ lastIndexOf(searchValue: T): number; /** * Returns the first index in the Collection where a value satisfies the * provided predicate function. Otherwise -1 is returned. */ findIndex( predicate: (value: T, index: number, iter: this) => boolean, context?: any) : number; /** * Returns the last index in the Collection where a value satisfies the * provided predicate function. Otherwise -1 is returned. */ findLastIndex( predicate: (value: T, index: number, iter: this) => boolean, context?: any) : number; // Sequence algorithms /** * Returns a new Collection with other collections concatenated to this one. */ concat(...valuesOrCollections: Array | C>): Collection.Indexed; /** * Returns a new Collection.Indexed with values passed through a * `mapper` function. * * ```js * const { Collection } = require('immutable') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` * * Note: `map()` always returns a new instance, even if it produced the * same value at every step. */ map( mapper: (value: T, key: number, iter: this) => M, context?: any) : Collection.Indexed; /** * Flat-maps the Collection, returning a Collection of the same type. * * Similar to `collection.map(...).flatten(true)`. */ flatMap( mapper: (value: T, key: number, iter: this) => Iterable, context?: any) : Collection.Indexed; /** * Returns a new Collection with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: T, index: number, iter: this) => value is F, context?: any) : Collection.Indexed; filter( predicate: (value: T, index: number, iter: this) => any, context?: any) : this; [Symbol.iterator](): IterableIterator; } /** * Set Collections only represent values. They have no associated keys or * indices. Duplicate values are possible in the lazy `Seq.Set`s, however * the concrete `Set` Collection does not allow duplicate values. * * Collection methods on Collection.Set such as `map` and `forEach` will provide * the value as both the first and second arguments to the provided function. * * ```js * const { Collection } = require('immutable') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => * assert.equal(v, k) * ) * ``` */ module Set {} /** * Similar to `Collection()`, but always returns a Collection.Set. * * Note: `Collection.Set` is a factory function and not a class, and does * not use the `new` keyword during construction. */ function Set(collection: Iterable): Collection.Set; interface Set extends Collection { /** * Deeply converts this Set collection to equivalent native JavaScript Array. */ toJS(): Array; /** * Shallowly converts this Set collection to equivalent native JavaScript Array. */ toJSON(): Array; /** * Shallowly converts this collection to an Array. */ toArray(): Array; /** * Returns Seq.Set. * @override */ toSeq(): Seq.Set; // Sequence algorithms /** * Returns a new Collection with other collections concatenated to this one. */ concat(...collections: Array>): Collection.Set; /** * Returns a new Collection.Set with values passed through a * `mapper` function. * * ``` * Collection.Set([ 1, 2 ]).map(x => 10 * x) * // Seq { 1, 2 } * ``` * * Note: `map()` always returns a new instance, even if it produced the * same value at every step. */ map( mapper: (value: T, key: T, iter: this) => M, context?: any) : Collection.Set; /** * Flat-maps the Collection, returning a Collection of the same type. * * Similar to `collection.map(...).flatten(true)`. */ flatMap( mapper: (value: T, key: T, iter: this) => Iterable, context?: any) : Collection.Set; /** * Returns a new Collection with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: T, key: T, iter: this) => value is F, context?: any) : Collection.Set; filter( predicate: (value: T, key: T, iter: this) => any, context?: any) : this; [Symbol.iterator](): IterableIterator; } } declare interface Collection extends ValueObject { // Value equality /** * True if this and the other Collection have value equality, as defined * by `Immutable.is()`. * * Note: This is equivalent to `Immutable.is(this, other)`, but provided to * allow for chained expressions. */ equals(other: any): boolean; /** * Computes and returns the hashed identity for this Collection. * * The `hashCode` of a Collection is used to determine potential equality, * and is used when adding this to a `Set` or as a key in a `Map`, enabling * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances * const set = Set([ a ]); * assert.equal(set.has(b), true); * ``` * * If two values have the same `hashCode`, they are [not guaranteed * to be equal][Hash Collision]. If two values have different `hashCode`s, * they must not be equal. * * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) */ hashCode(): number; // Reading values /** * Returns the value associated with the provided key, or notSetValue if * the Collection does not contain this key. * * Note: it is possible a key may be associated with an `undefined` value, * so if `notSetValue` is not provided and this method returns `undefined`, * that does not guarantee the key was not found. */ get(key: K, notSetValue: NSV): V | NSV; get(key: K): V | undefined; /** * True if a key exists within this `Collection`, using `Immutable.is` * to determine equality */ has(key: K): boolean; /** * True if a value exists within this `Collection`, using `Immutable.is` * to determine equality * @alias contains */ includes(value: V): boolean; contains(value: V): boolean; /** * In case the `Collection` is not empty returns the first element of the * `Collection`. * In case the `Collection` is empty returns the optional default * value if provided, if no default value is provided returns undefined. */ first(notSetValue?: NSV): V | NSV; /** * In case the `Collection` is not empty returns the last element of the * `Collection`. * In case the `Collection` is empty returns the optional default * value if provided, if no default value is provided returns undefined. */ last(notSetValue?: NSV): V | NSV; // Reading deep values /** * Returns the value found by following a path of keys or indices through * nested Collections. * * * ```js * const { Map, List } = require('immutable') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); * deepData.getIn(['x', 0, 'y']) // 123 * ``` * * Plain JavaScript Object or Arrays may be nested within an Immutable.js * Collection, and getIn() can access those values as well: * * * ```js * const { Map, List } = require('immutable') * const deepData = Map({ x: [ { y: 123 } ] }); * deepData.getIn(['x', 0, 'y']) // 123 * ``` */ getIn(searchKeyPath: Iterable, notSetValue?: any): any; /** * True if the result of following a path of keys or indices through nested * Collections results in a set value. */ hasIn(searchKeyPath: Iterable): boolean; // Persistent changes /** * This can be very useful as a way to "chain" a normal function into a * sequence of methods. RxJS calls this "let" and lodash calls it "thru". * * For example, to sum a Seq after mapping and filtering: * * * ```js * const { Seq } = require('immutable') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) * } * * Seq([ 1, 2, 3 ]) * .map(x => x + 1) * .filter(x => x % 2 === 0) * .update(sum) * // 6 * ``` */ update(updater: (value: this) => R): R; // Conversion to JavaScript types /** * Deeply converts this Collection to equivalent native JavaScript Array or Object. * * `Collection.Indexed`, and `Collection.Set` become `Array`, while * `Collection.Keyed` become `Object`, converting keys to Strings. */ toJS(): Array | {[key: string]: any;}; /** * Shallowly converts this Collection to equivalent native JavaScript Array or Object. * * `Collection.Indexed`, and `Collection.Set` become `Array`, while * `Collection.Keyed` become `Object`, converting keys to Strings. */ toJSON(): Array | {[key: string]: V;}; /** * Shallowly converts this collection to an Array. * * `Collection.Indexed`, and `Collection.Set` produce an Array of values. * `Collection.Keyed` produce an Array of [key, value] tuples. */ toArray(): Array | Array<[K, V]>; /** * Shallowly converts this Collection to an Object. * * Converts keys to Strings. */ toObject(): {[key: string]: V;}; // Conversion to Collections /** * Converts this Collection to a Map, Throws if keys are not hashable. * * Note: This is equivalent to `Map(this.toKeyedSeq())`, but provided * for convenience and to allow for chained expressions. */ toMap(): Map_2; /** * Converts this Collection to a Map, maintaining the order of iteration. * * Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`, but * provided for convenience and to allow for chained expressions. */ toOrderedMap(): OrderedMap; /** * Converts this Collection to a Set, discarding keys. Throws if values * are not hashable. * * Note: This is equivalent to `Set(this)`, but provided to allow for * chained expressions. */ toSet(): Set_2; /** * Converts this Collection to a Set, maintaining the order of iteration and * discarding keys. * * Note: This is equivalent to `OrderedSet(this.valueSeq())`, but provided * for convenience and to allow for chained expressions. */ toOrderedSet(): OrderedSet; /** * Converts this Collection to a List, discarding keys. * * This is similar to `List(collection)`, but provided to allow for chained * expressions. However, when called on `Map` or other keyed collections, * `collection.toList()` discards the keys and creates a list of only the * values, whereas `List(collection)` creates a list of entry tuples. * * * ```js * const { Map, List } = require('immutable') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] * ``` */ toList(): List; /** * Converts this Collection to a Stack, discarding keys. Throws if values * are not hashable. * * Note: This is equivalent to `Stack(this)`, but provided to allow for * chained expressions. */ toStack(): Stack; // Conversion to Seq /** * Converts this Collection to a Seq of the same kind (indexed, * keyed, or set). */ toSeq(): Seq; /** * Returns a Seq.Keyed from this Collection where indices are treated as keys. * * This is useful if you want to operate on an * Collection.Indexed and preserve the [index, value] pairs. * * The returned Seq will have identical iteration order as * this Collection. * * * ```js * const { Seq } = require('immutable') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') * // Seq [ "B" ] * const keyedSeq = indexedSeq.toKeyedSeq() * // Seq { 0: "A", 1: "B", 2: "C" } * keyedSeq.filter(v => v === 'B') * // Seq { 1: "B" } * ``` */ toKeyedSeq(): Seq.Keyed; /** * Returns an Seq.Indexed of the values of this Collection, discarding keys. */ toIndexedSeq(): Seq.Indexed; /** * Returns a Seq.Set of the values of this Collection, discarding keys. */ toSetSeq(): Seq.Set; // Iterators /** * An iterator of this `Collection`'s keys. * * Note: this will return an ES6 iterator which does not support * Immutable.js sequence algorithms. Use `keySeq` instead, if this is * what you want. */ keys(): IterableIterator; /** * An iterator of this `Collection`'s values. * * Note: this will return an ES6 iterator which does not support * Immutable.js sequence algorithms. Use `valueSeq` instead, if this is * what you want. */ values(): IterableIterator; /** * An iterator of this `Collection`'s entries as `[ key, value ]` tuples. * * Note: this will return an ES6 iterator which does not support * Immutable.js sequence algorithms. Use `entrySeq` instead, if this is * what you want. */ entries(): IterableIterator<[K, V]>; // Collections (Seq) /** * Returns a new Seq.Indexed of the keys of this Collection, * discarding values. */ keySeq(): Seq.Indexed; /** * Returns an Seq.Indexed of the values of this Collection, discarding keys. */ valueSeq(): Seq.Indexed; /** * Returns a new Seq.Indexed of [key, value] tuples. */ entrySeq(): Seq.Indexed<[K, V]>; // Sequence algorithms /** * Returns a new Collection of the same type with values passed through a * `mapper` function. * * * ```js * const { Collection } = require('immutable') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` * * Note: `map()` always returns a new instance, even if it produced the same * value at every step. */ map( mapper: (value: V, key: K, iter: this) => M, context?: any) : Collection; /** * Note: used only for sets, which return Collection but are otherwise * identical to normal `map()`. * * @ignore */ map(...args: never[]): any; /** * Returns a new Collection of the same type with only the entries for which * the `predicate` function returns true. * * * ```js * const { Map } = require('immutable') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: V, key: K, iter: this) => value is F, context?: any) : Collection; filter( predicate: (value: V, key: K, iter: this) => any, context?: any) : this; /** * Returns a new Collection of the same type with only the entries for which * the `predicate` function returns false. * * * ```js * const { Map } = require('immutable') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` * * Note: `filterNot()` always returns a new instance, even if it results in * not filtering out any values. */ filterNot( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : this; /** * Returns a new Collection of the same type in reverse order. */ reverse(): this; /** * Returns a new Collection of the same type which includes the same entries, * stably sorted by using a `comparator`. * * If a `comparator` is not provided, a default comparator uses `<` and `>`. * * `comparator(valueA, valueB)`: * * * Returns `0` if the elements should not be swapped. * * Returns `-1` (or any negative number) if `valueA` comes before `valueB` * * Returns `1` (or any positive number) if `valueA` comes after `valueB` * * Is pure, i.e. it must always return the same value for the same pair * of values. * * When sorting collections which have no defined order, their ordered * equivalents will be returned. e.g. `map.sort()` returns OrderedMap. * * * ```js * const { Map } = require('immutable') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } * if (a === b) { return 0; } * }); * // OrderedMap { "a": 1, "b": 2, "c": 3 } * ``` * * Note: `sort()` Always returns a new instance, even if the original was * already sorted. * * Note: This is always an eager operation. */ sort(comparator?: (valueA: V, valueB: V) => number): this; /** * Like `sort`, but also accepts a `comparatorValueMapper` which allows for * sorting by more sophisticated means: * * hitters.sortBy(hitter => hitter.avgHits) * * Note: `sortBy()` Always returns a new instance, even if the original was * already sorted. * * Note: This is always an eager operation. */ sortBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number) : this; /** * Returns a `Collection.Keyed` of `Collection.Keyeds`, grouped by the return * value of the `grouper` function. * * Note: This is always an eager operation. * * * ```js * const { List, Map } = require('immutable') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), * Map({ v: 1 }), * Map({ v: 0 }), * Map({ v: 2 }) * ]) * const groupsOfMaps = listOfMaps.groupBy(x => x.get('v')) * // Map { * // 0: List [ Map{ "v": 0 }, Map { "v": 0 } ], * // 1: List [ Map{ "v": 1 }, Map { "v": 1 } ], * // 2: List [ Map{ "v": 2 } ], * // } * ``` */ groupBy( grouper: (value: V, key: K, iter: this) => G, context?: any) : /*Map*/Seq.Keyed>; // Side effects /** * The `sideEffect` is executed for every entry in the Collection. * * Unlike `Array#forEach`, if any call of `sideEffect` returns * `false`, the iteration will stop. Returns the number of entries iterated * (including the last iteration which returned false). */ forEach( sideEffect: (value: V, key: K, iter: this) => any, context?: any) : number; // Creating subsets /** * Returns a new Collection of the same type representing a portion of this * Collection from start up to but not including end. * * If begin is negative, it is offset from the end of the Collection. e.g. * `slice(-2)` returns a Collection of the last two entries. If it is not * provided the new Collection will begin at the beginning of this Collection. * * If end is negative, it is offset from the end of the Collection. e.g. * `slice(0, -1)` returns a Collection of everything but the last entry. If * it is not provided, the new Collection will continue through the end of * this Collection. * * If the requested slice is equivalent to the current Collection, then it * will return itself. */ slice(begin?: number, end?: number): this; /** * Returns a new Collection of the same type containing all entries except * the first. */ rest(): this; /** * Returns a new Collection of the same type containing all entries except * the last. */ butLast(): this; /** * Returns a new Collection of the same type which excludes the first `amount` * entries from this Collection. */ skip(amount: number): this; /** * Returns a new Collection of the same type which excludes the last `amount` * entries from this Collection. */ skipLast(amount: number): this; /** * Returns a new Collection of the same type which includes entries starting * from when `predicate` first returns false. * * * ```js * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] * ``` */ skipWhile( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : this; /** * Returns a new Collection of the same type which includes entries starting * from when `predicate` first returns true. * * * ```js * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] * ``` */ skipUntil( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : this; /** * Returns a new Collection of the same type which includes the first `amount` * entries from this Collection. */ take(amount: number): this; /** * Returns a new Collection of the same type which includes the last `amount` * entries from this Collection. */ takeLast(amount: number): this; /** * Returns a new Collection of the same type which includes entries from this * Collection as long as the `predicate` returns true. * * * ```js * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] * ``` */ takeWhile( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : this; /** * Returns a new Collection of the same type which includes entries from this * Collection as long as the `predicate` returns false. * * * ```js * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] * ``` */ takeUntil( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : this; // Combination /** * Returns a new Collection of the same type with other values and * collection-like concatenated to this one. * * For Seqs, all entries will be present in the resulting Seq, even if they * have the same key. */ concat(...valuesOrCollections: Array): Collection; /** * Flattens nested Collections. * * Will deeply flatten the Collection by default, returning a Collection of the * same type, but a `depth` can be provided in the form of a number or * boolean (where true means to shallowly flatten one level). A depth of 0 * (or shallow: false) will deeply flatten. * * Flattens only others Collection, not Arrays or Objects. * * Note: `flatten(true)` operates on Collection> and * returns Collection */ flatten(depth?: number): Collection; flatten(shallow?: boolean): Collection; /** * Flat-maps the Collection, returning a Collection of the same type. * * Similar to `collection.map(...).flatten(true)`. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable, context?: any) : Collection; /** * Flat-maps the Collection, returning a Collection of the same type. * * Similar to `collection.map(...).flatten(true)`. * Used for Dictionaries only. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, context?: any) : Collection; // Reducing a value /** * Reduces the Collection to a value by calling the `reducer` for every entry * in the Collection and passing along the reduced value. * * If `initialReduction` is not provided, the first item in the * Collection will be used. * * @see `Array#reduce`. */ reduce( reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any) : R; reduce( reducer: (reduction: V | R, value: V, key: K, iter: this) => R) : R; /** * Reduces the Collection in reverse (from the right side). * * Note: Similar to this.reverse().reduce(), and provided for parity * with `Array#reduceRight`. */ reduceRight( reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any) : R; reduceRight( reducer: (reduction: V | R, value: V, key: K, iter: this) => R) : R; /** * True if `predicate` returns true for all entries in the Collection. */ every( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : boolean; /** * True if `predicate` returns true for any entry in the Collection. */ some( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : boolean; /** * Joins values together as a string, inserting a separator between each. * The default separator is `","`. */ join(separator?: string): string; /** * Returns true if this Collection includes no values. * * For some lazy `Seq`, `isEmpty` might need to iterate to determine * emptiness. At most one iteration will occur. */ isEmpty(): boolean; /** * Returns the size of this Collection. * * Regardless of if this Collection can describe its size lazily (some Seqs * cannot), this method will always return the correct size. E.g. it * evaluates a lazy `Seq` if necessary. * * If `predicate` is provided, then this returns the count of entries in the * Collection for which the `predicate` returns true. */ count(): number; count( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : number; /** * Returns a `Seq.Keyed` of counts, grouped by the return value of * the `grouper` function. * * Note: This is not a lazy operation. */ countBy( grouper: (value: V, key: K, iter: this) => G, context?: any) : Map_2; // Search for value /** * Returns the first value for which the `predicate` returns true. */ find( predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V) : V | undefined; /** * Returns the last value for which the `predicate` returns true. * * Note: `predicate` will be called for each entry in reverse. */ findLast( predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V) : V | undefined; /** * Returns the first [key, value] entry for which the `predicate` returns true. */ findEntry( predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V) : [K, V] | undefined; /** * Returns the last [key, value] entry for which the `predicate` * returns true. * * Note: `predicate` will be called for each entry in reverse. */ findLastEntry( predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V) : [K, V] | undefined; /** * Returns the key for which the `predicate` returns true. */ findKey( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : K | undefined; /** * Returns the last key for which the `predicate` returns true. * * Note: `predicate` will be called for each entry in reverse. */ findLastKey( predicate: (value: V, key: K, iter: this) => boolean, context?: any) : K | undefined; /** * Returns the key associated with the search value, or undefined. */ keyOf(searchValue: V): K | undefined; /** * Returns the last key associated with the search value, or undefined. */ lastKeyOf(searchValue: V): K | undefined; /** * Returns the maximum value in this collection. If any values are * comparatively equivalent, the first one found will be returned. * * The `comparator` is used in the same way as `Collection#sort`. If it is not * provided, the default comparator is `>`. * * When two values are considered equivalent, the first encountered will be * returned. Otherwise, `max` will operate independent of the order of input * as long as the comparator is commutative. The default comparator `>` is * commutative *only* when types do not differ. * * If `comparator` returns 0 and either value is NaN, undefined, or null, * that value will be returned. */ max(comparator?: (valueA: V, valueB: V) => number): V | undefined; /** * Like `max`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: * * hitters.maxBy(hitter => hitter.avgHits); * */ maxBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number) : V | undefined; /** * Returns the minimum value in this collection. If any values are * comparatively equivalent, the first one found will be returned. * * The `comparator` is used in the same way as `Collection#sort`. If it is not * provided, the default comparator is `<`. * * When two values are considered equivalent, the first encountered will be * returned. Otherwise, `min` will operate independent of the order of input * as long as the comparator is commutative. The default comparator `<` is * commutative *only* when types do not differ. * * If `comparator` returns 0 and either value is NaN, undefined, or null, * that value will be returned. */ min(comparator?: (valueA: V, valueB: V) => number): V | undefined; /** * Like `min`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: * * hitters.minBy(hitter => hitter.avgHits); * */ minBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number) : V | undefined; // Comparison /** * True if `iter` includes every value in this Collection. */ isSubset(iter: Iterable): boolean; /** * True if this Collection includes every value in `iter`. */ isSuperset(iter: Iterable): boolean; } /** * @class * Color objects are used in annotations for defining colors. We're using an rgb representation * internally with the `r`, `g`, `b` values clipped between `0` and `255` inclusive, and a `transparent` * flag that can be used to indicate that the color is transparent, in which case the provided `r`, `g`, * and `b` values are ignored and set to `0` in the instantiated `Color`. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `color.set("r", 255)`. * * However, in order to obtain a transparent color the static `TRANSPARENT` value should be used instead. * * The difference between using `Color.TRANSPARENT` and `null` as values for annotation color properties * may depend on the context; if the annotation is being created or updated: * - If an annotation with a non-transparent color value is updated to have a color value of `Color.TRANSPARENT`, * the color value will be updated and be transparent. * - But if that same annotation is updated to have a color value of `null`, the color change will not be saved * to the document, although it may appear as transparent in the viewer. * * To avoid inconsistencies, it is recommended to always use `Color.TRANSPARENT` instead of `null` when updating * annotations. * @example * Create and update a color. * ```ts * var color = new NutrientViewer.Color({ r: 245, g: 0, b: 0 }); * color = color.set("r", 255); * color.r; // => 255 * ``` * * @summary A simple RGB color value. * @param color - An object used to initialize the color. If `r`, `g` or `b` is omitted, `0` * will be used instead. * @default { r: 0, g: 0, b: 0, transparent: false } */ export declare class Color extends Color_base { /** Simple black (CSS: `rgb(0, 0, 0)`) */ static BLACK: Color; /** Grey (CSS: `rgb(128, 128, 128)`) */ static GREY: Color; /** Simple white (CSS: `rgb(255, 255, 255)`) */ static WHITE: Color; /** Blue (CSS: `rgb(36, 131, 199)`) */ static DARK_BLUE: Color; /** Red (CSS: `rgb(248, 36, 0)`) */ static RED: Color; /** Purple (CSS: `rgb(255, 0, 255)`) */ static PURPLE: Color; /** Pink (CSS: `rgb(255, 114, 147)`) */ static PINK: Color; /** Green (CSS: `rgb(110, 176, 0)`) */ static GREEN: Color; /** Orange (CSS: `rgb(243, 149, 0)`) */ static ORANGE: Color; /** Yellow (CSS: `rgb(255, 255, 0)`) */ static YELLOW: Color; /** Light blue (CSS: `rgb(141, 184, 255)`) */ static LIGHT_BLUE: Color; /** Light red (CSS: `rgb(247, 141, 138)`) */ static LIGHT_RED: Color; /** Light green (CSS: `rgb(162, 250, 123)`) */ static LIGHT_GREEN: Color; /** Light yellow (CSS: `rgb(252, 238, 124)`) */ static LIGHT_YELLOW: Color; /** Blue (CSS: `rgb(34, 147, 251)`) */ static BLUE: Color; /** Light orange (CSS: `rgb(255, 139, 94)`) */ static LIGHT_ORANGE: Color; /** Light grey (CSS: `rgb(192, 192, 192)`) */ static LIGHT_GREY: Color; /** Dark grey (CSS: `rgb(64, 64, 64)`) */ static DARK_GREY: Color; /** Mauve (CSS: `rgb(245, 135, 255)`) */ static MAUVE: Color; /** Transparent (CSS: `transparent`) */ static TRANSPARENT: Color; /** * Converts a hex color value to a Color instance. * * @param hexColor - The hex color value to convert. * @returns A Color instance. */ static fromHex: (hexColor: string) => Color; constructor(color: { r?: number; g?: number; b?: number; transparent?: boolean; }); /** * Returns a lighter version of the current Color. * * @example * const color = NutrientViewer.Color.RED.lighter(50); * * @param percent - The percentage of lightness between 0 and 100. * @returns A Color with the new values. */ lighter(percent: number): Color; /** * Returns a darker version of the current Color. * * @example * const color = NutrientViewer.Color.RED.darker(50); * * @param percent - The percentage of lightness between 0 and 100. * @returns A Color with the new values. */ darker(percent: number): Color; /** * Returns true if the provided color or object and the current Color have the same RGB values. * * @example * const color = NutrientViewer.Color.RED.equals({ r: 248, g: 36, b: 0 }); * * @param color - Color instance or RGB object. * @returns True if equal, false otherwise. */ equals(color: Color | { r: number; g: number; b: number; transparent: boolean; }): boolean; /** * Modifies the saturation of the Color and returns a new one. * * @example * const color = NutrientViewer.Color.RED.saturate(50); * * @param percent - The percentage of saturation between 0 and 100. * @returns A Color with the new values. */ saturate(percent: number): Color; sRGBToRGBComponent(RGBComponent: number): number; relativeLuminance(): number; contrastRatio(color: Color): number; /** * Converts the color to a CSS value (e.g. `rgb(255, 0, 0)`). * * @example * NutrientViewer.Color.RED.toCSSValue(); // => 'rgb(248, 36, 0)' * * @returns A CSS color value in `rgb` format. */ toCSSValue(): string; /** * Converts the color to a Hex value (e.g. `#000000`). * * @example * NutrientViewer.Color.RED.toHex(); // => '#f82400' * * @returns A CSS color value in `hex` format. */ toHex(): string; } declare const Color_base: Record_2.Factory<{ /** * The red value of the color. * * @default 0 */ r: number; /** * The green value of the color. * * @default 0 */ g: number; /** * The blue value of the color. * * @default 0 */ b: number; /** * Transparency of the color. * * @default false */ transparent: boolean; }>; export declare type ColorPreset = { /** * The Color represented by this preset. Eg: `new NutrientViewer.Color({ r: 255, g: 139, b: 94 })`. * * `null` means transparent. */ color: Color | null; localization: { /** The ID of the preset color. Eg: 'red' */ id: string; /** The default message of the preset color. Eg: 'Red' */ defaultMessage?: string; /** The description of the preset color. Eg: 'Red color' */ description?: string; }; }; declare type ColorPreset_2 = ColorPreset; /** * @class * * A combo box is a drop down box with the option to add custom entries * (see {@link FormFields.ComboBoxFormField#edit}). * * Please note that {@link Instance#getFormFieldValues} will not return * the latest value for this field until the user leaves this field by default. If you * want this value to update on every change then set the {@link FormFields.ChoiceFormField#commitOnChange}) to * true. * @public * @summary A drop down box with the option to add custom entries. */ export declare class ComboBoxFormField extends ChoiceFormField { /** * If true, the combo box includes an editable text box as well as a drop-down list. Otherwise, it * includes only a drop-down list. * * @default false */ edit: boolean; /** * If true, text entered in the field is not spell-checked. * * @default false */ doNotSpellCheck: boolean; } /** * @class * A text comment made by the user that stems from an existing root annotation. * @summary Comment element. */ declare class Comment_2 extends Comment_base { /** * Comment serializer. Converts a comment to a InstantJSON compliant object. * * @param comment - The comment to serialize. * @returns The serialized comment. */ static toSerializableObject: (comment: Comment_2) => Serializers.CommentJSON; /** * Comment deserializer. Converts a comment object to a {@link NutrientViewer.Comment}. * * @param comment - The comment to deserialize. * @returns The deserialized comment. */ static fromSerializableObject: (comment: Serializers.CommentJSON) => Comment_2; /** * A method that returns a set of user IDs that are mentioned in the comment. * * @example * const ids = comment.getMentionedUserIds() * * @returns An immutable set of user IDs that are mentioned in the comment. */ getMentionedUserIds(): Immutable.Set; constructor(options?: Partial); } export { Comment_2 as Comment }; declare const Comment_base: Immutable.Record.Factory; /** * A specific comment display mode that will always be applied when the visible part of the document contains comments. * * In mobile devices, comments are always displayed in a drawer a the bottom of the viewport * * @enum */ export declare const CommentDisplay: { /** Comments are displayed in a dialog or floating depending on the available viewport space. */ readonly FITTING: "FITTING"; /** Comments are displayed in a popover dialog next to their reference annotation marker. */ readonly POPOVER: "POPOVER"; /** Comments are displayed floating next to the page side, at the same height as their reference annotation marker, except when `ViewState#zoom` is set to `ZoomeMode#FIT_TO_WIDTH`, in which case they are displayed in a popover dialog instead. */ readonly FLOATING: "FLOATING"; }; /** * @class * Annotation specific to NutrientViewer that defines a general root annotation type * for comments to originate from, which can be placed at an arbitrary location * in the document. * * See our * {@link https://www.nutrient.io/guides/web/annotations/comments-and-replies/comments/ | Instant Comments guide article}. * @summary Root annotation used for comments. */ export declare class CommentMarkerAnnotation extends Annotation { static readableName: string; } declare class CommentMarkerAnnotationSerializer extends AnnotationSerializer { annotation: CommentMarkerAnnotation; constructor(annotation: CommentMarkerAnnotation); toJSON(): Serializers.CommentMarkerAnnotationJSON; static fromJSON(id: InstantID | null, json: Omit, options?: ICollaboratorPermissionsOptions): CommentMarkerAnnotation; } declare function CommentPermissionMixin>(Base: T): { new (...args: any[]): { /** * This method is used to update the isEditableComment callback * * When the supplied callback is invalid it will throw a {@link Error} that contains a * detailed error message. * * To learn more check * {@link https://www.nutrient.io/guides/web/annotations/comments-and-replies/comments/#comment-permissions | this guide article}. * * @example * Only allow editing comments from a specific creator name * ```ts * instance.setIsEditableComment((comment) => comment.creatorName === myCurrentUser.name); * ``` * * @throws {Error} Will throw an error when the supplied array is not valid. */ setIsEditableComment(isEditableCommentCallback: IsEditableCommentCallback): void; }; } & T; /** @inline */ declare type CommentProps = { /** * A unique identifier for the comment. When comment is created in the UI, the * viewer has to generate a unique ID. */ id: InstantID | null; /** * The ID of the annotation that this comment stems from. In Nutrient Web SDK, * this should be either a {@link NutrientViewer.Annotations.MarkupAnnotation} or * a {@link NutrientViewer.Annotations.CommentMarkerAnnotation}. */ rootId: InstantID | null; /** * The page index that this comment resides at. */ pageIndex: null | number; /** * If this comment is from the original PDF, then this ID is from that PDF * note annotation that defined the comment. */ pdfObjectId: number | null; /** * The name of the person who created the comment. */ creatorName: string | null; /** * The time when the comment was created. */ createdAt: Date; /** * The time when the comment was last updated. */ updatedAt: Date; /** * The text of the comment in xhtml/plain text format. * * In case of XHTML, we support the following tags: * - ``: Bold * - ``: Italic * - ``: Font color, background color and underline using the `style` attribute (e.g. `Hello`) * - `p`: Paragraph. You can use this to add a newline between paragraphs. * - `a`: Link. You can use this to add a link to the comment. The `href` attribute is required. */ text: { format: 'plain' | 'xhtml'; value: string | null; }; /** * Arbitrary JSON-serializable data the user can attach to the comment. */ customData: Record | null; /** * This property is used to define the permission scope for a particular comment. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ group?: string | null; /** * This property defines whether this comment can be edited or not. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly isEditable?: boolean; /** * This property defines whether this comment can be deleted or not. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly isDeletable?: boolean; /** * This property defines whether the user has permission to edit the group of this comment. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly canSetGroup?: boolean; }; declare function CommentsMixin>(Base: T): { new (...args: any[]): { /** * Returns a {@link NutrientViewer.Immutable.List} of {@link Comment} for the current document. * * The list contains an immutable snapshot of the currently available comments in the UI. * * When you want to keep a reference to the latest comments, you can listen for * {@link NutrientViewer.EventName.COMMENTS_CHANGE}. * * @example * instance.getComments().then(function (comments) { * comments.forEach(comment => { * console.log(comment.text); * }); * * // Get the number of currently loaded comments * const totalComments = comments.size; * }) * * @param options - An object to configure the comments retrieval - {@link GetCommentsOptions} * * @returns Resolves to comments. */ getComments(options?: GetCommentsOptions): Promise>; /** * Set a list of users that can be mentioned in comments. * * @example * instance.setMentionableUsers([ * { id: "1", name: "John Doe", displayName: "John", avatar: "https://example.com/avatar.png" }, * { id: "2", name: "Jane Doe", displayName: "Jane", avatar: "https://example.com/avatar.png" }, * { id: "3", name: "John Smith", displayName: "John", avatar: "https://example.com/avatar.png" }, * ]); * * @server * @param mentionableUsers - An array of {@link MentionableUser} objects. */ setMentionableUsers(mentionableUsers: MentionableUser[]): void; /** * Set the maximum number of suggestions that will be shown when mentioning a user. * * @example * instance.setMaxMentionSuggestions(5); * * @server * @param maxMentionSuggestions - The maximum number of suggestions that will be shown when mentioning a user. */ setMaxMentionSuggestions(maxMentionSuggestions: number): void; /** * You can programmatically modify the properties of the comment just before it is created. * * @example * instance.setOnCommentCreationStart((comment) => { * return comment.set('text', { format: 'xhtml', value: '

This comment has a default value

' }); * }); * * @param callback - The callback to set the values of created form fields programmatically. */ setOnCommentCreationStart(callback: OnCommentCreationStartCallback): void; }; } & T; /** * Slots for partial customization of the comment thread. * * @see {@link UI.SlotConfiguration} * * @inline */ declare type CommentThreadUIOptions = { /** * Use this to render a custom UI in the header (top area) of the UI. * * @example * * Add a custom header to the comment thread by customizing the `header` slot: * * ```ts * NutrientViewer.load({ * // ... Your configuration. * ui: { * commentThread: { * header: () => { * return { * render: () => { * const div = document.createElement("div"); * div.style.backgroundColor = "lightgreen"; * div.style.padding = "5px"; * div.innerText = "This is a custom header for the comment thread."; * * return div; * }, * }; * }, * }, * }, * }); * ``` */ header?: UI.SlotConfigurationCallback; /** * Use this to render a custom UI in the footer (bottom area) of the UI. * * @example * * Add a custom footer to the comment thread by customizing the `footer` slot: * * ```ts * NutrientViewer.load({ * // ... Your configuration. * ui: { * commentThread: { * footer: () => { * return { * render: () => { * const div = document.createElement("div"); * div.style.backgroundColor = "lightgreen"; * div.style.padding = "5px"; * div.innerText = "This is a custom footer for the comment thread."; * * return div; * }, * }; * }, * }, * }, * }); * ``` */ footer?: UI.SlotConfigurationCallback; /** * Use this to customize the editor area. * * @example * * Replace the editor area by customizing the `editor` slot: * * ```ts * NutrientViewer.load({ * // ... Your configuration. * ui: { * commentThread: { * editor: () => { * return { * render: () => { * const div = document.createElement("div"); * div.style.backgroundColor = "lightgreen"; * div.style.padding = "5px"; * // You can add your custom editor implementation here. * * return div; * }, * }; * }, * }, * }, * }); * ``` */ editor?: UI.SlotConfigurationCallback; /** * Use this to customize each comment fully or provide slots for partial customization. * * @example * * Customize each `comment` within the comment thread: * * ```ts * NutrientViewer.load({ * // ... Your configuration. * ui: { * commentThread: { * comment: () => { * return { * render: () => { * const div = document.createElement("div"); * div.style.backgroundColor = "lightgreen"; * div.style.padding = "5px"; * div.innerText = "This is a custom comment for the comment thread."; * * return div; * }, * }; * }, * }, * }, * }); * ``` */ comment?: UI.CommentUI; }; /** * ComparisonOperation is a class that provides methods to describe a comparison operation. * It encapsulates the type and optional settings for the comparison. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `scale.set("options", { numberOfContextWords: 4 })` * * @example * Create a new text comparison operation. * ```ts * const operation = new ComparisonOperation(NutrientViewer.ComparisonOperationType.TEXT, { numberOfContextWords: 2 }); * ``` * * @example * Create a new AI comparison operation. * ```ts * const aiOperation = new ComparisonOperation( * NutrientViewer.ComparisonOperationType.AI, * { operationType: NutrientViewer.AIComparisonOperationType.ANALYZE, model: 'gpt4o' } * ); * ``` * * @public * @summary The descriptor for a comparison operation. * @default { type: NutrientViewer.ComparisonOperationType.TEXT, options: { numberOfContextWords: 0 } } */ export declare class ComparisonOperation extends ComparisonOperation_base { constructor(type: IComparisonOperationType, options?: ITextComparisonOperationOptions | IAIComparisonOperationOptions); /** * Returns true if this operation is a text comparison */ isTextComparison(): boolean; /** * Returns true if this operation is an AI comparison */ isAIComparison(): boolean; /** * Returns the AI operation type, if this is an AI comparison */ getAIOperationType(): IAIComparisonOperationType | undefined; } declare const ComparisonOperation_base: Record_2.Factory; declare type ComparisonOperationJSON = { type: IComparisonOperationType; options?: { numberOfContextWords?: number; wordLevel?: boolean; }; }; /** * Describes types for document comparison operation. * * @enum */ declare const ComparisonOperationType: { /** Compare the text of documents. */ readonly TEXT: "text"; /** Compare documents using AI-powered analysis. */ readonly AI: "ai"; }; /** * @replaceWith export interface Configuration extends SharedConfiguration, Partial & Omit>{} */ export declare type Configuration = ServerConfiguration | StandaloneConfiguration; /** * Represents one of the available conformance types for PDF/A documents. * * @enum */ export declare const Conformance: { /** PDF/A-1a conformance level (Level A) - Full accessibility and tagged PDF support. */ readonly PDFA_1A: "pdfa-1a"; /** PDF/A-1b conformance level (Level B) - Basic visual appearance preservation. */ readonly PDFA_1B: "pdfa-1b"; /** PDF/A-2a conformance level (Level A) - Enhanced accessibility with JPEG 2000 and transparency support. */ readonly PDFA_2A: "pdfa-2a"; /** PDF/A-2u conformance level (Level U) - Unicode mapping requirement with JPEG 2000 and transparency support. */ readonly PDFA_2U: "pdfa-2u"; /** PDF/A-2b conformance level (Level B) - Basic visual appearance preservation with JPEG 2000 and transparency support. */ readonly PDFA_2B: "pdfa-2b"; /** PDF/A-3a conformance level (Level A) - Full accessibility with embedded files support. */ readonly PDFA_3A: "pdfa-3a"; /** PDF/A-3u conformance level (Level U) - Unicode mapping with embedded files support. */ readonly PDFA_3U: "pdfa-3u"; /** PDF/A-3b conformance level (Level B) - Basic visual appearance preservation with embedded files support. */ readonly PDFA_3B: "pdfa-3b"; /** PDF/A-4 conformance level - Latest standard based on PDF 2.0 with enhanced features. */ readonly PDFA_4: "pdfa-4"; /** PDF/A-4e conformance level - Engineering variant with 3D support. */ readonly PDFA_4E: "pdfa-4e"; /** PDF/A-4f conformance level - Enhanced support for embedded files. */ readonly PDFA_4F: "pdfa-4f"; }; export declare namespace ContentEditing { /** * Describes the properties used to update a text block. * * This is a partial text block that contains the id of the text block and the new text. * It is used to update the text block in the document. * * @see {@link ContentEditing.Session#updateTextBlocks} */ export interface UpdatedTextBlock { /** Unique identifier for the text block. */ id: string; /** The new text content of the text block. */ text?: string; /** The anchor point of the text block. */ anchor?: { x?: number; y?: number; }; /** The maximum width of the text block. */ maxWidth?: number; } /** * This describes the content editor session returned by {@link Instance#beginContentEditingSession}. * * It is independent of the content editor UI session, which is used to display the content editor UI. At one time, only one content editing session can be active, either this session or a UI session. Starting the UI session will deactivate this session. * Also, if the contents of an opened document are modified while this session is active, the session will be deactivated. * * Using this requires a license that includes the Content Editor component. */ export interface Session { /** * Completes the current editing session and saves all changes. Document will reload. * * @returns A promise that resolves when the changes have been successfully saved. */ commit: () => Promise; /** * Completes the current editing session without persisting any changes. * * @returns A promise that resolves when the session is successfully discarded. */ discard: () => Promise; /** * Retrieves all text blocks for a specific page. * * @param pageIndex - The index of the page to retrieve text blocks for. * @returns A promise that resolves with an array of TextBlocks for the given page. * @throws {Error} If the page index is out of bounds. */ getTextBlocks: (pageIndex: number) => Promise; /** * Updates an array of text blocks with partial data. * * @param textBlocks - Array of UpdatedTextBlock objects to update. * @returns A promise that resolves when the update is complete. * @throws {Error} If the ID of any text block is missing or doesn't exist. */ updateTextBlocks: (textBlocks: ContentEditing.UpdatedTextBlock[]) => Promise; /** * Indicates whether the session is currently active. */ active: boolean; } /** * Describes the properties of a text block detected on a page. * * Contains the text, the bounding box in PDF coordinates, and the anchor point. * * @see {@link ContentEditing.Session#getTextBlocks} */ export type TextBlock = { /** Unique identifier for the text block. */ id: string; /** The text content of the text block. */ text: string; /** The current bounding box of the text block, in PDF coordinates. */ boundingBox: { /** The top coordinate of the bounding box. */ top: number; /** The left coordinate of the bounding box. */ left: number; /** The width of the bounding box. */ width: number; /** The height of the bounding box. */ height: number; }; /** The anchor point of the text block. */ anchor: { x: number; y: number; }; /** The maximum width of the text block. */ maxWidth: number; }; /** * Font selection result for content editing font matching. */ export interface FontMatchResult { /** The specific font face to use from the available fonts array */ font: AvailableFontFace; /** The font size to use. If not specified, the size reported by the PDF will be used. */ size: number | null | undefined; } /** * Font information extracted from PDF during content editing. */ export interface FontInfo { /** The font name as declared in the PDF (e.g., "Helvetica-BoldOblique"). Rarely we can't find any name information. */ name: string | null; /** The current font size being used. If matching is called during text selection, this may be null. */ fontSize: number | null; /** Information about subset fonts detected in the PDF. */ subsetInfo?: { /** Full font name with subset prefix (e.g., "ABCDEF+Helvetica") */ originalName: string; /** Extracted base font name without prefix (e.g., "Helvetica") */ demangledName: string; }; } /** * Available font face for content editing font matching. * Each font face represents a specific combination of family and style. */ export interface AvailableFontFace { /** The font family name (e.g., "Arial", "Times New Roman") */ family: string; /** Whether this font face is bold */ bold: boolean; /** Whether this font face is italic */ italic: boolean; } /** * Callback to evaluate or override a font match during content editing. * * This callback is invoked when the system has determined a best-match font for text * during content editing operations. It allows developers to provide custom font * matching logic or override the system's choice. * * The callback receives the system's proposed font match, metadata about the * original font from the PDF, the current font size, and a list of all available * fonts that can be used. It can return a different font reference to override * the match, or `undefined` to accept the system's choice. * * @param match - The font name selected by the system as the best match. * @param fontInfo - Font metadata from the PDF including current size. * @param availableFonts - Array of all fonts available for use in content editing. * * @returns A font and size to override the match, or `undefined` to accept the system match. * @example * Simple font matching using available fonts. * ```ts * NutrientViewer.load({ * contentEditingFontMatcher: (match, fontInfo, availableFonts) => { * // For Helvetica, try to find Arial or use the first available font * if (fontInfo.name?.includes("Helvetica")) { * const arialFont = availableFonts.find(font => font.family === "Arial" && !font.bold && !font.italic); * if (arialFont) { * return { font: arialFont, size: fontInfo.fontSize }; * } * // Fallback to first available font * if (availableFonts.length > 0) { * return { font: availableFonts[0], size: fontInfo.fontSize }; * } * } * return undefined; // Accept system match * } * }); * ``` */ export type FontMatcher = (match: string, fontInfo: FontInfo, availableFonts: AvailableFontFace[]) => FontMatchResult | undefined; /** * @deprecated Use `ContentEditing.FontMatcher` instead */ export type ContentEditingFontMatcher = FontMatcher; } declare function ContentEditorMixin>(Base: T): { new (...args: any[]): { /** * Saves changes made in the current UI content editing session and exits * content editing mode. * * This is the programmatic equivalent of pressing the "Save" button in * the exit content editor dialog. * * Using this method requires a license that includes the Content Editor component. * * @throws {Error} If the Content Editor license feature is not available. * @throws {Error} If no UI content editing session is currently active. * @throws {Error} If the session is currently being saved. * @returns A promise that resolves when the save is complete. */ saveContentEditingSession(): Promise; /** * Discards changes made in the current UI content editing session and exits * content editing mode. * * This is the programmatic equivalent of pressing the "Don't Save" button * in the exit content editor dialog. * * Using this method requires a license that includes the Content Editor component. * * @throws {Error} If the Content Editor license feature is not available. * @throws {Error} If no UI content editing session is currently active. * @throws {Error} If the session is currently being saved. * @returns A promise that resolves when the session has been discarded. */ discardContentEditingSession(): Promise; /** * Returns whether the current UI content editing session has unsaved changes. * * Returns `false` if no UI content editing session is active. * * @returns `true` if there are unsaved changes, `false` otherwise. */ hasUnsavedContentEditingChanges(): boolean; /** * Creates and returns a new content editing session. * * If called in a Server-backed instance, * we will download the document and WASM in the background automatically. * * Using this method requires a license that includes the Content Editor component. * * @throws {Error} If a session (either UI or API) is already in progress. * @returns A promise that resolves to a {@link ContentEditing.Session} object. */ beginContentEditingSession(): Promise; /** * Exports the PDF with pending content editor changes applied, without ending the session. * * Requires a UI content editing session to be in progress * (see the [Content Editing guide](https://www.nutrient.io/guides/web/editor/edit-text/)). * * @returns A promise that resolves with the exported PDF as an ArrayBuffer. */ exportContentEditorPDF(): Promise; }; } & T; /** * Converts a document to the specified supported conversion format. * * Returns a {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise} * resolving to an `ArrayBuffer` of the converted document, or rejecting with a {@link NutrientViewer.Error}. * * It requires a {@link Configuration | configuration object}. If the configuration is * invalid, the promise will be rejected with a {@link NutrientViewer.Error}. * * @example * NutrientViewer.convertToOffice({ * document: "/article.pdf", * licenseKey: "YOUR_LICENSE_KEY", * }, * NutrientViewer.OfficeDocumentFormat.docx * ).then((arrayBuffer) => { * console.log("Successfully converted document", arrayBuffer); * }).catch((error) => { * console.error(error.message); * }) * * @public * @param configuration - A configuration Object. * @param format - Format to export the document to. * @returns Promise that resolves to an ArrayBuffer of the converted file */ declare function convertToOffice(configuration: StandaloneConfiguration, format: IDocumentOfficeFormat): Promise; /** * Converts a file to a PDF. * * Returns a {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise} * resolving to an `ArrayBuffer` of a PDF, or rejecting with a {@link NutrientViewer.Error}. * * The resulting `ArrayBuffer` can be directly loaded with {@link NutrientViewer.load | NutrientViewer.load()}. * * It requires a {@link Configuration | configuration object}. If the configuration is * invalid, the promise will be rejected with a {@link NutrientViewer.Error}. * * @example * NutrientViewer.convertToPDF({ * document: "/sales-report.docx", * licenseKey: "YOUR_LICENSE_KEY", * }).then((arrayBuffer) => { * console.log("Successfully converted document", arrayBuffer); * }).catch((error) => { * console.error(error.message); * }) * * @public * @param configuration - A configuration Object * @param conformance - A conformance level of the output PDF * @param officeConversionSettings - Settings specific to office conversion * @returns Promise that resolves to an ArrayBuffer of a file converted to PDF */ declare function convertToPDF(configuration: StandaloneConfiguration, conformance?: IConformance | null, officeConversionSettings?: OfficeConversionSettings): Promise; /** @inline */ declare type CoreActionJSON = { type: 'uri'; uri: string; subactions?: Array; } | { type: 'goTo'; pageIndex: number; subactions?: Array; } | { type: 'goToEmbedded'; newWindow: boolean; relativePath: string; targetType: 'parent' | 'child'; subactions?: Array; } | { type: 'goToRemote'; relativePath: string; namedDestination: string; subactions?: Array; } | { type: 'hide'; hide: boolean; annotationReferences: Array; subactions?: Array; } | { type: 'resetForm'; fields: Array | null; flags: string | null; subactions?: Array; } | { type: 'submitForm'; uri: string; fields: Array | null; flags: Array | null; subactions?: Array; } | { type: 'launch'; filePath: string; subactions?: Array; } | { type: 'named'; action: Omit; subactions?: Array; } | { type: 'named'; action: 'custom'; customAction: NamedCustomAction; subactions?: Array; } | { type: 'javaScript'; script: string; subactions?: Array; }; /** * This record is used to persist the information for a Custom Overlay Item. * * Custom Overlay Items are user defined DOM `Node`s that are rendered in a page at a given position. * * @example * Creating an image and rendering it as Custom Overlay Item. * ```ts * let img = document.createElement("img"); * img.src = "https://example.com/logo.png"; * * const item = new NutrientViewer.CustomOverlayItem({ * id: "logo-item", * node: img, * pageIndex: 0, * position: new NutrientViewer.Geometry.Point({ x: 100, y: 100 }), * onAppear() { * console.log('rendered!'); * } * }); * * instance.setCustomOverlayItem(item); * ``` * * @summary Custom Item to render in a page. * @see {@link NutrientViewer.Instance#setCustomOverlayItem} * @see {@link Configuration} */ export declare class CustomOverlayItem extends CustomOverlayItem_base { /** * Whether the node should not be zoomed (scaled) with the page. * * Custom zoom handling makes sense when you want to display rasterized images for example, * and you need to manually re-render them (maybe when using `` images or want to display * images at different resolutions). * * To track zoom changes and manually update overlay items you can subscribe to the * {@link Events.ViewStateZoomChangeEvent | `viewState.zoom.change`} event. * * By default items will zoom with the page using a CSS based scale transformation. * * @default false */ disableAutoZoom: boolean; /** * A unique identifier to describe the custom overlay item. * New IDs should be generated by the user and should be unique. */ id: CustomOverlayItemID; /** * A reference to the DOM `Node` to render in the page. */ node: Node; /** * Whether the node should not be rotated with the page. */ noRotate: boolean; /** * The page index on which the custom item is placed. It's important to notice that a custom item * can only ever be on one page. */ pageIndex: number; /** * Position of this custom item in the page. * The coordinates are in the PDF page space with the origin being on the top left. */ position: Point; /** * Optional callback to invoke when the custom item is created and appears in the viewport. */ onAppear?: ((...args: Args) => void) | null; /** * Optional callback to invoke when the custom item is removed. */ onDisappear?: ((...args: Args) => void) | null; constructor(args: ICustomOverlayItem); } declare const CustomOverlayItem_base: Record_2.Factory; declare type CustomOverlayItemID = string; declare function CustomOverlayItemsMixin>(Base: T): { new (...args: any[]): { /** * This method is used to set a new {@link CustomOverlayItem} or update an existing one. * * @example * Add a text node to the first page. * ```ts * let item = new NutrientViewer.CustomOverlayItem({ * id: "1", * node: document.createTextNode("Hello from Nutrient Web SDK."), * pageIndex: 0, * position: new NutrientViewer.Geometry.Point({ x: 100, y: 200 }), * }); * instance.setCustomOverlayItem(item); * ``` * * @example * Update a text node. * ```ts * item = item.set("node", document.createTextNode("Hello again my friend!!!")); * instance.setCustomOverlayItem(item); * ``` * * @param item - The item to create or update. */ setCustomOverlayItem(item: CustomOverlayItem): void; /** * This method is used to remove an existing {@link CustomOverlayItem}. * * @example * Create and then remove a text node. * ```ts * const id = "1"; * const item = new NutrientViewer.CustomOverlayItem({ * id: id, * node: document.createTextNode("Hello from Nutrient Web SDK."), * pageIndex: 0, * position: new NutrientViewer.Geometry.Point({ x: 100, y: 200 }), * }); * instance.setCustomOverlayItem(item); * * instance.removeCustomOverlayItem(id); * ``` * * @param id - The `id` of the item to remove. */ removeCustomOverlayItem(id: CustomOverlayItemID): void; }; } & T; /** * This object can include functions to be called when specific entities, like annotations, * are being rendered in the viewport, and return additional or replacement DOM content for * the entity instance. * * Currently only annotation's rendering can be customized using the `Annotation` key. * * If the callback returns null, the instance will be rendered normally. * * @summary Keyed list of callbacks called when entities are rendered. * @example * NutrientViewer.load({ * customRenderers: { * Annotation: ({ annotation }) => ({ * node: document.createElement("div").appendChild(document.createTextNode("Custom rendered!")), * append: true, * }) * } * }); * * @see {@link Configuration.customRenderers} * @see {@link NutrientViewer.Instance#setCustomRenderers} */ export declare type CustomRenderers = { /** * This user defined function receives the {@link AnnotationsUnion} to be rendered as argument. * * It must return a {@link RendererConfiguration} object or null. * * @public */ Annotation?: (options: { /** Annotation to be rendered. */ annotation: AnnotationsUnion; }) => RendererConfiguration | null | undefined; CommentAvatar?: (options: { comment: Comment_2; }) => RendererConfiguration | null | undefined; }; export declare type CustomUI = Partial>; /** * This callback can be used in the {@link NutrientViewer.Instance#setCustomUIConfiguration | setCustomUIConfiguration()} * method to do atomic updates to the current custom UI configuration and currently rendered UI elements. * * @inline */ declare type CustomUIConfigurationSetter = (customUI: CustomUI | null) => CustomUI; declare type CustomUIElementConfiguration = CustomUISidebarConfiguration; declare type CustomUISidebarConfiguration = Partial<{ [K in ISidebarMode]: Renderer }>; /** * Defining this callback allows you to customize how dates are rendered as part * of the NutrientViewer UI. * * @public * @example * NutrientViewer.load({ * dateTimeString: ({ dateTime, element }) => { * if(element === NutrientViewer.UIDateTimeElement.ANNOTATIONS_SIDEBAR) { * return new Intl.DateTimeFormat("en-US", { * dateStyle: "short", * timeStyle: "short", * }).format(dateTime); * } else { * return new Intl.DateTimeFormat("en-US", { * dateStyle: "full", * timeStyle: "long", * }).format(dateTime); * } * } * // ... * }); * */ export declare type DateTimeStringCallback = (args: { /** The date to be formatted. */ dateTime: Date; /** The NutrientViewer UI element on which the date is going to be rendered. */ element: IUIDateTimeElement; /** The annotation or comment that contains the date that is being rendered. */ object: AnnotationsUnion | Comment_2; }) => string; /** * Namespace for the internationalization and localization (i18n) configuration. * The current locale can be retrieved via {@link NutrientViewer.Instance#locale}, * and set with {@link NutrientViewer.Instance#setLocale}. * * @public * @namespace NutrientViewer.I18n * @summary Namespace for the i18n configuration. */ declare const _default: { /** * Returns an array of available locales. Each entry in the array is a string representing the * locale e.g. `en`. The array can be mutated directly to add new locales. Note that when adding * new locales you also need to add the corresponding * {@link NutrientViewer.I18n.messages translated messages}. * * @example * Add a new locale. * ```ts * NutrientViewer.I18n.locales.push("fr"); * ``` */ readonly locales: string[]; /** * Returns an object containing the translated messages for every locale. * In the messages object each key represents the locale and values are objects containing * `messageId`-`translated message` pairs. * * The messages object can be mutated directly to change translations or add new ones. * * @example The messages object * { * "en": { * "delete": "Delete", * "openPDF": "Open PDF" * }, * "it": { * "delete": "Rimuovi", * "openPDF": "Apri PDF" * } * } * * @example * Mutate the messages object. Replace "Open PDF" with "Open". * ```ts * NutrientViewer.I18n.messages.en.openPDF = "Open"; * ``` */ readonly messages: Record>; /** * Nutrient Web SDK comes with a number of {@link NutrientViewer.I18n.locales predefined locales} * which are loaded automatically on demand when using the {@link NutrientViewer.Instance#setLocale} * API or when setting a locale in the main {@link Configuration}. * * The locale information are then exposed to {@link NutrientViewer.I18n.messages}. * * You can use this method to preload these information instead of loading them on demand. * This would allow you to modify some translations before {@link NutrientViewer.load loading Nutrient Web SDK} for example. * * @param locale - The locale to load the localization data for. * @param options - The options for the preloadLocalizationData function. * @returns Returns a promise that resolves when the locale data have been loaded. */ readonly preloadLocalizationData: (locale: string, options?: { /** The location of the `nutrient-viewer-lib` directory. See {@link Configuration#baseUrl}. */ baseUrl?: string; }) => Promise; }; /** * Returns a deep copy of an array containing the default * {@link NutrientViewer.Annotations | editable annotation types}. */ declare const _default_2: readonly (typeof WidgetAnnotation | typeof TextAnnotation | typeof CommentMarkerAnnotation)[]; /** * Returns a deep copy of an array containing the default * {@link ElectronicSignatureCreationMode | creationModes} offered as part of * the electronic signatures modal. * * 1. `DRAW` * 2. `IMAGE` * 3. `TYPE` */ declare const _default_3: readonly ("DRAW" | "IMAGE" | "TYPE")[]; /** * Returns a deep copy of an array containing the default * {@link NutrientViewer.Font | fonts} that are available for * electronic signatures. * * 1. `NutrientViewer.Font({ name: 'Caveat' })` * 4. `NutrientViewer.Font({ name: 'Pacifico' })` * 2. `NutrientViewer.Font({ name: 'Marck Script' })` * 3. `NutrientViewer.Font({ name: 'Meddon' })` */ declare const _default_4: readonly Font[]; declare const defaultAnnotationPresets: { [key: string]: Record; }; declare const defaultAnnotationsSidebarContent: typeof defaultAnnotationsSidebarContent_2; /** * Returns a deep copy of an array containing the default annotation * classes that are included in the annotations sidebar UI. * * These members are: * 1. {@link NutrientViewer.Annotations.EllipseAnnotation} * 2. {@link NutrientViewer.Annotations.HighlightAnnotation} * 3. {@link NutrientViewer.Annotations.ImageAnnotation} * 4. {@link NutrientViewer.Annotations.InkAnnotation} * 5. {@link NutrientViewer.Annotations.LineAnnotation} * 6. {@link NutrientViewer.Annotations.NoteAnnotation} * 7. {@link NutrientViewer.Annotations.PolygonAnnotation} * 8. {@link NutrientViewer.Annotations.PolylineAnnotation} * 9. {@link NutrientViewer.Annotations.RectangleAnnotation} * 10. {@link NutrientViewer.Annotations.SquiggleAnnotation} * 11. {@link NutrientViewer.Annotations.StampAnnotation} * 12. {@link NutrientViewer.Annotations.StrikeOutAnnotation} * 13. {@link NutrientViewer.Annotations.TextAnnotation} * 14. {@link NutrientViewer.Annotations.UnderlineAnnotation} * 15. {@link NutrientViewer.Annotations.WidgetAnnotation} * * @see {@link ViewState#sidebarOptions} * @see {@link AnnotationsSidebarOptions} * @see {@link SidebarOptions} */ declare const defaultAnnotationsSidebarContent_2: readonly [typeof Annotation_2.EllipseAnnotation, typeof Annotation_2.HighlightAnnotation, typeof Annotation_2.ImageAnnotation, typeof Annotation_2.InkAnnotation, typeof Annotation_2.LineAnnotation, typeof Annotation_2.NoteAnnotation, typeof Annotation_2.PolygonAnnotation, typeof Annotation_2.PolylineAnnotation, typeof Annotation_2.RectangleAnnotation, typeof Annotation_2.SquiggleAnnotation, typeof Annotation_2.StampAnnotation, typeof Annotation_2.StrikeOutAnnotation, typeof Annotation_2.TextAnnotation, typeof Annotation_2.UnderlineAnnotation, typeof Annotation_2.WidgetAnnotation]; declare const defaultDocumentEditorFooterItems: typeof defaultDocumentEditorFooterItems_2; /** * Returns a deep copy of an array containing the default {@link NutrientViewer.DocumentEditorFooterItem|document editor footer items} * ordered by {@link NutrientViewer.DocumentEditorFooterItem#type} in the following way: * * 1. `cancel` * 2. `selected-pages` * 3. `spacer` * 4. `loading-indicator` * 5. `save-as` * 6. `save` * * The `loading-indicator` is only visible when the changes are being committed and `selected-pages` is only visible when you have selected multiple pages. * * @see {@link DocumentEditorFooterItem} */ declare const defaultDocumentEditorFooterItems_2: { type: BuiltInDocumentEditorFooterItem; }[]; declare const defaultDocumentEditorToolbarItems: typeof defaultDocumentEditorToolbarItems_2; /** * Returns a deep copy of an array containing the default {@link NutrientViewer.DocumentEditorToolbarItem|document editor toolbar items} * ordered by {@link NutrientViewer.DocumentEditorToolbarItem#type} in the following way: * * 1. `add` * 2. `remove` * 3. `duplicate` * 4. `rotate-left` * 5. `rotate-right` * 6. `move` * 7. `move-left` * 8. `move-right` * 9. `import-document` * 10. `extract-pages` * 11. `spacer` * 12. `undo` * 13. `redo` * 14. `select-all` * 15. `select-none` * 16. `zoom-out` * 17. `zoom-in` */ declare const defaultDocumentEditorToolbarItems_2: { type: BuiltInDocumentEditorToolbarItemType; }[]; declare const defaultElectronicSignatureColorPresets: ColorPreset[]; declare const defaultStampAnnotationTemplates: typeof defaultStampAnnotationTemplates_2; /** * Returns a deep copy of an array containing the default {@link NutrientViewer.stampAnnotationTemplates | stamp * and image annotation templates}, which are {@link NutrientViewer.Annotations.StampAnnotation | stamp annotation instances}. * However, {@link NutrientViewer.Annotations.ImageAnnotation | image annotation} templates can also be added to * this `Array` using {@link NutrientViewer.setStampAnnotationTemplates}. * Used by the stamp picker UI. * Initially it contains only the following {@link NutrientViewer.Annotations.StampAnnotation | stamp annotations}: * * 1. `Approved` * 2. `NotApproved` * 3. `Draft` * 4. `Final` * 5. `Completed` * 6. `Confidential` * 7. `ForPublicRelease` * 8. `NotForPublicRelease` * 9. `ForComment` * 10. `Void` * 11. `PreliminaryResults` * 12. `InformationOnly` * 13. `Rejected` * 14. `Accepted` * 15. `InitialHere` * 16. `SignHere` * 17. `Witness` * 18. `AsIs` * 19. `Departmental` * 20. `Experimental` * 21. `Expired` * 22. `Sold` * 23. `TopSecret` * 24. `Revised` * 25. `RejectedWithText` */ declare const defaultStampAnnotationTemplates_2: StampAnnotation[]; declare const defaultTextComparisonInnerToolbarItems: typeof defaultTextComparisonInnerToolbarItems_2; /** * Returns a deep copy of an array containing the default {@link TextComparisonInnerToolbarItem | text comparison instance toolbar items} * ordered by {@link TextComparisonInnerToolbarItem#type} in the following way: * * 1. `pager` * 2. `pan` * 3. `zoom-out` * 4. `zoom-in` * 5. `spacer` * * Please keep in mind that under some circumstances some items may be removed from the final list. */ declare const defaultTextComparisonInnerToolbarItems_2: { type: string; }[]; declare const defaultTextComparisonToolbarItems: typeof defaultTextComparisonToolbarItems_2; /** * Returns a deep copy of an array containing the default {@link NutrientViewer.TextComparisonToolbarItem|text comparison toolbar items} * ordered by {@link NutrientViewer.TextComparisonToolbarItem#type} in the following way: * * 1. `comparison-changes` * 2. `prev-change` * 3. `next-change` * 4. `scroll-lock` * * Please keep in mind that under some circumstances some items may be removed from the final list. */ declare const defaultTextComparisonToolbarItems_2: { type: string; }[]; declare const defaultToolbarItems: typeof defaultToolbarItems_2; /** * Returns a deep copy of an array containing the default {@link NutrientViewer.ToolbarItem|toolbar items} * ordered by {@link NutrientViewer.ToolbarItem#type} in the following way: * * 1. `sidebar-thumbnails` * 2. `sidebar-document-outline` * 3. `sidebar-annotations` * 4. `sidebar-bookmarks` * 5. `sidebar-signatures` * 6. `sidebar-attachments` * 7. `sidebar-layers` * 8. `pager` * 9. `pan` * 10. `zoom-out` * 11. `zoom-in` * 12. `zoom-mode` * 13. `spacer` * 14. `annotate` * 15. `ink` * 16. `highlighter` * 17. `text-highlighter` * 18. `ink-eraser` * 19. `signature` * 20. `image` * 21. `stamp` * 22. `note` * 23. `text` * 24. `line` * 25. `arrow` * 26. `rectangle` * 27. `cloudy-rectangle` * 28. `dashed-rectangle` * 29. `ellipse` * 30. `cloudy-ellipse` * 31. `dashed-ellipse` * 32. `polygon` * 33. `cloudy-polygon` * 34. `dashed-polygon` * 35. `polyline` * 36. `print` * 37. `document-editor` * 38. `document-crop` * 39. `search` * 40. `export-pdf` * 41. `debug` * 42. `content-editor` * 43. `link` * 44. `multi-annotations-selection` * 45. `callout` * * Please keep in mind that under some circumstances some items may be removed from the final list. * * Items hidden for touch devices: * * * `pan` * * Items hidden for touch devices when the media query `(max-width: 992px)` for medium devices matches: * * * `zoom-out` * * `zoom-in` * * `zoom-mode` * * Please keep in mind that the media query is only added for touch devices. * You can change this behavior by defining your own `mediaQueries` and replacing the original item. * To learn more about how to do so please refer to [our guide](https://www.nutrient.io/guides/web/customizing-the-interface/configure-the-toolbar/#toc_customizing-built-in-items). * * Items hidden for small screens `(max-width: 992px)` * * * `text` * * `callout` * * `ink` * * `highlighter` * * `text-highlighter` * * `ink-eraser` * * `line` * * `arrow` * * `rectangle` * * `cloudy-rectangle` * * `dashed-rectangle` * * `ellipse` * * `cloudy-ellipse` * * `dashed-ellipse` * * `polygon` * * `cloudy-polygon` * * `dashed-polygon` * * `polyline` * * `signature` * * `image` * * `stamp` * * `note` * * `undo` * * `redo` * * `link` * * Items shown on small screens `(max-width: 992px)` * * * `annotate` * * Items hidden when in {@link NutrientViewer.ViewState#readOnly| read-only mode}: * * * `text` * * `ink` * * `highlighter` * * `text-highlighter` * * `ink-eraser` * * `line` * * `arrow` * * `rectangle` * * `cloudy-rectangle` * * `dashed-rectangle` * * `ellipse` * * `cloudy-ellipse` * * `dashed-ellipse` * * `polygon` * * `cloudy-polygon` * * `dashed-polygon` * * `polyline` * * `signature` * * `image` * * `stamp` * * `note` * * `undo` * * `redo` * * `link` * * `multi-annotations-selection` * * Hidden when not in debug mode (See {@link https://www.nutrient.io/guides/web/troubleshoot/#bug-reports|this guide article}): * * * `debug` * * Hidden by default and only available when explicitly set via the API: * * * `layout-config` * * `marquee-zoom` * * `comment` * * `redact-text-highlighter` * * `redact-rectangle` * * `cloudy-rectangle` * * `dashed-rectangle` * * `cloudy-ellipse` * * `dashed-ellipse` * * `dashed-polygon` * * `undo` * * `redo` * * `document-comparison` * * `form-creator` * * `content-editor` * * `measure` * * `pager-expanded`: This is the expanded version of the pager which is visible by default on larger screens. In case you want to always show it, you should replace `pager` with `pager-expanded`. */ declare const defaultToolbarItems_2: readonly [{ readonly type: "sidebar-thumbnails"; }, { readonly type: "sidebar-document-outline"; }, { readonly type: "sidebar-annotations"; }, { readonly type: "sidebar-bookmarks"; }, { readonly type: "sidebar-signatures"; }, { readonly type: "sidebar-attachments"; }, { readonly type: "sidebar-layers"; }, { readonly type: "pager"; }, { readonly type: "multi-annotations-selection"; }, { readonly type: "pan"; }, { readonly type: "zoom-out"; }, { readonly type: "zoom-in"; }, { readonly type: "zoom-mode"; }, { readonly type: "linearized-download-indicator"; }, { readonly type: "spacer"; }, { readonly type: "annotate"; }, { readonly type: "ink"; }, { readonly type: "highlighter"; }, { readonly type: "text-highlighter"; }, { readonly type: "ink-eraser"; }, { readonly type: "signature"; }, { readonly type: "image"; }, { readonly type: "stamp"; }, { readonly type: "note"; }, { readonly type: "text"; }, { readonly type: "callout"; }, { readonly type: "line"; }, { readonly type: "link"; }, { readonly type: "arrow"; }, { readonly type: "rectangle"; }, { readonly type: "ellipse"; }, { readonly type: "polygon"; }, { readonly type: "cloudy-polygon"; }, { readonly type: "polyline"; }, { readonly type: "print"; }, { readonly type: "document-editor"; }, { readonly type: "document-crop"; }, { readonly type: "search"; }, { readonly type: "export-pdf"; }, { readonly type: "debug"; }]; declare const defaultToolbarTypes: ("text" | "search" | "link" | "ellipse" | "image" | "line" | "polygon" | "polyline" | "spacer" | "note" | "zoom-in" | "zoom-out" | "callout" | "signature" | "ink" | "debug" | "arrow" | "highlighter" | "rectangle" | "stamp" | "print" | "pager" | "pan" | "cloudy-polygon" | "text-highlighter" | "annotate" | "multi-annotations-selection" | "ink-eraser" | "document-crop" | "document-editor" | "export-pdf" | "linearized-download-indicator" | "sidebar-thumbnails" | "sidebar-document-outline" | "sidebar-layers" | "sidebar-annotations" | "sidebar-bookmarks" | "sidebar-signatures" | "sidebar-attachments" | "zoom-mode")[]; /** * Describes the configuration used to populate a document template. * * @inline */ declare type DelimiterConfig = { /** The delimiter settings used in data parsing. */ delimiter?: DelimiterSettings; /** Additional vendor-specific config keys are forwarded as-is. */ [key: string]: unknown; }; /** * Describes the delimiter settings config used in data parsing. * * @inline */ declare type DelimiterSettings = { /** The start delimiter for data parsing. Defaults to `{` when omitted. */ start?: string; /** The end delimiter for data parsing. Defaults to `}` when omitted. */ end?: string; /** * Optional separator used to treat dotted markers as literal keys instead of object navigation. * Example: with `objectDelimiter: "|"`, `{{opps.length()}}` resolves the literal `"opps.length()"` key. */ objectDelimiter?: string; /** Additional vendor-specific delimiter keys are forwarded as-is. */ [key: string]: unknown; }; /** * FormField deserializer. Converts a form field InstantJSON object to a {@link NutrientViewer.FormFields.FormField}. * * @param id - The ID of the form field. * @param payload - The serialized form field. * @param options - The options for the form field. * @returns The deserialized form field. */ declare function deserializeFormField(id: ID, payload: Serializers.FormFieldJSON, options?: ICollaboratorPermissionsOptions): FormField; export declare namespace DigitalSignatures { /** * *Server only* * * Contains information to be optionally passed along to the signing service when * {@link NutrientViewer.Instance#signDocument | `instance.signDocument()`} is called in server mode, so it can be used * for identification, security or any other purpose. * * To learn more about how to set up the signing service check * {@link https://www.nutrient.io/guides/web/signatures/digital-signatures/signature-lifecycle/sign-a-pdf-document-document-engine/ | this guide article}. * * This is the property that can be included in the object: * * @example * Passing a string for the signing service when signing (Server) * ```ts * instance.signDocument(null, { * signingToken: "My security token" * }) * .then(function () { * console.log("The document has been signed!"); * }); * ``` * * @summary Data for the digital signing service. * @server */ export interface ServerSigningServiceData { /** Token to be passed by the backend to the signing service. */ signingToken: string; } /** * *Standalone only* * * Contains information needed for signing with Nutrient backend in standalone mode. Supports the following backends: * * * Document Engine (requires Document Engine >= 1.6.0) * * {@link https://www.nutrient.io/api/ | DWS} * * The document loaded in your instance will not be transferred over the network, instead document hash and * signature properties will be prepared locally and passed to the backend to perform the signing via certificate, * finally digital signature is embedded into the document locally. * * Uses JSON Web Token (JWT) to authorize with the NutrientViewer backend. See Document Engine's * {@link https://www.nutrient.io/api/reference/document-engine/upstream/#tag/JWT-authorization | API Reference} * for more details about the JWT authorization. * * @example * Signing document in Web standalone via NutrientViewer backend * ```ts * instance.signDocument(null, { * jwt: "" * }) * .then(function () { * console.log("The document has been signed!"); * }); * ``` * * @standalone * @summary Data for the hash signing process. * @since Document Engine 1.6.0 */ export interface StandaloneSigningServiceData { /** Authentication token needed to authenticate the signing request with the backend. */ jwt: string; /** * Base server URL to use as the signing backend. * * The `/api/sign_hash` is used as the signing endpoint * and `/api/get_certificates` is used to retrieve the certificates. * */ serverUrl?: string; /** Optional signing token to be passed by the backend to the signing service. Valid only when signing via Document Engine. */ signingToken?: string; } /** * Contains information to be optionally passed along to the backend signing service when * {@link NutrientViewer.Instance#signDocument | `instance.signDocument()`} is called, so it can be used * for identification, security or any other purpose. * * @summary Data for the digital signing service. */ export type SigningServiceData = ServerSigningServiceData | StandaloneSigningServiceData; /** * Represents a digital certificate used for signing documents. * * @summary Information about the signing certificate. */ export type SigningCertificate = { type: 'pspdfkit/certificate'; isCACertificate: boolean; isSelfSigned: boolean; issuerCommonName: string; serialNumberHex: string; subjectCommonName: string; validFrom: string; validUntil: string; }; /** * Contains metadata information to be included in a Digital Signature. * * This object can be passed optionally to {@link Instance#signDocument | `Instance.signDocument()`} * as part of {@link SignaturePreparationData}. * * @example * Specifying the signer name, signature reason and location for a Digital Signature (Standalone) * ```ts * instance.signDocument( * { * signatureMetadata: { * signerName: "John Doe", * signatureReason: "Testing", * signatureLocation: "San Francisco" * } * }, getPKCS7Container) * .then(function () { * console.log("The document has been signed!"); * }); * ``` * * @summary Digital signing preparation data. */ export type SignatureMetadata = { signerName?: string; signatureReason?: string; signatureLocation?: string; }; /** * @inline * @summary Page, coordinates and dimensions of a digital signature. */ export interface SignaturePosition { /** Index of the page for the digital signature. */ pageIndex: number; /** Coordinates and dimensions of the digital signature. */ boundingBox: Rect; } /** * This object can be provided optionally as part of the {@link SignaturePreparationData | `NutrientViewer.SignaturePreparationData`} * passed as first argument when calling {@link NutrientViewer.Instance#signDocument | `instance.signDocument()`} and contains * the certificates, private key and signature type for the SDK to use for signing the document using the Web Crypto API. * * `certificates` must be an `Array` of `ArrayBuffer` (DER-encoded) or `string` (PEM-encoded) containing X.509 certificates. * * The SDK can sign the document using the {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto | Web SubtleCrypto API} * as long as the certificate chain and private key are provided here. * * `privatekey` must be a `string` that contains the private key to sign (PEM-encoded). If `privateKey` is not included, {@link TwoStepSignatureCallback | `NutrientViewer.TwoStepSignatureCallback`} needs to be passed * as second argument for the `instance.signDocument()` call to perform the signing. * * If `certificates` is not provided, only `NutrientViewer.SignatureType.CMS` can be created. * * If `signatureType` is not provided, `NutrientViewer.SignatureType.CAdES` will be used by default as long as `certificates` is provided, * and will default to `NutrientViewer.SignatureType.CMS` otherwise. * * If `timestamp` is provided, the `signatureType` must be `NutrientViewer.SignatureType.CAdES`. */ export interface SigningData { /** Certificates used to sign the document. */ certificates?: ArrayBuffer[] | string[]; signatureType: SignatureTypeType; /** Signature container type. Can be `NutrientViewer.SignatureContainerType.raw` or `NutrientViewer.SignatureContainerType.pkcs7`. */ signatureContainer?: SignatureContainerType_2; /** Private key used to sign the document. */ privateKey?: string; /** Timestamping authority information (Standalone only). */ timestamp?: TimestampType; /** Flag to enable LTV (Long Term Validation) for the signature (Standalone only). */ ltv?: boolean; /** PAdES level to use when creating the signature (Document Engine only). This parameter is ignored when the signatureType is `cms`. Defaults to `b-lt`. */ padesLevel?: PAdESLevelType; } export interface SignatureCreationData extends DigitalSignatures.SignaturePreparationData { signatureMetadata?: DigitalSignatures.SignatureMetadata; signingData?: SigningData; } /** * Contains information to be used for preparing a document to be signed digitally. * * This object can be passed optionally to {@link NutrientViewer.Instance#signDocument | `instance.signDocument()`} * with specific parameters for the preparation of the digital signature. * * `formFieldName` and `position` cannot be set at the same time, or an error will be thrown. * * This is the property that can be included in the object: * * @example * Setting the digital signature container reserved size when signing (Server) * ```ts * instance.signDocument({ * placeholderSize: 65536 // Specify a container with a 64 KB size * }) * .then(function () { * console.log("The document has been signed!"); * }); * ``` * * @summary Digital signing preparation data. */ export interface SignaturePreparationData { /** Size (bytes) to be reserved for the digital signature container. The default is 32 KB (32768 bytes). */ placeholderSize?: number; /** Whether the document should be flatten before digitally signing it. The default is `false`. Note that flattening a document may remove previous digital signatures. */ flatten?: boolean; /** Name of the existing signature form field to apply the signature to. */ formFieldName?: string; /** Page index and bounding box of the signature. */ position?: DigitalSignatures.SignaturePosition; /** Appearance options for the digital signature. */ appearance?: SignatureAppearance; } /** * This callback is called when a document has been prepared for digitally signing by calling * {@link Instance#signDocument | `instance.signDocument()`}. It receives the current document hash, file contents and data to be signed * as arguments, and must return a `Promise` object that resolves to any of these types: * - An `ArrayBuffer` that contains either the signed data or a PKCS7 container that includes it. * - A `SignatureCallbackResponsePkcs7` that is structured type for when the signature device or service creates signatures * in the PKCS#7 format. * - A `SignatureCallbackResponseRaw` that is structured type for when the signature device or service creates signatures * in the raw (for instance, PKCS#1.5) format. * If the returned `Promise` object rejects, the document will not be signed. * * The provided file contents or the data to be signed can be used as input for the Web Crypto API, or for a * signing service of your choice to be signed (hashed and encrypted). The file contents hash is * also provided so it can be used it to verify the validity of the contents. * * See * {@link https://www.nutrient.io/guides/web/signatures/digital-signatures/overview/ | this guide article} * for more information on how to digitally sign a document on Standalone. * * @returns A promise that resolves to any of these: * - An `ArrayBuffer` that contains the signed data in the PKCS#1.5 or PKCS#7 format. * - A `SignatureCallbackResponsePkcs7`, for when the signature device or service creates signatures in the PKCS#7 format. * - A `SignatureCallbackResponseRaw`, for when the signature device or service creates signatures in the raw (for instance, PKCS#1.5) format. * The `ArrayBuffer` return type is deprecated. It's recommended to return either a `SignatureCallbackResponsePkcs7` or `SignatureCallbackResponseRaw`, depending on the signature format. * * @example * Sign document (Standalone) * ```ts * instance.signDocument(null, function({ hash, fileContents }) { * return new Promise(function(resolve, reject) { * const PKCS7Container = getPKCS7Container(hash, fileContents); * if (PKCS7Container != null) { * return resolve(PKCS7Container) * } * reject(new Error("Could not retrieve the PKCS7 container.")) * }) * }).then(function() { * console.log("Document signed!"); * }) * ``` * */ export type TwoStepSignatureCallback = (result: { /** Hash of the current document */ hash: string; /** Content of the file to be signed. Provided only for CMS signatures. */ fileContents: ArrayBuffer | null; /** Data to be signed for CAdES signatures. */ dataToBeSigned: ArrayBuffer; }) => Promise; /** * Represents the result of a signing process that returns a raw, (for instance, PKCS#1) signature. */ export type SignatureCallbackResponseRaw = { /** * The certificate chain to include in the digital signature. * It can be a list of DER-encoded (represented as an `ArrayBuffer`) or PEM-encoded certificates. */ certificates: ArrayBuffer[] | string[]; /** * The raw (for example, PKCS#1) signature as an ArrayBuffer. */ signedData: ArrayBuffer; /** * Optional timestamp token, DER-encoded. The format should be as * specified by [RFC3161]{@link https://www.rfc-editor.org/info/rfc3161}. If no timestamp response is provided, the signing * process will fallback to the optional `signingData.timestamp` field of * `NutrientViewer.SignaturePreparationData`. */ timestampResponse?: ArrayBuffer; /** * Optional array of OCSP responses. Required if the signature needs to be LTV enabled. */ ocspResponses?: OcspResponse[]; }; /** * Represents the result of a signing process that returns a PKCS#7 (CMS) signature. */ export type SignatureCallbackResponsePkcs7 = { /** * The DER-encoded PKCS#7 signature as an `ArrayBuffer`. */ pkcs7: ArrayBuffer; /** * Optional array of OCSP responses. Required if the signature needs to be LTV enabled. */ ocspResponses?: OcspResponse[]; }; /** * On Standalone, by implementing this callback you have a fine grained control over * which certificates are going to be used for digital signatures validation. * * For more information, see {@link Configuration#trustedCAsCallback} * * @example * Fetch and use custom set of certificates (Standalone) * * ```ts * NutrientViewer.load({ * trustedCAsCallback: function() { * return new Promise((resolve, reject) => { * fetch("/your-certificate.cer") * .then(res => res.arrayBuffer()) * .then(cert => resolve([cert])) * .catch(reject) * }); * }, * // ... * }); * ``` * * @returns The CA certificates in DER (`ArrayBuffer`) or PEM (`string`) format. */ export type TrustedCAsCallback = () => Promise>; /** * Represents an OCSP (Online Certificate Status Protocol) response. */ export type OcspResponse = { /** * The serial number of the certificate whose revocation status was checked. */ serialNumber: string; /** * The OCSP response body as an `ArrayBuffer` (DER-encoded structure), as defined in [RFC6960]{@link https://www.rfc-editor.org/info/rfc6960}. */ body: ArrayBuffer; }; /** * Describes and persists the overall validation status of the document, based on the * digital signatures it contains. * * The information contained in the digital signatures included in a document * can be extracted using {@link NutrientViewer.Instance#getSignaturesInfo}, which resolves with * a `NutrientViewer.SignaturesInfo` object. This object represent the overall validation status * of the document. For getting information about each individual signature from the document, * an array of {@link SignatureInfo} is included under the `signatures` property. * * To learn more about digital signatures validation check * {@link https://www.nutrient.io/guides/web/signatures/digital-signatures/signature-lifecycle/validation/ | this guide article}. * * @example * Getting digital signatures data from a document * ```ts * instance.getSignaturesInfo() * .then(function (signaturesInfo) { * console.log(signaturesInfo) * }); * ``` * * @summary Digital signatures validation information. * @see {@link NutrientViewer.Instance#getSignaturesInfo} | {@link NutrientViewer.ViewState#showSignatureValidationStatus} * @see {@link Configuration#trustedCAsCallback} */ export type SignaturesInfo = { /** The different possible validation states of the document. */ status: DocumentValidationStatusType; checkedAt: Date; /** Array with the properties of each digital signature. */ signatures?: Array; /** The document has been modified since the last signature was added to it. */ documentModifiedSinceSignature?: boolean; }; /** * @summary Appearance options for a visible digital signature. */ export type SignatureAppearance = { /** Signature appearance mode: with graphics, description or both; defaults to both. */ mode?: ISignatureAppearanceMode; /** Whether to include the signer in the signature appearance; defaults to true. */ showSigner?: boolean; /** Whether to include the signature date in the signature appearance; defaults to true. */ showSignDate?: boolean; /** Whether to include the reason for the signature in the signature appearance; defaults to true. */ showReason?: boolean; /** Whether to include the location for the signature in the signature appearance; defaults to true. */ showLocation?: boolean; /** Whether to show the watermark image; defaults to true. */ showWatermark?: boolean; /** Whether to show the timezone when `showSignDate` is true; defaults to false. */ showDateTimezone?: boolean; /** Watermark image for the digital signature; can be a PDF, a JPEG or a PNG image. */ watermarkImage?: Blob | File; /** Signer image (for instance, a handwritten signature). Can be a PDF, a JPEG or a PNG image. */ graphicImage?: Blob | File; }; } declare function DigitalSignaturesMixin>(Base: T): { new (...args: any[]): { /** * Gets the digital signatures validation information for all the signatures present * in the current document. See {@link DigitalSignatures.SignaturesInfo}. * * @example * Retrieve signatures information * ```ts * instance.getSignaturesInfo() * .then(signaturesInfo => { * console.log(signaturesInfo.status) * if(signaturesInfo.signatures) { * const invalidSignatures = signaturesInfo.signatures * .filter(signature => signature.signatureValidationStatus !== NutrientViewer.SignatureValidationStatus.valid); * console.log(invalidSignatures); * } * }); * ``` * * Additional information can be found in * {@link https://www.nutrient.io/guides/web/signatures/digital-signatures/signature-lifecycle/validation/ | this guide article}. * * @returns Promise that resolves with a {@link DigitalSignatures.SignaturesInfo}. */ getSignaturesInfo(): Promise; /** * Digitally signs the document. On Standalone it can make sign the document with the certificates and private key * provided by the user in {@link DigitalSignatures.SignaturePreparationData}, or use the signing service optionally provided * in the callback argument. * * On Server, you can optionally specify additional data to be passed to the signing service. * * Check the related {@link https://www.nutrient.io/guides/web/signatures/digital-signatures/overview/ | guide article}. * * @example * Sign document with CMS signature (Standalone) * ```ts * instance.signDocument(null, function({ hash, fileContents }) { * return new Promise(function(resolve, reject) { * const PKCS7Container = getPKCS7Container(hash, fileContents); * if (PKCS7Container != null) { * return resolve(PKCS7Container) * } * reject(new Error("Could not retrieve the PKCS7 container.")) * }) * }).then(function() { * console.log("Document signed!"); * }) * ``` * * @example * Sign document (Server) * ```ts * instance.signDocument(null, { signingToken: "My security token" }) * .then(function() { * console.log("Document signed!"); * }) * ``` * * @param signaturePreparationData - Properties to prepare the signature with. * @param twoStepSignatureCallbackOrSigningServiceData - Either * a callback to be executed when the document is ready for signing (Standalone only) or optional data to be passed to the * signing service. * @returns Promise that resolves when the document is signed. */ signDocument(signaturePreparationData: DigitalSignatures.SignatureCreationData | null, twoStepSignatureCallbackOrSigningServiceData?: DigitalSignatures.TwoStepSignatureCallback | DigitalSignatures.SigningServiceData): Promise; /** * Adds LTV (Long Term Validation) information to an existing signature. * See {@link DigitalSignatures.SignaturesInfo}. * * @example * Add LTV information to an existing signature * ```ts * instance.setSignaturesLTV(certificates) * .then(signaturesInfo => { * console.log(signaturesInfo.status) * if(signaturesInfo.signatures) { * const invalidSignatures = signaturesInfo.signatures * .filter(signature => !signature.ltv); * console.log(invalidSignatures); * } * }); * ``` * Additional information can be found in * {@link https://www.nutrient.io/guides/web/signatures/digital-signatures/signature-lifecycle/sign-a-pdf-document/ | this guide article}. * * @public * @standalone * @param certificates - Certificates used to sign the document. * @returns Promise that resolves with a {@link DigitalSignatures.SignaturesInfo}. */ setSignaturesLTV(certificates?: ArrayBuffer[] | string[]): Promise; }; } & T; declare type Dispatch = (value: A) => void; export declare namespace DocumentComparison { /** * Represents a pair of documents to be compared. */ export type ComparisonDocuments = { /** The original document. */ originalDocument: DocumentDescriptor; /** The changed document. */ changedDocument: DocumentDescriptor; }; export type DocumentDescriptorWithBuffer = DocumentDescriptor & { arrayBuffer: ArrayBuffer; }; export type ComparisonDocumentsWithBuffers = { originalDocument: DocumentDescriptorWithBufferJSON; changedDocument: DocumentDescriptorWithBufferJSON; }; /** * Describes a range within a document. */ export type Range = { /** The starting position of the range. */ position: number; /** The length of the range. */ length: number; }; export type Config = { originalDocument: DocumentDescriptorWithBuffer; changedDocument: DocumentDescriptorWithBuffer; comparisonOperation: ComparisonOperationJSON; }; /** * Describes a block of text within a document. */ export type TextBlock = { /** The range of the text block. */ range: Range; /** The rectangular coordinates of the text block. */ rect: [number, number, number, number]; }; /** * Describes an operation within a text comparison. */ export type Operation = { /** The type of operation. */ type: 'insert' | 'delete' | 'equal'; /** The text involved in the operation. */ text: string; /** The text blocks from the original document. */ originalTextBlocks: TextBlock[]; /** The text blocks from the changed document. */ changedTextBlocks: TextBlock[]; }; /** * Describes a hunk of changes within a document comparison. */ export type Hunk = { /** The range in the original document. */ originalRange: Range; /** The range in the changed document. */ changedRange: Range; /** The operations within the hunk. */ operations: Operation[]; }; /** * Describes the result of a text comparison. */ export type TextComparisonResult = { /** The type of comparison result. Only "text" is supported for now. */ type: 'text'; /** The hunks of changes within the comparison result. */ hunks: Hunk[]; }; /** * Describes the result of a page comparison. */ export type PageComparisonResult = { /** The index of the original page. */ originalPageIndex?: number; /** The index of the changed page. */ changedPageIndex?: number; /** The comparison results for the page. */ comparisonResults: TextComparisonResult[]; }; /** * Object containing the result of a document comparison operation. */ export type DocumentComparisonResult = { /** The comparison results for each page. */ documentComparisonResults: PageComparisonResult[]; } | null; } /** * Defines specific configuration options related to the document comparison feature. Passed when calling {@link Instance#setDocumentComparisonMode}. * * @public * @summary Object containing configuration options for document comparison. * @example * instance.setDocumentComparisonMode({ * documentA: { * source: NutrientViewer.DocumentComparisonSourceType.USE_OPEN_DOCUMENT * }, * documentB: { * source: NutrientViewer.DocumentComparisonSourceType.USE_FILE_DIALOG * }, * autoCompare: false * }); */ export declare type DocumentComparisonConfiguration = { /** * Settings for the base document used for document comparison. */ documentA: DocumentComparisonSource; /** * Settings for the second document used for document comparison. */ documentB: DocumentComparisonSource; /** * Stroke colors to be used for the base and second documents strokes when overlaid for document comparison. * * @default { documentA: new NutrientViewer.Color({ r: 245, g: 40, b: 27 }), documentB: new NutrientViewer.Color({ r: 49, g: 193, b: 255 }) } */ strokeColors?: DocumentComparisonStrokeColors; /** * {@link NutrientViewer.BlendMode | Blend mode} to be used for overlaying the two source documents when performing document comparison. * * @default "darken" */ blendMode?: IBlendMode; /** * Set to `true` to perform automatic comparison without manual alignment of both documents. Set to `false` to manually align them. */ autoCompare: boolean; }; declare function DocumentComparisonMixin>(Base: T): { new (...args: any[]): { /** * ***Standalone only*** * * Enables or disables the document comparison UI. * * When a {@link DocumentComparisonConfiguration} object is passed, the document comparison UI is * mounted and initialized with the provided settings. * * When `null` is passed, the document comparison UI is hidden if it was being shown. * * @example * Initialize and show the document comparison UI * ```ts * instance.setDocumentComparisonMode({ * documentA: { * source: fetch("old-document.pdf").then(res => res.arrayBuffer()) * }, * documentB: { * source: fetch("old-document.pdf").then(res => res.arrayBuffer()) * }, * autoCompare: true * }); * ``` * * @public * @param documentComparisonConfiguration - Initial document comparison configuration. * @returns Promise that resolves when the document comparison UI is hidden. */ setDocumentComparisonMode(documentComparisonConfiguration: DocumentComparisonConfiguration | null): Promise; }; } & T; /** * Specifies the data and settings for documents used for document comparison. * * @public * @summary Object containing data and settings for documents used for document comparison. * @example * instance.setDocumenComparisonMode({ * documentA: { * source: NutrientViewer.DocumentComparisonSourceType.USE_OPEN_DOCUMENT, * pageIndex: 0, * strokeColor: NutrientViewer.Color.RED * }, * documentB: { * source: NutrientViewer.DocumentComparisonSource.USE_FILE_DIALOG, * pageIndex: 0, * strokeColor: NutrientViewer.Color.BLUE * }, * autoCompare: false * }); */ export declare type DocumentComparisonSource = { /** * Data for one of the source documents used for document comparison. */ source: IDocumentComparisonSourceType | string | ArrayBuffer | Promise; /** * ***optional*** * * Page index of the source document to be used for document comparison. * * Defaults to page `0`. * * @default 0 */ pageIndex?: number; }; /** * Represents one of the available document sources to be used * in document comparison. * * @enum */ declare const DocumentComparisonSourceType: { /** Use the currently open document as source. */ readonly USE_OPEN_DOCUMENT: "USE_OPEN_DOCUMENT"; /** Show the file dialog for the user to choose the source document from the local file system. */ readonly USE_FILE_DIALOG: "USE_FILE_DIALOG"; }; /** * Specifies the stroke colors used for overlaid strokes of the base and second documents documents used in document comparison. * * @summary Object containing the stroke colors used for overlaid strokes of the base and second documents documents used in document comparison. * @example * instance.setDocumentComparisonMode({ * documentA: { * source: NutrientViewer.DocumentComparisonSourceType.USE_OPEN_DOCUMENT, * pageIndex: 0 * }, * documentB: { * source: NutrientViewer.DocumentComparisonSourceType.USE_FILE_DIALOG, * pageIndex: 0 * }, * strokeColors: { * documentA: NutrientViewer.Color.RED, * documentB: NutrientViewer.Color.BLUE * }, * autoCompare: false * }); */ export declare type DocumentComparisonStrokeColors = { /** * Stroke color for the base document used for document comparison. * * @default new NutrientViewer.Color({ r: 245, g: 40, b: 27 }) */ documentA?: Color; /** * Stroke color for the second document used for document comparison. * * @default new NutrientViewer.Color({ r: 49, g: 193, b: 255 }) */ documentB?: Color; }; /** * @class * DocumentDescriptor is a class that provides methods to describe a document for comparison. * It encapsulates the file path, optional password, and page indexes for the document. * @example * Create a new DocumentDescriptor. * ```ts * const doc = new DocumentDescriptor({ filePath: "path/to/document.pdf", pageIndexes: [0, 1] }); * ``` * * @public * @summary The descriptor for a document to be compared. */ declare class DocumentDescriptor extends DocumentDescriptor_base { constructor(documentDescriptorOptions: IDocumentDescriptor); } declare const DocumentDescriptor_base: Record_2.Factory; declare type DocumentDescriptorJSON = { filePath?: string | ArrayBuffer; password?: string; pageIndexes: Array; jwt?: string; }; declare type DocumentDescriptorWithBufferJSON = DocumentDescriptorJSON & { arrayBuffer: ArrayBuffer; }; /** @inline */ declare interface DocumentEditorBuiltinFooterItem extends BaseDocumentEditorFooterItem { type: BuiltInDocumentEditorFooterItemType; onPress?: (e: Event) => void; } /** @inline */ declare interface DocumentEditorBuiltinToolbarItem extends BaseDocumentEditorToolbarItem { type: BuiltInDocumentEditorToolbarItemType; onPress?: (e: Event) => void; } /** @inline */ declare interface DocumentEditorCustomFooterItem extends BaseDocumentEditorFooterItem { type: 'custom'; /** * ***required*** * * `custom` tool items have to define a DOM node which NutrientViewer will render. * * In this case the tool item is rendered inside of a container div. The `className` which you pass is set to this container div and not to the node that you passed. * * The `onPress` event is registered and fires any time the item is clicked. */ node: Node; /** * Icon for the item. * * The icon should either be an URL, a base64 encoded image or the HTML for an inline SVG. */ icon?: string; /** * Callback to invoke when the item is clicked or tapped (on touch devices). It gets the `event` as * first argument, a document editor UI handler object as the second, and the `id` of the tool item as the third. * * @param e - The event that is fired on press. `onPress` is also fired when pressing enter while the item has focus. * @param documentEditorUIHandler - An instance object to set and retrieve different state properties of the document editor UI. * @param id - The tool item id. */ onPress?: (e: Event, documentEditorUIHandler: DocumentEditorUIHandler, id?: string) => void; } /** @inline */ declare interface DocumentEditorCustomToolbarItem extends BaseDocumentEditorToolbarItem { type: 'custom'; /** * Callback to invoke when the item is clicked or tapped (on touch devices). It gets the `event` as * first argument, a document editor UI object as the second, and the `id` of the tool item as the third. * * @param e - The event that is fired on press. `onPress` is also fired when pressing enter while the item has focus. * @param documentEditorUIHandler - An instance object to set and retrieve different state properties of the document editor UI. */ onPress?: (e: Event, documentEditorUIHandler: DocumentEditorUIHandler, id?: string) => void; } /** * Describes the properties of a Document Editor Footer Item. * * Check out [our guides](https://www.nutrient.io/guides/web/customizing-the-interface/customizing-the-document-editor-toolbar-and-footer/) * for more examples. * * @see {@link NutrientViewer.Instance#setDocumentEditorFooterItems} * @see {@link Configuration#documentEditorFooterItems} * * **Note:** `node` and `icon` are only applicable when `type` is `'custom'`. * Built-in items receive only the `Event` in `onPress`; custom items also receive a `DocumentEditorUIHandler` and `id`. * * @replaceWith export interface DocumentEditorFooterItem extends DocumentEditorBuiltinFooterItem, DocumentEditorCustomFooterItem { type: BuiltInDocumentEditorFooterItemType | 'custom' } */ export declare type DocumentEditorFooterItem = DocumentEditorBuiltinFooterItem | DocumentEditorCustomFooterItem; declare function DocumentEditorMixin>(Base: T): { new (...args: any[]): { /** * Returns a deep copy of the latest document editor footer items. This value changes whenever the user * interacts with NutrientViewer or whenever {@link Instance#setDocumentEditorFooterItems} is called. * * Mutating this array will have no effect. * * @returns A deep copy of the latest document editor footer items. */ readonly documentEditorFooterItems: any[]; /** * Returns a deep copy of the latest document editor toolbar items. This value changes whenever the user * interacts with NutrientViewer or whenever {@link Instance#setDocumentEditorToolbarItems} is called. * * Mutating this array will have no effect. * */ readonly documentEditorToolbarItems: any[]; /** * This method is used to update the document editor footer of the PDF editor. * It makes it possible to add new {@link DocumentEditorFooterItem | items} and edit or remove existing ones. * * When you pass in an `array` of {@link DocumentEditorFooterItem}, the current items will be immediately * updated. Calling this method is also idempotent. * * If you pass in a function, it will be immediately invoked and will receive the current * `array` of {@link DocumentEditorFooterItem} as argument. You can use this to modify the list based on its * current value. This type of update is guaranteed to be atomic - the value of `currentDocumentEditorFooterItems` * can't change in between. * * When one of the supplied {@link DocumentEditorFooterItem} is invalid, this method will throw an * {@link Error} that contains a detailed error message. * * Since `items` is a regular JavaScript `Array` of object literals it can be manipulated using * standard array methods like `forEach`, `map`, `reduce`, `splice` and so on. * Additionally you can use any 3rd party library for array manipulation like [lodash](https://lodash.com) * or [just](http://anguscroll.com/just/). * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setDocumentEditorFooterItems(items => items.reverse()); * ``` * * @example * The new changes will be applied immediately * ```ts * instance.setDocumentEditorFooterItems(newItems); * instance.documentEditorFooterItems === newItems; // => true * ``` * * @example * Changing a property of a custom button * ```ts * const myButton = { * type: "custom", * id: "my-button", * onPress() { * alert("test"); * }, * }; * ``` * * @throws {Error} will throw an error when the supplied items array is not valid. This will also throw an error if you don not have document editor license. * @param documentEditorFooterItemsOrFunction - Either a * new `array` of DocumentEditorFooterItem which would overwrite the existing one, or a callback that will get * invoked with the current footer items and is expected to return the new `array` of items. */ setDocumentEditorFooterItems(documentEditorFooterItemsOrFunction: DocumentEditorFooterItem[] | SetDocumentEditorFooterFunction): void; /** * This method is used to update the document editor toolbar of the PDF editor. * It makes it possible to add new {@link DocumentEditorToolbarItem | items} and edit or remove existing ones. * * When you pass in an `array` of {@link DocumentEditorToolbarItem}, the current items will be immediately * updated. Calling this method is also idempotent. * * If you pass in a function, it will be immediately invoked and will receive the current * `array` of {@link DocumentEditorToolbarItem} as argument. You can use this to modify the list based on its * current value. This type of update is guaranteed to be atomic - the value of `currentDocumentEditorToolbarItems` * can't change in between. * See: {@link SetDocumentEditorToolbarFunction | DocumentEditorToolbarItemsSetter} * * When one of the supplied {@link DocumentEditorToolbarItem} is invalid, this method will throw an * {@link Error} that contains a detailed error message. * * Since `items` is a regular JavaScript `Array` of object literals it can be manipulated using * standard array methods like `forEach`, `map`, `reduce`, `splice` and so on. * Additionally you can use any 3rd party library for array manipulation like [lodash](https://lodash.com) * or [just](http://anguscroll.com/just/). * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setDocumentEditorToolbarItems(items => items.reverse()); * ``` * * @example * The new changes will be applied immediately * ```ts * instance.setDocumentEditorToolbarItems(newItems); * instance.documentEditorToolbarItems === newItems; // => true * ``` * * @example * Changing a property of a custom button * ```ts * const myButton = { * type: "custom", * id: "my-button", * onPress() { * alert("test"); * }, * }; * ``` * * @throws {Error} will throw an error when the supplied items array is not valid. This will also throw an error if you don not have document editor license. * @param documentEditorToolbarItemsOrFunction - Either a * new `array` of DocumentEditorToolbarItem which would overwrite the existing one, or a callback that will get * invoked with the current toolbar items and is expected to return the new `array` of items. */ setDocumentEditorToolbarItems(documentEditorToolbarItemsOrFunction: DocumentEditorToolbarItem[] | SetDocumentEditorToolbarFunction): void; }; } & T; /** * Describes the properties of a Document Editor Toolbar Item. * * Check out [our guides](https://www.nutrient.io/guides/web/customizing-the-interface/customizing-the-document-editor-toolbar-and-footer/) * for more examples. * * @see {@link NutrientViewer.Instance#setDocumentEditorToolbarItems} * @see {@link Configuration#documentEditorToolbarItems} * * @replaceWith export interface DocumentEditorToolbarItem extends DocumentEditorBuiltinToolbarItem, DocumentEditorCustomToolbarItem { type: BuiltInDocumentEditorToolbarItemType | 'custom' } */ export declare type DocumentEditorToolbarItem = DocumentEditorBuiltinToolbarItem | DocumentEditorCustomToolbarItem; /** * @public * @summary An object that allows you to configure the Document Editor UI. * @example * const myDocumentEditorUIConfig = { * thumbnailDefaultSize: 500, * thumbnailMinSize: 100, * thumbnailMaxSize: 600, * } * * NutrientViewer.load({ * //... * documentEditorConfig: myDocumentEditorUIConfig, * }) */ declare type documentEditorUIConfig = { /** The minimum size of the thumbnail. */ thumbnailMinSize: number; /** The maximum size of the thumbnail. */ thumbnailMaxSize: number; /** The default size of the thumbnail. */ thumbnailDefaultSize: number; }; /** * An object provided the Nutrient Web SDK to custom items in the document editor toolbar and footer. This object contains methods that can be * invoked to retrieve and modify the current stack of document operations to be applied to the open document. */ export declare type DocumentEditorUIHandler = { setOperations: SetOperationsCallback; /** * Retrieve the page indexes of the currently selected pages. This function can be used to set the scope of a new document operation, for example. * * @returns The page indexes of the currently selected pages. */ getSelectedPageIndexes: () => number[]; }; /** * The different signature validation states the document can be in. * * @enum */ export declare const DocumentIntegrityStatus: { /** * The part of the document covered by the signature has not been modified. */ readonly ok: "ok"; /** * The part of the document covered by the signature has been modified. */ readonly tampered_document: "tampered_document"; /** * The signature /Contents couldn't be parsed. */ readonly failed_to_retrieve_signature_contents: "failed_to_retrieve_signature_contents"; /** * The signature /ByteRange couldn't be parsed. */ readonly failed_to_retrieve_byterange: "failed_to_retrieve_byterange"; /** * The digest of the document couldn't be calculated. */ readonly failed_to_compute_digest: "failed_to_compute_digest"; /** * The signing certificate from the signature contents couldn't be extracted. */ readonly failed_retrieve_signing_certificate: "failed_retrieve_signing_certificate"; /** * The public key from the signature contents couldn't be extracted. */ readonly failed_retrieve_public_key: "failed_retrieve_public_key"; /** * The encryption padding from the signature contents couldn't be extracted. */ readonly failed_encryption_padding: "failed_encryption_padding"; /** * The digital signature contains a timestamp that is not valid or the timestamped data was tampered with. */ readonly tampered_or_invalid_timestamp: "tampered_or_invalid_timestamp"; /** * An unspecific error. */ readonly general_failure: "general_failure"; }; /** @inline */ declare type DocumentIntegrityStatusType = ValueOf; declare type DocumentMarkupMode = /** Revisions are not shown in the resulting PDF. */ 'noMarkup' /** Revisions are shown as they would appear in the original DOCX document. */ | 'original' /** Revisions are shown with simple indicators (e.g., strikethrough for deletions, underline for additions). */ | 'simpleMarkup' /** All revision details are shown, including comments and tracked changes. */ | 'allMarkup'; /** @inline */ declare type DocumentMetadata = { title?: string; author?: string; }; /** * The DocumentOperation namespace contains all the operations that can be applied to a document. * * @example * Apply a rotation operation to the document after load. * * ```ts * instance.applyOperations([{ * type: 'rotatePages', * pageIndexes: [0], * rotateBy: 90 * }]) * ``` * * @example * Export the document with the operations applied. * * ```ts * instance.exportPDFWithOperations([{ * type: 'rotatePages', * pageIndexes: [0], * rotateBy: 90 * }]) * ``` * * @see {@link Instance#applyOperations} * @see {@link Instance#exportPDFWithOperations} */ export declare namespace DocumentOperations { /** * Adds a blank page after the specified page index using the provided configuration. */ export interface AddPageAfterOperation extends AddPageConfiguration { type: 'addPage'; afterPageIndex: number; } /** * Adds a blank page before the specified page index using the provided configuration. */ export interface AddPageBeforeOperation extends AddPageConfiguration { type: 'addPage'; beforePageIndex: number; } /** * Crops the pages of PDF document. If the `pageIndexes` property is undefined, * the cropping operation is applied to all pages. * * @example * ```ts * instance.applyOperations([{ * type: "cropPages", * pageIndexes: [1, 2], * cropBox: new NutrientViewer.Geometry.Rect({ * top: 100, * left: 100, * width: 100, * height: 100 * }) * }]); * ``` */ export interface CropPagesOperation { type: 'cropPages'; pageIndexes?: Array; cropBox: Rect; } /** * Adds margins to the pages of the document. If the `pageIndexes` property is undefined, * the new margins are applied to all pages. Negative numbers will shrink the page. * * Content and annotations will be repositioned back to the original location on the page, * and other boxes (crop, bleed, trim, art) will be adjusted to encompass the same area. * * @example * ```ts * instance.applyOperations([{ * type: "addPageMargins", * pageIndexes: [1, 2], * margins: new NutrientViewer.Geometry.Inset({ * top: 100, * left: 100, * right: 100, * bottom: 100 * }) * }]); * ``` */ export interface AddPageMarginsOperation { type: 'addPageMargins'; pageIndexes?: Array; margins: Inset; } /** * Removes the pages specified in the `pageIndexes` array. */ export interface RemovePagesOperation { type: 'removePages'; pageIndexes: Array; } /** * Duplicates the pages specified in the `pageIndexes` array. Each new page will * be inserted after the original page. */ export interface DuplicatePagesOperation { type: 'duplicatePages'; pageIndexes: Array; } /** * Moves the pages specified in the `pageIndexes` array after the page specified. */ export interface MovePagesAfterOperation { type: 'movePages'; pageIndexes: Array; afterPageIndex: number; } /** * Moves the pages specified in the `pageIndexes` array before the page specified. */ export interface MovePagesBeforeOperation { type: 'movePages'; pageIndexes: Array; beforePageIndex: number; } /** * Rotates the pages specified in the `pageIndexes` array by the amount of degrees set * in `rotateBy`. */ export interface RotatePagesOperation { type: 'rotatePages'; pageIndexes: Array; rotateBy: Rotation; } /** * Removes all pages from the document except for the pages specified in the * `pageIndexes` array. * * @example * ```ts * instance.applyOperations([{ * type: "keepPages", * pageIndexes: [1, 2] * }]); * ``` */ export interface KeepPagesOperation { type: 'keepPages'; pageIndexes: Array; } /** * Imports the provided document after the specified page index. `treatImportedDocumentAsOnePage` * determines whether it will be treated as a single page for other document operations * (e.g. a rotation) provided during the same call. After these operations * are applied, the imported pages will behave like regular pages in the document. * * Flattening and importing a document where `treatImportedDocumentAsOnePage` in the same operations * batch is not supported and will raise an error. * * Importing the same document more than once in the same operations block is not allowed with the UI * in order to prevent possible user mistakes, but can be done programmatically. */ export interface ImportDocumentAfterOperation { type: 'importDocument'; afterPageIndex: number; treatImportedDocumentAsOnePage?: boolean; document: OperationAttachment; importedPageIndexes?: ImportPageIndex; } /** * Imports the provided document before the specified page index. `treatImportedDocumentAsOnePage` * determines whether it will be treated as a single page for other document operations * (e.g. a rotation) provided during the same call. After these operations * are applied, the imported pages will behave like regular pages in the document. * * Flattening and importing a document where `treatImportedDocumentAsOnePage` in the same operations * batch is not supported and will raise an error. * * Importing the same document more than once in the same operations block is not allowed with the UI * in order to prevent possible user mistakes, but can be done programmatically. */ export interface ImportDocumentBeforeOperation { type: 'importDocument'; beforePageIndex: number; treatImportedDocumentAsOnePage?: boolean; document: OperationAttachment; importedPageIndexes?: ImportPageIndex; } /** * Sets the page label for the pages specified in the `pageIndexes` array. */ export interface SetPageLabelOperation { type: 'setPageLabel'; pageIndexes?: Array; pageLabel?: string; } /** * If the OCR component is present in the license, performs OCR on the pages given with the language requested. See {@link https://www.nutrient.io/guides/document-engine/ocr/language-support/} for supported languages. * * @server * @example * instance.applyOperations([{ * type: "performOcr", * pageIndexes: "all", * language: "en" * }]); */ export interface PerformOcrOperation { type: 'performOcr'; pageIndexes?: Array | 'all'; language: string; } /** * If the Redaction component is present in the license, applies any redaction annotations, redacting the page content and removing the annotations. */ export interface ApplyRedactionsOperation { type: 'applyRedactions'; } /** * Indicates that a content editor session was saved, modifying the document's text content. */ export interface ContentEditorSaveOperation { type: 'contentEditorSave'; } /** * Updates metadata on the destination document. */ export interface UpdateMetadataOperation { type: 'updateMetadata'; metadata: DocumentMetadata; } /** * Applies the given Instant JSON object specified in the `instantJson` property. * To learn about Instant JSON please refer to * {@link https://www.nutrient.io/guides/web/importing-exporting/instant-json/ | this guide article}. */ export interface ApplyInstantJsonOperation { type: 'applyInstantJson'; instantJson: InstantJSON; dataFilePath?: OperationAttachment; } /** * Applies the given XFDF string specified in the `xfdf` property. * To learn about XFDF please refer to * {@link https://www.nutrient.io/guides/web/importing-exporting/xfdf-support/ | this guide article}. * * @see {@link Configuration#XFDF} */ export interface ApplyXfdfOperation { type: 'applyXfdf'; xfdf: string; ignorePageRotation?: boolean; dataFilePath?: OperationAttachment; richTextEnabled?: boolean; } /** * Flattens the annotations of the specified pages, or of all pages if none is specified. * * Flattening and importing a document where `treatImportedDocumentAsOnePage` in the same operations * batch is not supported and will raise an error. */ export interface FlattenAnnotationsOperation { type: 'flattenAnnotations'; pageIndexes?: Array; annotationIds?: string[]; noteAnnotationBackgroundColor?: Color; noteAnnotationOpacity?: number; /** * When set, the flattened annotation content is placed into the OCG layer * identified by this ID instead of directly into the page content. The layer * must already exist in the document (see {@link Instance#createLayer}). * * @standalone */ targetLayerId?: number; } export type DocumentOperationsUnion = AddPageAfterOperation | AddPageBeforeOperation | CropPagesOperation | AddPageMarginsOperation | RemovePagesOperation | DuplicatePagesOperation | MovePagesAfterOperation | MovePagesBeforeOperation | RotatePagesOperation | KeepPagesOperation | ImportDocumentAfterOperation | ImportDocumentBeforeOperation | SetPageLabelOperation | PerformOcrOperation | ApplyRedactionsOperation | UpdateMetadataOperation | ApplyInstantJsonOperation | ApplyXfdfOperation | FlattenAnnotationsOperation; /** * Union of all operation types that can appear in a {@link NutrientViewer.EventName.DOCUMENT_CHANGE | document.change} event. * * This includes all input operations from {@link DocumentOperationsUnion} plus * event-only operations that describe changes not triggered via * {@link NutrientViewer.Instance.applyOperations}. */ export type DocumentChangeEventOperation = DocumentOperationsUnion | ContentEditorSaveOperation; } declare function DocumentOperationsMixin>(Base: T): { new (...args: any[]): { /** * Applies operations to the current document. If multiple operations are provided, * each operation is performed on the resulting document from the previous operation. This API works only if you have the document editor component in your license. * * @example * Apply 90 degrees rotation to page 0 * ```ts * instance * .applyOperations([ * { * type: "rotatePages", * pageIndexes: [0], * rotateBy: 90 * } * ]); * ``` * * @param operations - Operations to be performed on the document. * @returns Promise that resolves with an array of results. */ applyOperations(operations: Array): Promise; /** * Exports the PDF contents after applying operations on the current document, which is not modified. * If multiple operations are provided, each operation is performed on the resulting document from the previous operation. * Returns an `ArrayBuffer` that can be used to download the PDF. * * @example * Export the modified PDF content * ```ts * const operations = [ * { * type: "rotatePages", * pageIndexes: [0], * rotateBy: 90 * } * ]; * instance.exportPDFWithOperations(operations).then(function (buffer) { * buffer; // => ArrayBuffer * }); * ``` * * @example * Download the modified PDF by using an `<a>` tag * ```ts * const operations = [ * { * type: "rotatePages", * pageIndexes: [0], * rotateBy: 90 * } * ]; * instance.exportPDFWithOperations(operations).then(function(buffer) { * const supportsDownloadAttribute = HTMLAnchorElement.prototype.hasOwnProperty( * "download" * ); * const blob = new Blob([buffer], { type: "application/pdf" }); * if (navigator.msSaveOrOpenBlob) { * navigator.msSaveOrOpenBlob(blob, "download.pdf"); * } else if (!supportsDownloadAttribute) { * const reader = new FileReader(); * reader.onloadend = function() { * const dataUrl = reader.result; * downloadPdf(dataUrl); * }; * reader.readAsDataURL(blob); * } else { * const objectUrl = window.URL.createObjectURL(blob); * downloadPdf(objectUrl); * window.URL.revokeObjectURL(objectUrl); * } * }); * function downloadPdf(blob) { * const a = document.createElement("a"); * a.href = blob; * a.style.display = "none"; * a.download = "download.pdf"; * a.setAttribute("download", "download.pdf"); * document.body.appendChild(a); * a.click(); * document.body.removeChild(a); * } * ``` * * @param operations - Operations to be performed on the document. * @returns Promise that resolves with the binary contents of the modified PDF. */ exportPDFWithOperations(operations: Array): Promise; }; } & T; /** * Flags representing permissions that can be granted to users for a document. * * These permissions control what actions are allowed, such as editing, printing, or extracting content. * Combine these flags to specify the allowed operations when exporting or encrypting a document. * * @enum */ declare const DocumentPermissionsEnum: { /** * Allows adding or modifying text annotations and interactive form fields. * If `fillForms` is also set, the user can fill existing forms (including digital signatures). */ readonly annotationsAndForms: "annotationsAndForms"; /** * Allows assembling the document: inserting, rotating, or deleting pages, and creating bookmarks or thumbnails. */ readonly assemble: "assemble"; /** * Allows copying or extracting text and graphics from the document. */ readonly extract: "extract"; /** * Allows extracting text and graphics for accessibility purposes (e.g., screen readers). */ readonly extractAccessibility: "extractAccessibility"; /** * Allows filling in existing interactive form fields, including digital signatures. */ readonly fillForms: "fillForms"; /** * Allows modifying the document contents by operations other than assembling. */ readonly modification: "modification"; /** * Allows high-quality printing (up to 300 dpi). If not set, printing is limited to 150 dpi. */ readonly printHighQuality: "printHighQuality"; /** * Allows printing the document. If `printHighQuality` is not set, printing is limited to degraded quality. */ readonly printing: "printing"; }; declare function DocumentTextComparisonMixin>(Base: T): { new (...args: any[]): { /** * Compares documents based on the operation provided. It supports both standard text comparison and AI-powered analysis and tagging. * * @example * Compare two documents * ```ts * const operation = new NutrientViewer.ComparisonOperation("text", { numberOfContextWords: 2 }); * * const originalDocument = new NutrientViewer.DocumentDescriptor({ filePath: "path/to/original.pdf", pageIndexes: [0]}); * const changedDocument = new NutrientViewer.DocumentDescriptor({ filePath: "path/to/changed.pdf", pageIndexes: [0]}); * * const comparisonDocuments = { originalDocument, changedDocument }; * * instance.compareDocuments(operation, comparisonDocuments) * .then((comparisonResults) => { * console.log(comparisonResults); * }); * ``` * * @example * AI-powered analysis * ```ts * const aiOperation = new NutrientViewer.ComparisonOperation( * NutrientViewer.ComparisonOperationType.AI, * { operationType: NutrientViewer.AIComparisonOperationType.ANALYZE } * ); * * instance.compareDocuments(comparisonDocuments, aiOperation) * .then((result) => { * // For AI operations, check the result type * if (NutrientViewer.isAIDocumentComparisonResult(result)) { * console.log('AI Summary:', result.summary); * console.log('Categories:', result.categories); * } * }); * ``` * * @example * AI-powered tagging with categories * ```ts * const tagOperation = new NutrientViewer.ComparisonOperation( * NutrientViewer.ComparisonOperationType.AI, * { * operationType: NutrientViewer.AIComparisonOperationType.TAG, * categories: ["Legal", "Financial"] * } * ); * * instance.compareDocuments(comparisonDocuments, tagOperation) * .then((result) => { * // For AI operations, check the result type * if (NutrientViewer.isAIDocumentComparisonResult(result)) { * console.log('Tagged References:', result.references); * // result.changes contains the original DocumentComparisonResult * } * }); * ``` * * @param comparisonDocuments - Descriptors of the original and changed documents. * @param operation - The comparison operation to be applied (either standard text or AI). * @returns A promise that resolves to the result of the comparison. The type depends on the operation: `DocumentComparisonResult` for text comparison, `AIDocumentComparisonResult` for AI operations. */ compareDocuments(comparisonDocuments: DocumentComparison.ComparisonDocuments, operation: ComparisonOperation): Promise; }; } & T; /** * The different possible validation states of the document. Based on the validation * of the digital signatures it contains. * * @enum */ export declare const DocumentValidationStatus: { /** * All of the signatures of the document are valid, that is, it should be shown with a green * checkmark or similar in the UI. */ valid: string; /** * All of the signatures of the document are valid with concerns, that is, it should be shown with * a yellow warning or similar in the UI. */ warning: string; /** * At least one signature of the document is invalid, that is, it should be shown with * a red cross of similar in the UI. */ error: string; /** * The document does not contain digital signatures. */ not_signed: string; }; declare type DocumentValidationStatusType = keyof typeof DocumentValidationStatus; /** @inline */ declare type DoNotSpellCheckPropertyPair = XOR, Record<'doNotSpellcheck', boolean>>; declare type DotNetDisposableStreamReference = { invokeMethodAsync(methodName: 'GetStream'): Promise; invokeMethodAsync(methodName: 'Dispose'): Promise; }; declare type DotNetObject = { invokeMethodAsync(methodName: string, ...args: any): Promise; }; /** * @class * An extension of the {@link NutrientViewer.Geometry.Point} that can also store an `intensity` value. * This is used for example inside an ink annotation, where the intensity is the pressure that was * exerted by the touch device. * @example * Create and update a point * ```ts * const point = new DrawingPoint({ * x: 20, * y: 30, * intensity: 0.3 * }); * point.intensity; // => 0.3 * ``` * * @public * @summary A 3D vector that describes a point in space and an intensity value. * @param args - An object used to initialize the Point. If `x` or `y` is omitted, `0` will * be used instead. If `intensity` is omitted, `0.5` will be used (the neutral intensity * value). * @default { x: 0, y: 0, intensity: 0.5 } */ export declare class DrawingPoint extends Point { /** * The `intensity` is used to describe the pressure of a point inside an ink annotation. It is * capped between 0 and 1 inclusive. * * If the touch input does not allow to measure the pressure, a value of `0.5` should be used. * * @default 0.5 */ intensity: number; static defaultValues: IObject; constructor(options?: IDrawingPoint); } /** * Represents one of the available signing methods for adding * new electronic signatures using the UI. * * @enum */ declare const ElectronicSignatureCreationMode: { /** UI in which users draw a signature. */ readonly DRAW: "DRAW"; /** UI in which users pick or drag an image to use that as the signature. */ readonly IMAGE: "IMAGE"; /** UI in which users can type a text and generate an image signature from it. */ readonly TYPE: "TYPE"; }; /** * @public * @summary Callback that returns the default text for the Type Electronic Signature UI. * @returns The default text for the Type Electronic Signature UI. */ export declare type ElectronicSignatureDefaultTextCallback = () => string | undefined | void; /** * Defines specific configuration options related to the electronic signatures feature. * * @public * @summary Object containing configuration options for electronic signatures * @example * NutrientViewer.load({ * electronicSignatures: { * creationModes: [NutrientViewer.ElectronicSignatureCreationMode.IMAGE], * fonts: [new NutrientViewer.Font("mycustomfont")] * } * }); */ export declare type ElectronicSignaturesConfiguration = { /** * Array of tabs that should be offered to users on the * electronic signatures modal. */ creationModes?: IElectronicSignatureCreationMode[]; /** * Array of {@link NutrientViewer.Font} fonts that users can choose from * when typing text for adding a new electronic signature. * * You can specify any additional font to use on a custom style sheet * set via {@link Configuration#styleSheets} via `@font-face` * CSS at-rule. * * When specifying the `name` of each `NutrientViewer.Font` record make sure * that it matches the one specified on the style sheet. */ fonts?: Readonly; /** * Optionally set an initial default text for the Type Electronic Signature UI. * * The default placeholder will be shown if the callback does not return a non-empty string, * or is not set to a non-empty string. * * @example * Setting a default text for the Type Electronic Signature UI * ```ts * NutrientViewer.load({ * electronicSignatures: { * setDefaultTypeText: () => "My default text" * } * }); * ``` */ setDefaultTypeText?: ElectronicSignatureDefaultTextCallback | string; /** * Optionally set color presets to be used in the Electronic Signatures dialog. * * @example * Setting custom color presets for the Type Electronic Signature UI * ```ts * NutrientViewer.load({ * electronicSignatures: { * colorPresets: [ * { * color: Color.RED, * localization: { * id: 'red', * defaultMessage: 'Red', * description: 'Red color', * }, * }, * { * color: Color.ORANGE, * localization: { * id: 'orange', * defaultMessage: 'Orange', * description: 'Orange color', * }, * }, * { * color: Color.YELLOW, * localization: { * id: 'yellow', * defaultMessage: 'Yellow', * description: 'Yellow color', * }, * }, * ], * } * }); * ``` */ colorPresets?: Readonly; }; /** * @class * Ellipse annotations are used to draw ellipses on a page. * * Ellipse annotations with transparent fill color are only selectable around their visible lines. * This means that you can create a page full of ellipse annotations while * annotations behind the ellipse annotation are still selectable. * * Right now, ellipse annotations are implemented using SVG images. This behavior is subject to * change. * *
* *
* @example * Create an ellipse annotation * ```ts * const annotation = new NutrientViewer.Annotations.EllipseAnnotation({ * pageIndex: 0, * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 10, * top: 10, * width: 100, * height: 100, * }), * cloudyBorderIntensity: 2, * cloudyBorderInset: new NutrientViewer.Geometry.Inset({ * left: 9, * top: 9, * right: 9, * bottom: 9, * }) * }); * ``` * * @public * @summary Display an ellipse on a page. * @param args - An object of the members. */ export declare class EllipseAnnotation extends ShapeAnnotation { /** * Intensity of the cloudy border. * * If not present or 0, the annotation will use a normal border. * * @default null Normal border. */ cloudyBorderIntensity: null | number; /** * Cloudy border inset. * * For ellipse annotations with a cloudy border, it contains the values for the distances from * the bounding box to bounding box wrapped by the inner, where the content fits. * * Visual representation of the property: * *
* *
*/ cloudyBorderInset: null | Inset; static defaultValues: IObject; static readableName: string; constructor(options?: Partial); } /** * @deprecated Use {@link Serializers.EllipseAnnotationJSON} instead. * @hidden */ export declare type EllipseAnnotationJSON = Serializers.EllipseAnnotationJSON; declare class EllipseAnnotationSerializer extends ShapeAnnotationSerializer { annotation: EllipseAnnotation; toJSON(): Serializers.EllipseAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): EllipseAnnotation; } /** * This record is used to persist the information for an embedded file. * * @summary Embedded File. * @hideconstructor * @see {@link Instance#getEmbeddedFiles} * @see {@link Instance#getAttachment} */ export declare class EmbeddedFile extends EmbeddedFile_base {} declare const EmbeddedFile_base: Immutable.Record.Factory; /** * This call back defines which text annotations should be treated as rich text annotation. * By default, all the text annotations are treated as plain text annotations, which means that * when you edit them, you will see the plain text editor. You can change this behavior by * returning `true` for the text annotations that you want to be treated as rich text annotations. * * For more information, see {@link Configuration#enableRichText}. * * @param annotation - The text annotation. * @example * Only treat newly created annotations as rich text annotations * ```ts * NutrientViewer.load({ * enableRichText: annotation => annotation.pageIndex === null * // ... * }); * ``` * */ export declare type EnableRichTextCallback = (annotation: TextAnnotation) => boolean; declare const EnvironmentSpecificNutrientViewer: typeof NutrientViewer; export default EnvironmentSpecificNutrientViewer; declare class EventEmitter { listeners: Record[]>; events: Array; /** * Creates a new EventEmitter that only accepts the events defined in `events`. If this is an * empty array, it accepts all event names. */ constructor(events?: Array); /** * Register a new event listener for the `event` event * * @param event - The event you want to listen to * @param listener - The callback that should be triggered on each `event` */ on(event: string, listener: EventListener_2): void; /** * Unregisters an event listener for the `event` event * * @param event - The event you want to listen to * @param listener - The callback that should be triggered on each `event` */ off(event: string, listener: EventListener_2): void; /** * Emits an event * * @param event - The event you want to trigger * @param args - The parameters that will get forwarded to the callbacks */ emit(event: string, ...args: TArgs): void; supportsEvent(event: string): boolean; isListening(events: Array): boolean; removeAllListeners(): void; } declare type EventListener_2 = (...args: TArgs) => void; /** * Defines the names of the events that can be emitted by the viewer. * * @example * ```ts * instance.addEventListener(NutrientViewer.EventName.VIEW_STATE_CHANGE, (viewState, previousViewState) => { * console.log(previousViewState.toJS()); * console.log(viewState.toJS()); * }); * ``` * * @enum */ declare const EventName: { /** * This event will be emitted whenever the current view state changes either by the user (via * clicking the UI) or via {@link Instance#setViewState | setViewState()}. It will be * called after other view state specific events. If, for example, the page index changes, * {@link Events.ViewStateCurrentPageIndexChangeEvent} will emit first. * * If you update multiple properties at once, this event will only be dispatched once. * * The callback takes the current {@link ViewState} as first argument, and the previous `ViewState` as second. * * @example * Log the previous and current view state whenever the view state changes. * ```ts * instance.addEventListener("viewState.change", (viewState, previousViewState) => { * console.log(previousViewState.toJS()); * console.log(viewState.toJS()); * }); * ``` * * @example * Show the order in which page index and view state change events are emitted. * ```ts * instance.addEventListener("viewState.currentPageIndex.change", () => console.log("first")); * instance.addEventListener("viewState.change", () => console.log("second")); * ``` * * @group ViewState */ readonly VIEW_STATE_CHANGE: "viewState.change"; /** * This event will be emitted whenever the current page index changes. It can be used to * track the current view of a user. * * @example * Log the new page index when the page changes. * ```ts * instance.addEventListener("viewState.currentPageIndex.change", (pageIndex) => { * console.log(pageIndex); * }); * ``` * * @group ViewState */ readonly VIEW_STATE_CURRENT_PAGE_INDEX_CHANGE: "viewState.currentPageIndex.change"; /** * This event will be emitted whenever the zoom level or the zoom mode changes. This could either * be a number multiplier or a distinct {@link ZoomConfiguration | zoom configuration or zoom mode}. * * @example * Log the new zoom value when the zoom changes. * ```ts * instance.addEventListener("viewState.zoom.change", (zoom) => { * console.log(zoom); * }); * ``` * * @group ViewState */ readonly VIEW_STATE_ZOOM_CHANGE: "viewState.zoom.change"; /** * This event will be emitted whenever the current preset is about to be updated with new property values * set by the user in the annotation toolbar. * * @example * Prevent the current preset from being updated in the annotation toolbar. * ```ts * instance.addEventListener("annotationPresets.update", (event) => { * event.preventDefault(); * }); * ``` * * @group Annotation */ readonly ANNOTATION_PRESETS_UPDATE: "annotationPresets.update"; /** * This event will be emitted whenever an annotation loses focus. * * The parameter is a {@link Events.AnnotationsBlurEvent}. * * @example * Log the annotation and event type when an annotation loses focus. * ```ts * instance.addEventListener("annotations.blur", (event) => { * console.log(event.annotation, event.nativeEvent.type) * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_BLUR: "annotations.blur"; /** * This event will be emitted whenever the current annotations change either due to a user * action (eg. clicking the UI) or via {@link Instance#create}, * {@link Instance#update} or {@link Instance#delete}. * * The event might also be emitted every time the NutrientViewer's annotations model changes. * This for example can happen when scrolling to a page and NutrientViewer loads the annotations * for that page or when opening the annotations sidebar and NutrientViewer (has to) loads * all the document annotations. * * The change event will fire before all specific events and it could be used * in case you want to perform some action regardless of which event caused the annotation * to "change" (create, delete, update, load, internal load, etc). * Consider using the specific events for more advanced use cases. * * @example * Perform a custom action whenever the annotations change. * ```ts * instance.addEventListener("annotations.change", () => { * // ... * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_CHANGE: "annotations.change"; /** * This event will be emitted whenever new annotations were created (either via the public * API or via the UI). * * If Nutrient Instant is enabled, annotations created by remote clients will also cause * this event to be emitted. * * The parameter is a {@link NutrientViewer.Immutable.List} of created {@link NutrientViewer.Annotations.Annotation}. * * @example * Log the list of created annotations. * ```ts * instance.addEventListener("annotations.create", (createdAnnotations) => { * console.log(createdAnnotations); * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_CREATE: "annotations.create"; /** * This event will be emitted whenever new annotations were deleted (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of deleted {@link NutrientViewer.Annotations}. * * @example * Log the list of deleted annotations. * ```ts * instance.addEventListener("annotations.delete", (deletedAnnotations) => { * console.log(deletedAnnotations); * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_DELETE: "annotations.delete"; /** * This event will be emitted whenever annotations were saved to the annotation provider. * * This event will follow a {@link Events.AnnotationsWillSaveEvent}. * * @example * Perform an action after annotations are saved. * ```ts * instance.addEventListener("annotations.didSave", () => { * // ... * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_DID_SAVE: "annotations.didSave"; /** * This event will be emitted whenever an annotation is focused. * * The parameter is a {@link Events.AnnotationsFocusEvent}. * * @example * Log the annotation and event type when an annotation is focused. * ```ts * instance.addEventListener("annotations.focus", (event) => { * console.log(event.annotation, event.nativeEvent.type) * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_FOCUS: "annotations.focus"; /** * This event will be emitted whenever annotations are loaded from the annotation provider. * This can happen more than once since we often load annotations on demand only. * * The parameter is a {@link NutrientViewer.Immutable.List} of loaded {@link NutrientViewer.Annotations}. * * @example * Log the loaded annotations when they are loaded from the provider. * ```ts * instance.addEventListener("annotations.load", (loadedAnnotations) => { * console.log(loadedAnnotations); * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_LOAD: "annotations.load"; /** * This event will be emitted whenever an annotation is pressed i.e. either clicked or tapped. * * The parameter is a {@link Events.AnnotationsPressEvent}. * * @example * Prevent the default behavior for LinkAnnotation and redirect to another site when an annotation is pressed. * ```ts * instance.addEventListener("annotations.press", (event) => { * if (event.annotation instanceof Annotations.LinkAnnotation) { * event.preventDefault(); * window.location.href = "https://example.com"; * } * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_PRESS: "annotations.press"; /** * This event will be emitted whenever new annotations were updated (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of updated {@link NutrientViewer.Annotations.Annotation}. * * @example * Log the list of updated annotations. * ```ts * instance.addEventListener("annotations.update", (updatedAnnotations) => { * console.log(updatedAnnotations); * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_UPDATE: "annotations.update"; /** * This event will be emitted when the user starts or ends an interaction * with an annotation. See {@link NutrientViewer.AnnotationsWillChangeReason} * for a comprehensive list of actions supported. * * Note that this event is only emitted for actions performed through the UI. * * Despite the name, it is not necessarily fired before each emission of * {@link NutrientViewer.EventName.ANNOTATIONS_CHANGE}, since that would not * correspond to the list of possible reasons described in * {@link NutrientViewer.AnnotationsWillChangeReason} on all cases. * * @example * Show a message depending on whether the user started or finished deleting an annotation. * ```ts * instance.addEventListener("annotations.willChange", event => { * const annotation = event.annotations.get(0); * if (event.reason === AnnotationsWillChangeReason.DELETE_START) { * console.log("Will open deletion confirmation dialog"); * } else if ( * event.reason === AnnotationsWillChangeReason.DELETE_END * ) { * if (annotation) { * console.log("The user decided to delete the annotation."); * } else { * console.log("The user decided to not delete the annotation."); * } * } * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_WILL_CHANGE: "annotations.willChange"; /** * This event will be emitted before annotations will be saved to the annotation provider. * * Right now, this happens whenever attributes of the annotation change (either via the * public API or via the UI) and the annotation is in a valid state. * * You can use this to display a loading spinner for example. This event will always be * followed by {@link Events.AnnotationsDidSaveEvent}. * * @example * Show a loading spinner before annotations are saved. * ```ts * instance.addEventListener("annotations.willSave", () => { * // ... * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_WILL_SAVE: "annotations.willSave"; /** * This event will fire whenever an annotation is being selected or unselected. * * @example * Log whether an annotation is selected or not when the selection changes. * ```ts * instance.addEventListener("annotationSelection.change", (annotations) => { * if (annotations.size !== 0) { * console.log("annotation is selected"); * } else { * console.log("no annotation is selected"); * } * }); * ``` * * @group Annotation */ readonly ANNOTATION_SELECTION_CHANGE: "annotationSelection.change"; /** * This event will be emitted whenever an annotation is dragged or resized using the UI. * * The parameter is a {@link Events.AnnotationsTransformEvent} * * @example * Log the bounding box of an annotation when it is transformed. * ```ts * instance.addEventListener("annotations.transform", (event) => { * console.log(event.annotation.boundingBox) * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_TRANSFORM: "annotations.transform"; /** * This event will be emitted whenever an annotation is copied using Cmd/Ctrl+C keyboard shortcut. * * The parameter is a {@link Events.AnnotationsCopyEvent} * * @example * Log the annotation that was copied. * ```ts * instance.addEventListener("annotations.copy", (event) => { * console.log(event.annotation) * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_COPY: "annotations.copy"; /** * This event will be emitted whenever an annotation is cut using Cmd/Ctrl+X keyboard shortcut. * * The parameter is a {@link Events.AnnotationsCutEvent} * * @example * Log the annotation that was cut. * ```ts * instance.addEventListener("annotations.cut", (event) => { * console.log(event.annotation) * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_CUT: "annotations.cut"; /** * This event will be emitted whenever an annotation is pasted using Cmd/Ctrl+V keyboard shortcut. * * The parameter is a {@link Events.AnnotationsPasteEvent} * * @example * Log the annotations that were pasted. * ```ts * instance.addEventListener("annotations.paste", (event) => { * console.log(event.annotations) * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_PASTE: "annotations.paste"; /** * This event will be emitted whenever an annotation is duplicated using the Ctrl/Cmd+D keyboard shortcut. * * The parameter is a {@link Events.AnnotationsDuplicateEvent} * * @example * Log the annotation that was duplicated. * ```ts * instance.addEventListener("annotations.duplicate", (event) => { * console.log(event.annotation) * }); * ``` * * @group Annotation */ readonly ANNOTATIONS_DUPLICATE: "annotations.duplicate"; /** * This event will be emitted whenever the current bookmarks change either * via {@link Instance#create}, {@link Instance#update} or {@link Instance#delete}. * * The change event will fire before all specific events. Consider using the specific events * for more advanced use cases. * * @example * Perform a custom action whenever the bookmarks change. * ```ts * instance.addEventListener("bookmarks.change", () => { * // ... * }); * ``` * * @group Bookmark */ readonly BOOKMARKS_CHANGE: "bookmarks.change"; /** * This event will be emitted whenever new bookmarks are created (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of created {@link Bookmark}. * * @example * Log the list of created bookmarks. * ```ts * instance.addEventListener("bookmarks.create", (createdBookmarks) => { * console.log(createdBookmarks); * }); * ``` * * @group Bookmark */ readonly BOOKMARKS_CREATE: "bookmarks.create"; /** * This event will be emitted whenever bookmarks are updated (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of updated {@link Bookmark}. * * @example * Log the list of updated bookmarks. * ```ts * instance.addEventListener("bookmarks.update", (updatedBookmarks) => { * console.log(updatedBookmarks); * }); * ``` * * @group Bookmark */ readonly BOOKMARKS_UPDATE: "bookmarks.update"; /** * This event will be emitted whenever bookmarks are deleted (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of deleted {@link Bookmark}. * * @example * Log the list of deleted bookmarks. * ```ts * instance.addEventListener("bookmarks.delete", (deletedBookmarks) => { * console.log(deletedBookmarks); * }); * ``` * * @group Bookmark */ readonly BOOKMARKS_DELETE: "bookmarks.delete"; /** * This event will be emitted whenever bookmarks are loaded from the bookmark provider. * This can happen more than once since we often load bookmarks on demand only. * * The parameter is a {@link NutrientViewer.Immutable.List} of loaded {@link Bookmark}. * * @example * Log the loaded bookmarks when they are loaded from the provider. * ```ts * instance.addEventListener("bookmarks.load", (loadedBookmarks) => { * console.log(loadedBookmarks); * }); * ``` * * @group Bookmark */ readonly BOOKMARKS_LOAD: "bookmarks.load"; /** * This event will be emitted whenever bookmarks were saved to the bookmark provider. * * This event will follow a {@link NutrientViewer.EventName.BOOKMARKS_WILL_SAVE}. * * @example * Perform an action after bookmarks are saved. * ```ts * instance.addEventListener("bookmarks.didSave", () => { * // ... * }); * ``` * * @group Bookmark */ readonly BOOKMARKS_DID_SAVE: "bookmarks.didSave"; /** * This event will be emitted before bookmarks will be saved to the bookmark provider. * * Right now, this happens whenever attributes of the bookmark change (either via the * public API or via the UI) and the bookmark is in a valid state. * * You can use this to display a loading spinner for example. This event will always be * followed by {@link NutrientViewer.EventName.BOOKMARKS_DID_SAVE}. * * @example * Show a loading spinner before bookmarks are saved. * ```ts * instance.addEventListener("bookmarks.willSave", () => { * // ... * }); * ``` * * @group Bookmark */ readonly BOOKMARKS_WILL_SAVE: "bookmarks.willSave"; /** * This event will be emitted whenever the current comments change either * via {@link Instance#create}, * {@link Instance#update} or {@link Instance#delete}. * * The change event will fire before all specific events. Consider using the specific events * for more advanced use cases. * * @example * Perform a custom action whenever the comments change. * ```ts * instance.addEventListener("comments.change", () => { * // ... * }); * ``` * * @group Comment */ readonly COMMENTS_CHANGE: "comments.change"; /** * This event will be emitted whenever new comments are created (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of created {@link Comment}. * * @example * Log the list of created comments. * ```ts * instance.addEventListener("comments.create", (createdComments) => { * console.log(createdComments); * }); * ``` * * @group Comment */ readonly COMMENTS_CREATE: "comments.create"; /** * This event will be emitted whenever comments are deleted (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of deleted {@link Comment}. * * @example * Log the list of deleted comments. * ```ts * instance.addEventListener("comments.delete", (deletedComments) => { * console.log(deletedComments); * }); * ``` * * @group Comment */ readonly COMMENTS_DELETE: "comments.delete"; /** * This event will be emitted whenever comments are updated (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of updated {@link Comment}. * * @example * Log the list of updated comments. * ```ts * instance.addEventListener("comments.update", (updatedComments) => { * console.log(updatedComments); * }); * ``` * * @group Comment */ readonly COMMENTS_UPDATE: "comments.update"; /** * This event will be emitted whenever comments are loaded from the comment provider. * This can happen more than once since we often load comments on demand only. * * The parameter is a {@link NutrientViewer.Immutable.List} of loaded {@link Comment}. * * @example * Log the loaded comments when they are loaded from the provider. * ```ts * instance.addEventListener("comments.load", (loadedComments) => { * console.log(loadedComments); * }); * ``` * * @group Comment */ readonly COMMENTS_LOAD: "comments.load"; /** * This event will be emitted before comments will be saved to the comment provider. * * Right now, this happens whenever attributes of the comment change (either via the * public API or via the UI) and the comment is in a valid state. * * You can use this to display a loading spinner for example. This event will always be * followed by {@link NutrientViewer.EventName.COMMENTS_DID_SAVE}. * * @example * Show a loading spinner before comments are saved. * ```ts * instance.addEventListener("comments.willSave", () => { * // ... * }); * ``` * * @group Comment */ readonly COMMENTS_WILL_SAVE: "comments.willSave"; /** * This event will be emitted whenever comments were saved to the comment provider. * * This event will follow a {@link NutrientViewer.EventName.COMMENTS_WILL_SAVE}. * * @example * Perform an action after comments are saved. * ```ts * instance.addEventListener("comments.didSave", () => { * // ... * }); * ``` * * @group Comment */ readonly COMMENTS_DID_SAVE: "comments.didSave"; /** * This event will be emitted whenever an instant client connects or disconnects from the current * document. See {@link Instance#connectedClients} for more information. * * To receive this callback, make sure to set up Nutrient Instant correctly. * * @example * Log the list of connected clients when the instant client list changes. * ```ts * instance.addEventListener("instant.connectedClients.change", (clients) => { * console.log(clients.toJS()); * }); * ``` * * @group Instant */ readonly INSTANT_CONNECTED_CLIENTS_CHANGE: "instant.connectedClients.change"; /** * This event will be emitted whenever operations have been performed in the document. * * The event listener will receive the array of {@link DocumentOperations} operations * performed on the document. * * @example * Perform a custom action when document operations are performed. * ```ts * instance.addEventListener("document.change", (operations) => { * // ... * }); * ``` * * @group Document */ readonly DOCUMENT_CHANGE: "document.change"; /** * This event will be emitted whenever document save state changes. This reflects changes to * return value of {@link Instance.hasUnsavedChanges}. * * The parameter is {@link Events.SaveStateChangeEvent}. * * @example * Log whether the document has unsaved changes when the save state changes. * ```ts * instance.addEventListener("document.saveStateChange", (event) => { * console.log(`Document has unsaved changes: ${event.hasUnsavedChanges}`); * }); * ``` * * @group Document */ readonly DOCUMENT_SAVE_STATE_CHANGE: "document.saveStateChange"; /** * This event will be emitted whenever the current value of form field were updated either due * to a user action or when {@link Instance#setFormFieldValues} is invoked. * * @example * Perform a custom action when form field values are updated. * ```ts * instance.addEventListener("formFieldValues.update", formFields => { * // ... * }); * ``` * * @group Form */ readonly FORM_FIELD_VALUES_UPDATE: "formFieldValues.update"; /** * This event will be emitted before form field values will be saved to the data provider. * * You can use this to display a loading spinner, for example. This event will always be * followed by {@link NutrientViewer.EventName.FORM_FIELD_VALUES_WILL_SAVE}. * * @example * Show a loading spinner before form field values are saved. * ```ts * instance.addEventListener("formFieldValues.willSave", () => { * // ... * }); * ``` * * @group Form */ readonly FORM_FIELD_VALUES_WILL_SAVE: "formFieldValues.willSave"; /** * This event will be emitted whenever the form field values were saved to the data provider. * * This event will follow a {@link NutrientViewer.EventName.FORM_FIELD_VALUES_WILL_SAVE}. * * @example * Perform an action after form field values are saved. * ```ts * instance.addEventListener("formFieldValues.didSave", () => { * // ... * }); * ``` * * @group Form */ readonly FORM_FIELD_VALUES_DID_SAVE: "formFieldValues.didSave"; /** * This event will be emitted whenever the form values will be submitted. * * To cancel the form submission, call the `preventDefault` function with no arguments. This * event will follow a {@link NutrientViewer.EventName.FORMS_WILL_SUBMIT}, when the submission got * not canceled with `preventDefault`. * * @example * Perform a custom action or cancel the form submission. * ```ts * instance.addEventListener("forms.willSubmit", ({ preventDefault }) => { * // ... * }); * ``` * * @group Form */ readonly FORMS_WILL_SUBMIT: "forms.willSubmit"; /** * This event will be emitted whenever the form got submitted to the specified URI. * The event will receive a object from the form submission. If the submission got transmitted * successfully, the object will contain a response key, which has a {@link * https://developer.mozilla.org/en-US/docs/Web/API/Response|response} object as a value. When * an error occurred during the submission, the object parameter will have an error key with * the error object as a value. * * @example * Handle the response or error after a form is submitted. * ```ts * instance.addEventListener("formFieldValues.didSave", ({ response, error }) => { * // ... * }); * ``` * * @group Form */ readonly FORMS_DID_SUBMIT: "forms.didSubmit"; /** * This event will be emitted whenever the current form fields change either due to a user * action (eg. clicking the UI) or via {@link Instance#create}, * {@link Instance#update} or {@link Instance#delete}. * * The change event will fire before all specific events and it could be used * in case you want to perform some action regardless of which event caused the form fields * to "change" (create, delete, update, load, internal load, etc). * Consider using the specific events for more advanced use cases. * * @example * Perform a custom action whenever the form fields change. * ```ts * instance.addEventListener("formFields.change", () => { * // ... * }); * ``` * * @group Form */ readonly FORM_FIELDS_CHANGE: "formFields.change"; /** * This event will be emitted whenever new form fields where created (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of created {@link NutrientViewer.FormFields}. * * @example * Log the list of created form fields. * ```ts * instance.addEventListener("formFields.create", (createdFormFields) => { * console.log(createdFormFields); * }); * ``` * * @group Form */ readonly FORM_FIELDS_CREATE: "formFields.create"; /** * This event will be emitted whenever new form fields where deleted (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of deleted {@link NutrientViewer.FormFields}. * * @example * Log the list of deleted form fields. * ```ts * instance.addEventListener("formFields.delete", (deletedFormFields) => { * console.log(deletedFormFields); * }); * ``` * * @group Form */ readonly FORM_FIELDS_DELETE: "formFields.delete"; /** * This event will be emitted whenever form fields were saved to the form field provider. * * This event will follow a {@link NutrientViewer.EventName.FORM_FIELDS_WILL_SAVE}. * * @example * Perform an action after form fields are saved. * ```ts * instance.addEventListener("formFields.didSave", () => { * // ... * }); * ``` * * @group Form */ readonly FORM_FIELDS_DID_SAVE: "formFields.didSave"; /** * This event will be emitted whenever form fields are loaded from the form field provider. * This can happen more than once since we often load form fields on demand only. * * The parameter is a {@link NutrientViewer.Immutable.List} of loaded {@link NutrientViewer.FormFields}. * * @example * Log the loaded form fields when they are loaded from the provider. * ```ts * instance.addEventListener("formFields.load", (loadedFormFields) => { * console.log(loadedFormFields); * }); * ``` * * @group Form */ readonly FORM_FIELDS_LOAD: "formFields.load"; /** * This event will be emitted whenever new form fields where updated (either via the public * API or via the UI). * * The parameter is a {@link NutrientViewer.Immutable.List} of updated {@link NutrientViewer.FormFields}. * * @example * Log the list of updated form fields. * ```ts * instance.addEventListener("formFields.update", (updatedFormFields) => { * console.log(updatedFormFields); * }); * ``` * * @group Form */ readonly FORM_FIELDS_UPDATE: "formFields.update"; /** * This event will be emitted before form fields will be saved to the form field provider. * * Right now, this happens whenever attributes of the form fields change (either via the * public API or via the UI) and the form field is in a valid state. * * You can use this to display a loading spinner for example. This event will always be * followed by {@link NutrientViewer.EventName.FORM_FIELDS_DID_SAVE}. * * @example * Show a loading spinner before form fields are saved. * ```ts * instance.addEventListener("formFields.willSave", () => { * // ... * }); * ``` * * @group Form */ readonly FORM_FIELDS_WILL_SAVE: "formFields.willSave"; /** * Whenever the search state changes, this event will fire with the latest state. * * @example * Log whether the search UI is focused when the search state changes. * ```ts * instance.addEventListener("search.stateChange", (searchState) => { * console.log(searchState.isFocused); * }); * ``` * * @group Search */ readonly SEARCH_STATE_CHANGE: "search.stateChange"; /** * This event will fire whenever the customer types in a new search term in the search UI. It can * be used to plug the default search into your own search UI. * * For an example, see {@link Events.SearchTermChangeEvent}. * * @group Search */ readonly SEARCH_TERM_CHANGE: "search.termChange"; /** * This event will fire whenever the list of ink signatures is changed (either a signature was * added, updated, or deleted). * * @example * Log a message when the ink signature list changes. * ```ts * instance.addEventListener("storedSignatures.change", () => { * console.log("ink signature list changed"); * }); * ``` * * @group StoredSignature */ readonly STORED_SIGNATURES_CHANGE: "storedSignatures.change"; /** * This event will fire whenever a signature is created and stored. * * @example * Log the annotation when a signature is created and stored. * ```ts * instance.addEventListener("storedSignatures.create", annotation => { * console.log(annotation); * }); * ``` * * @group StoredSignature */ readonly STORED_SIGNATURES_CREATE: "storedSignatures.create"; /** * This event will fire whenever a signature is deleted. * * @example * Log the annotation when a signature is deleted. * ```ts * instance.addEventListener("storedSignatures.delete", annotation => { * console.log(annotation); * }); * ``` * * @group StoredSignature */ readonly STORED_SIGNATURES_DELETE: "storedSignatures.delete"; /** * This event will fire whenever one ink signature is updated. * * @example * Log the updated annotations when an ink signature is updated. * ```ts * instance.addEventListener("storedSignatures.update", annotations => { * console.log(annotations); * }); * ``` * * @group StoredSignature */ readonly STORED_SIGNATURES_UPDATE: "storedSignatures.update"; /** * This event will be emitted whenever a click on a text line occurs that is not handled by any * occluding page element (annotation, form, etc.). * * The parameter is a {@link Events.TextLinePressEvent}. * * @example * Log the point in PDF page coordinates when a text line is clicked. * ```ts * instance.addEventListener("textLine.press", (event) => { * console.log(event.point); * }); * ``` * * @group Text */ readonly TEXT_LINE_PRESS: "textLine.press"; /** * Whenever the text selection changes, this event will fire with the latest selection. * * `textSelection` might be `null` when the selection was cleared. * * @example * Log whether text is selected or not when the selection changes. * ```ts * instance.addEventListener("textSelection.change", (textSelection) => { * if (textSelection) { * console.log("text is selected"); * } else { * console.log("no text is selected"); * } * }); * ``` * * @group Text */ readonly TEXT_SELECTION_CHANGE: "textSelection.change"; /** * This event will be emitted after calling {@link NutrientViewer.Instance#history}.undo or * {@link NutrientViewer.Instance#history}.redo, or after pressing the main toolbar Undo or Redo * buttons, optionally available. * * If provided, the listener callback will receive a {@link Events.HistoryChangeEvent} object. * * @example * Log the history change event after undo or redo. * ```ts * instance.addEventListener("history.change", (historyChangeEvent) => { * console.log(historyChangeEvent); * }); * ``` * * @group History */ readonly HISTORY_CHANGE: "history.change"; /** * This event will be emitted before adding an annotation change to the actions history; if the * event's `preventDefault()` method is called, the change will not be added and the action * will not be undoable. * * If provided, the listener callback will receive a {@link Events.HistoryWillChangeEvent} object. * * @example * Log the history will change event before adding to the actions history. * ```ts * instance.addEventListener("history.willChange", (historyWillChangeEvent) => { * console.log(historyWillChangeEvent); * }); * ``` * * @group History */ readonly HISTORY_WILL_CHANGE: "history.willChange"; /** * This event will be emitted after calling {@link NutrientViewer.Instance#history}.clear. * * @example * Log a message when the history is cleared. * ```ts * instance.addEventListener("history.clear", () => { * console.log('History cleared.'); * }); * ``` * * @group History */ readonly HISTORY_CLEAR: "history.clear"; /** * This event will be emitted after calling {@link NutrientViewer.Instance#history}.redo or after * pressing the main toolbar Redo button, optionally available. * * If provided, the listener callback will receive a {@link Events.HistoryChangeEvent} object. * * @example * Log the history redo event after a redo action. * ```ts * instance.addEventListener("history.redo", (historyRedoEvent) => { * console.log(historyRedoEvent); * }); * ``` * * @group History */ readonly HISTORY_REDO: "history.redo"; /** * This event will be emitted after calling {@link NutrientViewer.Instance#history}.undo or after * pressing the main toolbar Undo button, optionally available. * * If provided, the listener callback will receive a {@link Events.HistoryChangeEvent} object. * * @example * Log the history undo event after an undo action. * ```ts * instance.addEventListener("history.undo", (historyUndoEvent) => { * console.log(historyUndoEvent); * }); * ``` * * @group History */ readonly HISTORY_UNDO: "history.undo"; /** * This event will be emitted whenever a click on a page occurs that is not handled by any * occluding page element (annotation, form, etc.). * * This event internally uses the `onpointerup` event triggered by the browser. This is an * implementation detail which we are documenting because it is useful to prevent the propagation of click events on custom overlay items. * Please don't rely on this behavior if possible and use it wisely as it might break in future. * * The parameter is a {@link Events.PagePressEvent}. * * @example * Log the point in PDF page coordinates when a page is clicked. * ```ts * instance.addEventListener("page.press", (event) => { * console.log(event.point); * }); * ``` * * @group Page */ readonly PAGE_PRESS: "page.press"; /** * This event will fire whenever a signature is created and stored. * `storedSignatures.create` payload returns `null` values for the annotation * `id` and `name`. We return these values because the created signature is * not attached to the document hence it isn't assigned an `id` or `name`. * If you want to retrieve a complete list of values of the signature * annotation we suggest to listen to the `annotations.create` event. * * @example * Log the annotation when an ink signature is created and stored. * ```ts * instance.addEventListener("inkSignatures.create", annotation => { * console.log(annotation); * }); * ``` * * @group InkSignature */ readonly INK_SIGNATURES_CREATE: "inkSignatures.create"; /** * This event will fire whenever a signature is deleted. * * @example * Log the annotation when an ink signature is deleted. * ```ts * instance.addEventListener("inkSignatures.delete", annotation => { * console.log(annotation); * }); * ``` * * @group InkSignature */ readonly INK_SIGNATURES_DELETE: "inkSignatures.delete"; /** * This event will fire whenever one ink signature is updated. * * @example * Log the updated annotations when an ink signature is updated. * ```ts * instance.addEventListener("inkSignatures.update", annotations => { * console.log(annotations); * }); * ``` * * @group InkSignature */ readonly INK_SIGNATURES_UPDATE: "inkSignatures.update"; /** * This event will fire whenever the list of ink signatures is changed (either a signature was * added, updated, or deleted). * * @example * Log a message when the ink signature list changes. * ```ts * instance.addEventListener("inkSignatures.change", () => { * console.log("ink signature list changed"); * }); * ``` * * @group InkSignature */ readonly INK_SIGNATURES_CHANGE: "inkSignatures.change"; /** * This event will be emitted whenever the CropArea begins being created, moved, or resized (via UI interaction). * * @example * Log the crop area and page index when the crop area starts changing. * ```ts * instance.addEventListener("cropArea.changeStart", ({ area, pageIndex }) => { * console.log(area, pageIndex); * }); * ``` * * @group CropArea */ readonly CROP_AREA_CHANGE_START: "cropArea.changeStart"; /** * This event will be emitted whenever the crop area stops being created, moved or resized (via UI interaction). * * @example * Log the crop area and page index when the crop area stops changing. * ```ts * instance.addEventListener("cropArea.changeStop", ({ area, pageIndex }) => { * console.log(area, pageIndex); * }); * ``` * * @group CropArea */ readonly CROP_AREA_CHANGE_STOP: "cropArea.changeStop"; /** * This event will be emitted whenever the document comparison UI is shown. * * The event listener will receive the {@link DocumentComparisonConfiguration | document comparison configuration object} with which * {@link Instance#setDocumentComparisonMode | setDocumentComparisonMode()} has been called. * * @example * Perform an action when the document comparison UI is shown. * ```ts * instance.addEventListener("documentComparisonUI.start", (documentComparisonConfiguration) => { * // ... * }); * ``` * * @group DocumentComparison */ readonly DOCUMENT_COMPARISON_UI_START: "documentComparisonUI.start"; /** * This event will be emitted whenever the document comparison UI is hidden. * * @example * Perform an action when the document comparison UI is hidden. * ```ts * instance.addEventListener("documentComparisonUI.end", () => { * // ... * }); * ``` * * @group DocumentComparison */ readonly DOCUMENT_COMPARISON_UI_END: "documentComparisonUI.end"; /** * This event will be emitted whenever an annotation note is selected by pressing its associated icon. * * The parameter is a {@link Events.AnnotationNotePressEvent}. * * @example * Prevent the default annotation note UI from showing when an annotation note icon is pressed. * ```ts * instance.addEventListener("annotationNote.press", (event) => { * event.preventDefault(); * }); * ``` * * @group AnnotationNote */ readonly ANNOTATION_NOTE_PRESS: "annotationNote.press"; /** * This event will be emitted whenever an annotation note icon is hovered, which by default shows the annotation note editor popover element. * * The parameter is a {@link Events.AnnotationNotePressEvent}. * * @example * Prevent the default annotation note UI from showing when an annotation note icon is hovered. * ```ts * instance.addEventListener("annotationNote.hover", (event) => { * event.preventDefault(); * }); * ``` * * @group AnnotationNote */ readonly ANNOTATION_NOTE_HOVER: "annotationNote.hover"; /** * This event is emitted when the list of users mentioned in a comment changes or a new * comment is created with mentions. The `modifications` property contains a list of * modifications that were applied to the comment. Each modification contains the user ID * and the action that was performed. * * The event is *only emitted for the user that created or updated the comment* either via the * UI or the API. If you want to listen for changes to comments made by other users, you can * use the `comments.create`, `comments.change` and `comments.delete` event. You get the affected * comment in the event payload and can check the mentioned users using {@link Comment.getMentionedUserIds} method. * * @example * Log which users were mentioned or unmentioned in a comment. * ```ts * instance.addEventListener("comments.mention", (event) => { * const { comment, modifications } = event; * modifications.forEach((modification) => { * const { userId, action } = modification; * if (action === "ADDED") { * console.log(`User ${userId} was mentioned in comment ${comment.id}`); * } else { * console.log(`User ${userId} was unmentioned in comment ${comment.id}`); * } * }); * }); * ``` * * @group Comment */ readonly COMMENTS_MENTION: "comments.mention"; }; /** * The `Events` namespace contains all the event types that can be used with the * `addEventListener()` method. These events provide a comprehensive way to monitor * and respond to changes within the PDF viewer. * * @example * * ```ts * // Listen for view state changes * instance.addEventListener("viewState.change", (viewState, previousViewState) => { * console.log("View state changed:", viewState.toJS()); * }); * * // Listen for annotation creation * instance.addEventListener("annotations.create", (annotations) => { * console.log("New annotations created:", annotations.toJS()); * }); * * // Listen for page navigation * instance.addEventListener("viewState.currentPageIndex.change", (pageIndex) => { * console.log("Current page changed to:", pageIndex); * }); * ``` * * #### Event Handler Types * * Each event has a corresponding event listener type that defines the expected function signature. * These types ensure type safety when registering event listeners and provide clear * documentation of the parameters each event listener receives. * * #### Event Lifecycle * * Many events follow a lifecycle pattern: * - **Will** events: Fired before an action occurs, allowing you to prevent it * - **Change** events: Fired when the state changes * - **Did** events: Fired after an action completes * * For example, with annotations: * - `annotations.willSave` → `annotations.change` → `annotations.didSave` **/ export declare namespace Events { /** * This event will be emitted whenever the document comparison UI is shown. * * The event listener will receive the {@link DocumentComparisonConfiguration | document comparison configuration object} with which * {@link Instance#setDocumentComparisonMode} has been called. */ export type DocumentComparisonUIStartEvent = DocumentComparisonConfiguration; /** * This event will be emitted whenever the document comparison UI is hidden. * * The event listener will receive the {@link DocumentComparisonConfiguration | document comparison configuration object} with which * {@link Instance#setDocumentComparisonMode} has been called. */ export type DocumentComparisonUIEndEvent = DocumentComparisonConfiguration; /** * This event is emitted when the user **starts** changing the dimensions of the crop area on the document. */ export interface CropAreaChangeStartEvent { cropBox: Rect; pageIndex: number; } /** * This event is emitted when the dimensions or position of the CropBox is changed. */ export interface CropAreaChangeStopEvent { cropBox: Rect; pageIndex: number; } /** * This event is emitted when the list of users mentioned in a comment changes or a new * comment is created with mentions. The `modifications` property contains a list of * modifications that were applied to the comment. Each modification contains the user ID * and the action that was performed. * * The event is *only emitted for the user that created or updated the comment* either via the * UI or the API. If you want to listen for changes to comments made by other users, you can * use the `comments.create`, `comments.change` and `comments.delete` event. You get the affected * comment in the event payload and can check the mentioned users using {@link Comment.getMentionedUserIds} method. * * @example * Listen for changes to the changes in the list of mentioned users in a comment * ```ts * instance.addEventListener("comments.mention", (event) => { * const { comment, modifications } = event; * modifications.forEach((modification) => { * const { userId, action } = modification; * if (action === "ADDED") { * console.log(`User ${userId} was mentioned in comment ${comment.id}`); * } else { * console.log(`User ${userId} was unmentioned in comment ${comment.id}`); * } * }); * }); * ``` * * @see {@link Comment.getMentionedUserIds} */ export interface CommentsMentionEvent { /** * The comment that was updated. */ comment: Comment_2; /** * A list of modifications that were applied to the comment. */ modifications: List<{ userId: string; action: 'ADDED' | 'REMOVED'; }>; } /** * This event is emitted when certain user actions are performed to an * annotation. */ export interface AnnotationsWillChangeEvent { /** * A list of affected annotations. At the moment, this can contain at most * a single annotation. * * In some cases, it can return an empty list. Please See * {@link AnnotationsWillChangeReason} for a complete reference when * this is the case. */ annotations: List; /** This indicates the reason why the annotation will change. */ reason: keyof typeof AnnotationsWillChangeReason; } /** * This event is emitted whenever an annotation is either dragged * or resized. * * @example * Get current bounding box of an transforming annotation * ```ts * instance.addEventListener("annotations.transform", (event) => { * const boundingBox = event.annotation.boundingBox; * }); * ``` */ export interface AnnotationsTransformEvent { /** * The annotation that is being transformed. */ annotation: AnnotationsUnion; } /** * This event is emitted whenever an annotation is either clicked * or touched (on devices with touch capabilities) as well as when an already selected * annotation receives a click or touch event. * * Use this event to add custom behavior or prevent default ones from happening on press. * * Please note that this event will not be fired for annotations which are not * editable. If you still want to detect clicks for such annotations, for * example, to show a focus ring when clicked, you can use custom renderers to * made a clickable area above each annotation. This method is described fully * in our [Knowledge Base](https://www.nutrient.io/guides/web/knowledge-base/show-focus-ring-read-only/). * * @example * Prevent click and touch events on selected annotations * ```ts * instance.addEventListener("annotations.press", (event) => { * if (event.selected) { * event.preventDefault(); * } * }); * ``` */ export interface AnnotationsPressEvent { /** * The annotation that was pressed. * Remember that annotations are `Immutable.map`. */ annotation: AnnotationsUnion; /** * The browser event which caused the press event to dispatch. This is either a MouseEvent, * TouchEvent, or a PointerEvent. */ nativeEvent: Event; /** * When invoked, the `preventDefault` method prevents the default press * actions associated with the annotation to occur. */ preventDefault?: () => void; /** * Tells whether the pressed annotation is selected or not. */ selected: boolean; } /** * This event is emitted whenever an annotation is pasted. * * @example * Get current pasted annotation * ```ts * instance.addEventListener("annotations.paste", (event) => { * const pastedAnnotations = event.annotations; * }); * ``` */ export interface AnnotationsPasteEvent extends AnnotationsDuplicateEvent { /** * The action that was taken on the original annotation. * This can be `CUT` or `COPY`. */ previousAction: 'COPY' | 'CUT'; /** * The annotation that was pasted. */ annotations: AnnotationsUnion[]; /** * The form field generated for the pasted annotation. */ formFields?: FormField[]; /** * The original annotation that was cut or copied. */ originalAnnotations: AnnotationsUnion[]; /** * The form field associated with the original widget annotation that was cut or copied. */ originalFormFields?: Map_2; } /** * This event is emitted whenever an annotation is focused. Selecting an annotation also focuses it. * * When an annotation is deselected by pressing the `Escape` key, successive `annotations.blur` * and `annotations.focus` events will be dispatched for the same annotation. * * Use this event to add custom behavior like announcing the annotation value to screen readers. * * @example * Log text annotation value * ```ts * instance.addEventListener("annotations.focus", (event) => { * if (event.annotation instanceof Annotations.TextAnnotation) { * console.log(event.annotation.text); * } * }); * ``` */ export interface AnnotationsFocusEvent { /** * The annotation that was focused. * * Remember that annotations are `Immutable.map`. */ annotation: AnnotationsUnion; /** * The browser event `FocusEvent` which caused the `annotations.focus` event to dispatch. * Its `type` property is set to `focus`. */ nativeEvent: FocusEvent; } /** * This event is emitted whenever an annotation loses focus. Deselecting an annotation * with the pointer also blurs it. * * When an annotation is deselected by pressing the `Escape` key, successive `annotations.blur` * and `annotations.focus` events will be dispatched for the same annotation. * * Use this event to add custom behavior like announcing the annotation value to screen readers. * * @example * Log widget annotation new value * ```ts * instance.addEventListener("annotations.blur", (event) => { * instance.getFormFields().then(formFields => { * const formField = formFields.find(formField => formField.name === event.annotation.formFieldName); * console.log(formField); * }); * }); * ``` */ export interface AnnotationsBlurEvent { /** * The annotation that was focused. * * Remember that annotations are `Immutable.map`. */ annotation: AnnotationsUnion; /** * The browser event `FocusEvent` which caused the `annotations.blur` event to dispatch. * Its `type` property is set to `blur`. */ nativeEvent: FocusEvent; } /** * This event is emitted whenever an annotation is duplicated. You can * do this by pressing `Cmd/Ctrl+D` on the keyboard. * * @example * Get current duplicate annotation * ```ts * instance.addEventListener("annotations.duplicate", (event) => { * const duplicatedAnnotations = event.annotations; * }); * ``` */ export interface AnnotationsDuplicateEvent { /** * The annotation that was duplicated. */ annotations: AnnotationsUnion[]; /** * The newly created form field for the duplicated widget annotation. */ formFields?: FormField[]; /** * The original annotation that was duplicated. */ originalAnnotations: AnnotationsUnion[]; /** * The form field of the widget annotation that was duplicated. */ originalFormFields?: Map_2; } /** * This event is emitted whenever an annotation is cut. * * @example * Get current cut annotation * ```ts * instance.addEventListener("annotations.cut", (event) => { * const cutAnnotation = event.annotation; * }); * ``` */ export interface AnnotationsCutEvent { /** * The annotation that was cut. */ annotation: AnnotationsUnion; } /** * This event is emitted whenever an annotation is copied * * @example * Get current copied annotation * ```ts * instance.addEventListener("annotations.copy", (event) => { * const copiedAnnotation = event.annotation; * }); * ``` */ export interface AnnotationsCopyEvent { /** * The annotation that was copied. */ annotation: AnnotationsUnion; } /** * This event will be emitted whenever the current preset is about to be updated with new property values * set by the user in the annotation toolbar. * * @example * Register a AnnotationPresetsUpdateEvent using NutrientViewer.EventName.ANNOTATION_PRESETS_UPDATE and prevent the current preset from being updated. * ```ts * instance.addEventListener("annotationPresets.update", (event) => { * event.preventDefault(); * }); * ``` */ export interface AnnotationPresetsUpdateEvent { /** * Call this method to opt-out from updating the current preset. */ preventDefault: () => boolean; /** * Current active preset ID. */ currentPreset: AnnotationPresetID_2; /** * Properties and values of the current active preset. */ currentPresetProperties: AnnotationPreset_2; /** * Properties and values to be merged with the ones in the current active preset. */ newPresetProperties: AnnotationPreset_2; } /** * This event will be emitted whenever an annotation note is selected by pressing its associated icon. * * @example * Register a AnnotationNotePressEvent using NutrientViewer.EventName.ANNOTATION_NOTE_PRESS and prevent the default annotation note UI from showing. * ```ts * instance.addEventListener("annotationNote.press", (event) => { * event.preventDefault(); * }); * ``` */ export interface AnnotationNotePressEvent { /** Call this method to opt-out from showing the default annotation note UI. */ preventDefault: () => boolean; /** Annotation note for which the icon has been pressed. */ annotationNote?: AnnotationNote | null; } /** * This event will be emitted whenever an annotation note is hovered. * * @example * Register a AnnotationNoteHoverEvent using NutrientViewer.EventName.ANNOTATION_NOTE_HOVER and prevent the default annotation note UI from showing. * ```ts * instance.addEventListener("annotationNote.press", (event) => { * event.preventDefault(); * }); * ``` */ export interface AnnotationNoteHoverEvent { /** * Call this method to opt-out from showing the default annotation note UI. */ preventDefault: () => boolean; /** * Annotation note for which the icon has been hovered. */ annotationNote?: AnnotationNote | null; } /** * This event will be emitted whenever a click on a page occurs that is not handled by any * occluding page element (annotation, form, etc.). * * @example * Register a PagePressEvent and get the point in PDF page coordinates. * ```ts * instance.addEventListener("page.press", (event) => { * console.log(event.point); * }); * ``` */ export interface PagePressEvent { /** * The index of the page that was pressed. */ pageIndex: number; /** * The point where the press event was detected in PDF page space coordinates. */ point: Point; /** * The browser event which caused the press event to dispatch. Either a MouseEvent, TouchEvent, or * a PointerEvent. */ nativeEvent: Event; } /** * This event will be emitted whenever a click on a text line occurs that is not handled by any * occluding page element (annotation, form, etc.). * * @example * Register a TextLinePressEvent and get the point in PDF page coordinates. * ```ts * instance.addEventListener("textLine.press", (event) => { * console.log(event.point); * }); * ``` */ export interface TextLinePressEvent { /** * The text line that was clicked. */ textLine: TextLine; /** * The point where the press event was detected in PDF page space coordinates. */ point: Point; /** * The browser event which caused the press event to dispatch. This is either a MouseEvent, * TouchEvent, or a PointerEvent. */ nativeEvent: Event; } /** * This event is emitted when document save state changes. */ export interface SaveStateChangeEvent { /** Indicates whether there are any local changes. */ hasUnsavedChanges: boolean; } export interface HistoryRedoEvent { /** Type of history change. */ action: 'redo'; /** Annotation state before the action. */ before: AnnotationsUnion; /** Annotation state after the action. */ after: AnnotationsUnion; } export interface HistoryUndoEvent { /** Type of history change. */ action: 'undo'; /** Annotation state before the action. */ before: AnnotationsUnion; /** Annotation state after the action. */ after: AnnotationsUnion; } export interface HistoryChangeEvent { /** Type of history change. */ action: 'undo' | 'redo' | 'change' | 'willChange' | 'clear'; /** Annotation state before the action. */ before: AnnotationsUnion; /** Annotation state after the action. */ after: AnnotationsUnion; } export interface HistoryWillChangeEvent { type: 'create' | 'update' | 'delete'; annotation: Annotation; preventDefault: () => void; } /** * This event will fire whenever the customer types in a new search term in the search UI. It can * be used to plug the default search into your own search UI. * * @example * Implement your custom search backend * ```ts * instance.addEventListener("search.termChange", async (event) => { * // Opt-out from the default implementation. * event.preventDefault(); * * // We clear the search state, when the search term was removed. * if (term.length == 0) { * instance.setSearchState(searchState => searchState.set("term", "")); * } * * // Manually update the UI. If `SearchState#term` is not updated, the update will * // be ignored. * instance.setSearchState(searchState => * searchState * .set("term", event.term) * .set("isLoading", true) * ); * * // Make sure to cancel all outstanding requests so that the loading state won't be * // overwritten by an outdated search response (e.g. When the user types "foo" we * // want to cancel all requests for "f" and "fo" while the user types - otherwise * // incoming responses for "f" will clear the loading state of "foo"). This should * // make `myCustomSearch` no longer resolve its promise. * cancelSearchRequest(); * * // Implement your custom search logic that returns SearchResult objects. This can use * // `Instance#search()` internally. * const results = await myCustomSearch(term); * * // Apply the new search results. For an actual use case, you probably want to update * // `SearchState#focusedResultIndex` as well. * instance.setSearchState(searchState => * searchState * .set("isLoading", false) * .set("results", results) * ); * }); * ``` */ export interface SearchTermChangeEvent { /** * The updated search term. */ term: string; /** * Call this method to opt-out from the default search logic. */ preventDefault: () => void; } /** * This event is emitted when new annotations are created. The event includes the list of created annotations. * * @example * Get the list of created annotations. * ```ts * instance.addEventListener("annotations.create", (annotations: AnnotationsCreateEvent) => { * console.log(annotations.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.ANNOTATIONS_CREATE} */ export type AnnotationsCreateEvent = List; /** * This event is emitted when annotations are deleted. The event includes the list of deleted annotations. * * @example * Get the list of deleted annotations. * ```ts * instance.addEventListener("annotations.delete", (annotations) => { * console.log(annotations.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.ANNOTATIONS_DELETE} */ export type AnnotationsDeleteEvent = List; /** * This event is emitted when annotations are updated. The event includes the list of updated annotations. * * @example * Get the list of updated annotations. * ```ts * instance.addEventListener("annotations.update", (annotations: AnnotationsUpdateEvent) => { * console.log(annotations.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.ANNOTATIONS_UPDATE} */ export type AnnotationsUpdateEvent = List; /** * This event is emitted when annotations are loaded. The event includes the list of loaded annotations. * * @example * Get the list of loaded annotations. * ```ts * instance.addEventListener("annotations.load", (annotations: AnnotationsLoadEvent) => { * console.log(annotations.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.ANNOTATIONS_LOAD} */ export type AnnotationsLoadEvent = List; /** * This event is emitted when annotations are saved. The event includes the list of saved annotations. * * @example * Get the list of saved annotations. * ```ts * instance.addEventListener("annotations.willSave", (annotations: AnnotationsWillSaveEvent) => { * console.log("Annotations will be saved"); * }); * ``` * * @see {@link NutrientViewer.EventName.ANNOTATIONS_WILL_SAVE} */ export type AnnotationsWillSaveEvent = void; /** * This event is emitted when annotations are saved. The event includes the list of saved annotations. * * @example * Get the list of saved annotations. * ```ts * instance.addEventListener("annotations.didSave", (annotations: AnnotationsDidSaveEvent) => { * console.log("Annotations were saved"); * }); * ``` * * @see {@link NutrientViewer.EventName.ANNOTATIONS_DID_SAVE} */ export type AnnotationsDidSaveEvent = void; /** * This event is emitted when the annotation selection changes. The event includes the list of selected annotations. * * @example * Get the list of selected annotations. * ```ts * instance.addEventListener("annotationSelection.change", (annotations: AnnotationSelectionChangeEvent) => { * console.log(annotations.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.ANNOTATION_SELECTION_CHANGE} */ export type AnnotationSelectionChangeEvent = List; /** * This event is emitted when new bookmarks are created. The event includes the list of created bookmarks. * * @example * Get the list of created bookmarks. * ```ts * instance.addEventListener("bookmarks.create", (bookmarks: BookmarksCreateEvent) => { * console.log(bookmarks.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.BOOKMARKS_CREATE} */ export type BookmarksCreateEvent = List; /** * This event is emitted when bookmarks are updated. The event includes the list of updated bookmarks. * * @example * Get the list of updated bookmarks. * ```ts * instance.addEventListener("bookmarks.update", (bookmarks: BookmarksUpdateEvent) => { * console.log(bookmarks.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.BOOKMARKS_UPDATE} */ export type BookmarksUpdateEvent = List; /** * This event is emitted when bookmarks are deleted. The event includes the list of deleted bookmarks. * * @example * Get the list of deleted bookmarks. * ```ts * instance.addEventListener("bookmarks.delete", (bookmarks: BookmarksDeleteEvent) => { * console.log(bookmarks.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.BOOKMARKS_DELETE} */ export type BookmarksDeleteEvent = List; /** * This event is emitted when bookmarks are loaded. The event includes the list of loaded bookmarks. * * @example * Get the list of loaded bookmarks. * ```ts * instance.addEventListener("bookmarks.load", (bookmarks) => { * console.log(bookmarks.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.BOOKMARKS_LOAD} */ export type BookmarksLoadEvent = List; /** * This event is emitted when new comments are created. The event includes the list of created comments. * * @example * Get the list of created comments. * ```ts * instance.addEventListener("comments.create", (comments: CommentsCreateEvent) => { * console.log(comments.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.COMMENTS_CREATE} */ export type CommentsCreateEvent = List; /** * This event is emitted when comments are updated. The event includes the list of updated comments. * * @example * Get the list of updated comments. * ```ts * instance.addEventListener("comments.update", (comments: CommentsUpdateEvent) => { * console.log(comments.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.COMMENTS_UPDATE} */ export type CommentsUpdateEvent = List; /** * This event is emitted when comments are deleted. The event includes the list of deleted comments. * * @example * Get the list of deleted comments. * ```ts * instance.addEventListener("comments.delete", (comments: CommentsDeleteEvent) => { * console.log(comments.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.COMMENTS_DELETE} */ export type CommentsDeleteEvent = List; /** * This event is emitted when comments are loaded. The event includes the list of loaded comments. * * @example * Get the list of loaded comments. * ```ts * instance.addEventListener("comments.load", (comments) => { * console.log(comments.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.COMMENTS_LOAD} */ export type CommentsLoadEvent = List; /** * This event is emitted when form field values are updated. The event includes the list of updated form field values. * * @example * Get the list of updated form field values. * ```ts * instance.addEventListener("formFieldValues.update", (formFieldValues: FormFieldValuesUpdateEvent) => { * console.log(formFieldValues.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.FORM_FIELD_VALUES_UPDATE} */ export type FormFieldValuesUpdateEvent = List; export type FormsWillSubmitEvent = { /** Call this method to opt-out from the default form submission. */ preventDefault: () => void; }; /** * This event is emitted when form fields are created. The event includes the list of created form fields. * * @example * Get the list of created form fields. * ```ts * instance.addEventListener("formFields.create", (formFields: FormFieldsCreateEvent) => { * console.log(formFields.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.FORM_FIELDS_CREATE} */ export type FormFieldsCreateEvent = List; /** * This event is emitted when form fields are updated. The event includes the list of updated form fields. * * @example * Get the list of updated form fields. * ```ts * instance.addEventListener("formFields.update", (formFields: FormFieldsUpdateEvent) => { * console.log(formFields.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.FORM_FIELDS_UPDATE} */ export type FormFieldsUpdateEvent = List; /** * This event is emitted when form fields are deleted. The event includes the list of deleted form fields. * * @example * Get the list of deleted form fields. * ```ts * instance.addEventListener("formFields.delete", (formFields: FormFieldsDeleteEvent) => { * console.log(formFields.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.FORM_FIELDS_DELETE} */ export type FormFieldsDeleteEvent = List; /** * This event is emitted when form fields are loaded. The event includes the list of loaded form fields. * * @example * Get the list of loaded form fields. * ```ts * instance.addEventListener("formFields.load", (formFields: FormFieldsLoadEvent) => { * console.log(formFields.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.FORM_FIELDS_LOAD} */ export type FormFieldsLoadEvent = List; /** * This event is emitted when the search state changes. The event includes the latest search state. * * @example * Get the latest search state. * ```ts * instance.addEventListener("search.stateChange", (searchState: SearchStateChangeEvent) => { * console.log(searchState.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.SEARCH_STATE_CHANGE} */ export type SearchStateChangeEvent = SearchState; /** * This event is emitted when a new signature is created and stored. * * @example * Get the new signature. * ```ts * instance.addEventListener("storedSignatures.create", (signature: StoredSignatureCreateEvent) => { * console.log(signature.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.STORED_SIGNATURES_CREATE} */ export type StoredSignatureCreateEvent = Signature; /** * This event is emitted when a signature is updated. * * @example * Get the list of updated signatures. * ```ts * instance.addEventListener("storedSignatures.update", (signatures: StoredSignatureUpdateEvent) => { * console.log(signatures.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.STORED_SIGNATURES_UPDATE} */ export type StoredSignatureUpdateEvent = List; /** * This event is emitted when a signature is deleted. * * @example * Get the deleted signature. * ```ts * instance.addEventListener("storedSignatures.delete", (signature: StoredSignatureDeleteEvent) => { * console.log(signature.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.STORED_SIGNATURES_DELETE} */ export type StoredSignatureDeleteEvent = Signature; /** * This event will fire whenever a signature is created and stored `storedSignatures.create` payload * returns `null` values for the annotation id and name. We return these values because * the created signature is not attached to the document hence it isn't assigned an id or name. * If you want to retrieve a complete list of values of the signature annotation we suggest to listen to the annotations.create event. * * @example * Get the new signature. * ```ts * instance.addEventListener("inkSignatures.create", (signature: InkSignatureCreateEvent) => { * console.log(signature.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.INK_SIGNATURES_CREATE} */ export type InkSignatureCreateEvent = Signature; /** * This event is emitted when a signature is deleted. * * @example * Get the deleted signature. * ```ts * instance.addEventListener("inkSignatures.delete", (signature: InkSignatureDeleteEvent) => { * console.log(signature.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.INK_SIGNATURES_DELETE} */ export type InkSignatureDeleteEvent = Signature; /** * This event is emitted when a signature is updated. * * @example * Get the list of updated signatures. * ```ts * instance.addEventListener("inkSignatures.update", (signatures: InkSignatureUpdateEvent) => { * console.log(signatures.toJS()); * }); * ``` * * @see {@link NutrientViewer.EventName.INK_SIGNATURES_UPDATE} */ export type InkSignatureUpdateEvent = List; /** * This event is emitted when the current page index in the viewer changes. The event value is the new page index. * * @example * Get the new page index. * ```ts * instance.addEventListener("viewState.currentPageIndex.change", (pageIndex: ViewStateCurrentPageIndexChangeEvent) => { * console.log(pageIndex); * }); * ``` * * @see {@link NutrientViewer.EventName.VIEW_STATE_CURRENT_PAGE_INDEX_CHANGE} */ export type ViewStateCurrentPageIndexChangeEvent = number; /** * This event is emitted when the zoom level in the viewer changes. The event value is the new zoom level. * * @example * Get the new zoom level. * ```ts * instance.addEventListener("viewState.zoom.change", (zoom: ViewStateZoomChangeEvent) => { * console.log(zoom); * }); * ``` * * @see {@link NutrientViewer.EventName.VIEW_STATE_ZOOM_CHANGE} */ export type ViewStateZoomChangeEvent = number; /** * This event is emitted when form field values are saved. * * @example * Get the list of saved form field values. * ```ts * instance.addEventListener("formFieldValues.didSave", () => { * console.log("Form field values were saved"); * }); * ``` * * @see {@link NutrientViewer.EventName.FORM_FIELD_VALUES_DID_SAVE} */ export interface FormFieldValuesDidSaveEvent { /** The response from the backend. */ response: Response; /** The error from the backend. */ error: Error; } export interface EventNameToHandlerMap { [EventName.VIEW_STATE_CHANGE]: (previousViewState: ViewState, viewState: ViewState) => void; [EventName.VIEW_STATE_CURRENT_PAGE_INDEX_CHANGE]: (event: Events.ViewStateCurrentPageIndexChangeEvent) => void; [EventName.VIEW_STATE_ZOOM_CHANGE]: (event: Events.ViewStateZoomChangeEvent) => void; [EventName.ANNOTATION_PRESETS_UPDATE]: (event: Events.AnnotationPresetsUpdateEvent) => void; [EventName.ANNOTATIONS_BLUR]: (event: Events.AnnotationsBlurEvent) => void; [EventName.ANNOTATIONS_CHANGE]: () => void; [EventName.ANNOTATIONS_CREATE]: (event: Events.AnnotationsCreateEvent) => void; [EventName.ANNOTATIONS_DELETE]: (event: Events.AnnotationsDeleteEvent) => void; [EventName.ANNOTATIONS_DID_SAVE]: () => void; [EventName.ANNOTATIONS_FOCUS]: (event: Events.AnnotationsFocusEvent) => void; [EventName.ANNOTATIONS_LOAD]: (event: Events.AnnotationsLoadEvent) => void; [EventName.ANNOTATIONS_PRESS]: (event: Events.AnnotationsPressEvent) => void; [EventName.ANNOTATIONS_UPDATE]: (event: Events.AnnotationsUpdateEvent) => void; [EventName.ANNOTATIONS_WILL_CHANGE]: (event: Events.AnnotationsWillChangeEvent) => void; [EventName.ANNOTATIONS_WILL_SAVE]: () => void; [EventName.ANNOTATION_SELECTION_CHANGE]: (event: Events.AnnotationSelectionChangeEvent) => void; [EventName.ANNOTATIONS_TRANSFORM]: (event: Events.AnnotationsTransformEvent) => void; [EventName.ANNOTATIONS_COPY]: (event: Events.AnnotationsCopyEvent) => void; [EventName.ANNOTATIONS_CUT]: (event: Events.AnnotationsCutEvent) => void; [EventName.ANNOTATIONS_PASTE]: (event: Events.AnnotationsPasteEvent) => void; [EventName.ANNOTATIONS_DUPLICATE]: (event: Events.AnnotationsDuplicateEvent) => void; [EventName.BOOKMARKS_CHANGE]: () => void; [EventName.BOOKMARKS_CREATE]: (event: Events.BookmarksCreateEvent) => void; [EventName.BOOKMARKS_UPDATE]: (event: Events.BookmarksUpdateEvent) => void; [EventName.BOOKMARKS_DELETE]: (event: Events.BookmarksDeleteEvent) => void; [EventName.BOOKMARKS_LOAD]: (event: Events.BookmarksLoadEvent) => void; [EventName.BOOKMARKS_DID_SAVE]: () => void; [EventName.BOOKMARKS_WILL_SAVE]: () => void; [EventName.COMMENTS_CHANGE]: () => void; [EventName.COMMENTS_CREATE]: (event: Events.CommentsCreateEvent) => void; [EventName.COMMENTS_DELETE]: (event: Events.CommentsDeleteEvent) => void; [EventName.COMMENTS_UPDATE]: (event: Events.CommentsUpdateEvent) => void; [EventName.COMMENTS_LOAD]: (event: Events.CommentsLoadEvent) => void; [EventName.COMMENTS_WILL_SAVE]: () => void; [EventName.COMMENTS_DID_SAVE]: () => void; [EventName.INSTANT_CONNECTED_CLIENTS_CHANGE]: (clients: Map_2) => void; [EventName.DOCUMENT_CHANGE]: (operations?: Array) => void; [EventName.DOCUMENT_SAVE_STATE_CHANGE]: (event: Events.SaveStateChangeEvent) => void; [EventName.FORM_FIELD_VALUES_UPDATE]: (event: Events.FormFieldValuesUpdateEvent) => void; [EventName.FORM_FIELD_VALUES_WILL_SAVE]: () => void; [EventName.FORM_FIELD_VALUES_DID_SAVE]: (event: Events.FormFieldValuesDidSaveEvent) => void; [EventName.FORMS_WILL_SUBMIT]: (event: { preventDefault: () => void; }) => void; [EventName.FORMS_DID_SUBMIT]: () => void; [EventName.FORM_FIELDS_CHANGE]: () => void; [EventName.FORM_FIELDS_CREATE]: (event: Events.FormFieldsCreateEvent) => void; [EventName.FORM_FIELDS_DELETE]: (event: Events.FormFieldsDeleteEvent) => void; [EventName.FORM_FIELDS_DID_SAVE]: () => void; [EventName.FORM_FIELDS_LOAD]: (event: Events.FormFieldsLoadEvent) => void; [EventName.FORM_FIELDS_UPDATE]: (event: Events.FormFieldsUpdateEvent) => void; [EventName.FORM_FIELDS_WILL_SAVE]: () => void; [EventName.SEARCH_STATE_CHANGE]: (event: Events.SearchStateChangeEvent) => void; [EventName.SEARCH_TERM_CHANGE]: (event: Events.SearchTermChangeEvent) => void; [EventName.STORED_SIGNATURES_CHANGE]: () => void; [EventName.STORED_SIGNATURES_CREATE]: (event: Events.StoredSignatureCreateEvent) => void; [EventName.STORED_SIGNATURES_DELETE]: (event: Events.StoredSignatureDeleteEvent) => void; [EventName.STORED_SIGNATURES_UPDATE]: (event: Events.StoredSignatureUpdateEvent) => void; [EventName.TEXT_LINE_PRESS]: (event: Events.TextLinePressEvent) => void; [EventName.TEXT_SELECTION_CHANGE]: (selection: TextSelection_2 | null) => void; [EventName.HISTORY_CHANGE]: (event: Events.HistoryChangeEvent) => void; [EventName.HISTORY_WILL_CHANGE]: (event: Events.HistoryWillChangeEvent) => void; [EventName.HISTORY_CLEAR]: () => void; [EventName.HISTORY_REDO]: (event: Events.HistoryRedoEvent) => void; [EventName.HISTORY_UNDO]: (event: Events.HistoryUndoEvent) => void; [EventName.PAGE_PRESS]: (event: Events.PagePressEvent) => void; [EventName.INK_SIGNATURES_CREATE]: (event: Events.InkSignatureCreateEvent) => void; [EventName.INK_SIGNATURES_DELETE]: (event: Events.InkSignatureDeleteEvent) => void; [EventName.INK_SIGNATURES_UPDATE]: (event: Events.InkSignatureUpdateEvent) => void; [EventName.INK_SIGNATURES_CHANGE]: () => void; [EventName.CROP_AREA_CHANGE_START]: (event: Events.CropAreaChangeStartEvent) => void; [EventName.CROP_AREA_CHANGE_STOP]: (event: Events.CropAreaChangeStopEvent) => void; [EventName.DOCUMENT_COMPARISON_UI_START]: (event: Events.DocumentComparisonUIStartEvent) => void; [EventName.DOCUMENT_COMPARISON_UI_END]: () => void; [EventName.ANNOTATION_NOTE_PRESS]: (event: Events.AnnotationNotePressEvent) => void; [EventName.ANNOTATION_NOTE_HOVER]: (event: Events.AnnotationNoteHoverEvent) => void; [EventName.COMMENTS_MENTION]: (event: Events.CommentsMentionEvent) => void; } } /** Export options object **/ export declare type ExportOfficeFlags = { /** One of {@link NutrientViewer.OfficeDocumentFormat} values. */ format: IDocumentOfficeFormat; }; /** Export options object **/ export declare type ExportPDFFlags = { /** * Whether the document annotations should be converted to PDF content and therefore not editable in the future. * * @default false */ flatten?: boolean; /** * Whether the document should be exported using "full" or "incremental" saving. Default: `false`, or `true` if the document is digitally signed and the license includes the Digital Signatures component. * * @standalone */ incremental?: boolean; /** * @server * @default true */ includeComments?: boolean; /** * @standalone * @default false */ saveForPrinting?: boolean; /** * Whether the document annotations should be exported. * * @default false */ excludeAnnotations?: boolean; /** * Contain the `userPassword` and `ownerPassword` to encrypt the PDF along with the `documentPermissions`. */ permissions?: { /** The user password to encrypt the PDF. */ userPassword: string; /** The owner password to encrypt the PDF. */ ownerPassword: string; /** An Array that specifies what users can do with the output PDF. */ documentPermissions: Array; }; /** * If set to `true`, a default set of options will be applied to the exported document: * * ```ts * { * conformance: NutrientViewer.Conformance.PDFA_2B, * vectorization: true, * rasterization: true, * } * ``` * * Instead of a boolean value you can pass your own object ith custom values for the properties above. * * @default false */ outputFormat?: boolean | PDFAFlags; /** * If set to `true` the exported document will have a default set of options: * * ```ts * { * documentFormat: 'pdf', * grayscaleText: false, * grayscaleGraphics: false, * grayscaleFormFields: false, * grayscaleAnnotations: false, * grayscaleImages: false, * disableImages: false, * mrcCompression: false, * imageOptimizationQuality: 2, * linearize: false, * } * ``` * * Otherwise, you can pass the above options object customised with your own values * instead of a boolean value. * * @server * @default false */ optimize?: boolean | OptimizationFlags; flattenElectronicSignatures?: boolean; officeConversionSettings?: OfficeConversionSettings; }; declare const extraToolbarTypes: readonly ["layout-config", "marquee-zoom", "custom", "responsive-group", "comment", "redact-text-highlighter", "redact-rectangle", "cloudy-rectangle", "dashed-rectangle", "cloudy-ellipse", "dashed-ellipse", "dashed-polygon", "document-comparison", "measure", "undo", "redo", "form-creator", "content-editor", "ai-assistant", "pager-expanded"]; /** * @class * This record is used to persist information related to custom fonts on Standalone deployments. * Custom fonts need to be specified during the instance load and correctly fetched. * They will be used while rendering the document contents and exporting its annotations. * @example * Create a new Font object * ```ts * const fetcher = name => * fetch(`https://example.com/${name}`).then(r => { * if (r.status === 200) { * return r.blob(); * } else { * throw new Error(); * } * }); * * const customFonts = ["arial.ttf", "helvetica.ttf", "tahoma.ttf"] * .map(font => new NutrientViewer.Font({ name: font, callback: fetcher })); * * NutrientViewer.load({ * customFonts, * document: 'https://example.com/document.pdf' * }).then(instance => {}); * ``` * * @public * @summary An object used to load a new font. */ export declare class Font extends Font_base { /** A unique identifier to name the custom font. */ name: string | null; /** Non-optional callback to fetch the custom font. */ callback: FontCallback | null; constructor(args: { name: string; callback?: FontCallback; }); } declare const Font_base: Record_2.Factory; /** * On Standalone, this callback receives the name of a font to retrieve as an argument * and you can return from it a `Promise` that resolves to a `Blob` with the font data to * use. * * See {@link https://www.nutrient.io/guides/web/features/custom-fonts/ | this guide} * to learn more. * * @public * @param fontName - The `name` specified on the same {@link Font} constructor. * @example * Create a custom font for retrieving "Arial.ttf" * ```ts * new NutrientViewer.Font({ * name: "Arial.ttf", * callback: name => fetch(`https://example.com/${name}`).then(r => r.blob()) * }) * ``` * */ export declare type FontCallback = (fontName: string) => Promise; declare type FontSize = 'auto' | number; /** * Describes the fonts that you would like to substitute in a document and the fonts you would like to use for that substitution * * Patterns are matched using the following rules: * - `*` matches multiple characters. * - `?` matches a single character. * * **Ordering matters** - As names could match multiple patterns, it's important to note that the order of the patterns matters. * **Case-insensitive** - Both the pattern and the target name are case-insensitive. * * @summary An array of fonts to be substituted and the fonts to substitute them with * @example * Substitute all Noto fonts found in the document with AwesomeFont * ```ts * * const myFontsSubstitutions = [{ * pattern: "Noto*", * target: "AwesomeFont" * }] * * NutrientViewer.load({ * //... * fontSubstitutions: myFontsSubstitutions, * }) * ``` */ export declare type FontSubstitution = { /** The font you would like to be substituted. */ pattern: string; /** The font you would like to substitute the "from" font with. */ target: string; }; /** * @class * Form field type from which all form fields inherit. You can not instantiate from this type. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record}. * * To retrieve a list of all form fields, use {@link NutrientViewer.Instance#getFormFields}. * * Please see our {@link https://www.nutrient.io/guides/web/forms/introduction-to-forms/ | forms guide * article} to learn more about form fields and for examples on how to create them. * @example * Creating a form field. * ```ts * const widget = new NutrientViewer.Annotations.WidgetAnnotation({ * // Generate unique ID so it can be referenced in form field before the widget is created. * id: NutrientViewer.generateInstantId(), * pageIndex: 0, * formFieldName: 'form-field', * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 50, * top: 50, * width: 50, * height: 50, * }), * }); * const formField = new NutrientViewer.FormFields.TextFormField({ * name: 'form-field', * annotationIds: new NutrientViewer.Immutable.List([widget.id]), * }) * instance.create([widget, formField]); * ``` * * @public * @summary Base form field type from which all form fields inherit. * @see {@link NutrientViewer.Instance#create} | {@link NutrientViewer.Instance#delete} * @see {@link NutrientViewer.Instance#ensureChangesSaved} | {@link NutrientViewer.Instance#getFormFields} * @see {@link NutrientViewer.Instance#hasUnsavedChanges} | {@link NutrientViewer.Instance#save} * @see {@link NutrientViewer.Instance#update} * @see {@link Configuration#disableForms} | {@link NutrientViewer.EventName.FORM_FIELDS_LOAD} * @see {@link NutrientViewer.EventName.FORM_FIELDS_CHANGE} | {@link NutrientViewer.EventName.FORM_FIELDS_CREATE} * @see {@link NutrientViewer.EventName.FORM_FIELDS_UPDATE} | {@link NutrientViewer.EventName.FORM_FIELDS_DELETE} * @see {@link NutrientViewer.EventName.FORM_FIELDS_WILL_SAVE} | {@link NutrientViewer.EventName.FORM_FIELDS_DID_SAVE} * @see {@link NutrientViewer.EventName.FORMS_WILL_SUBMIT} | {@link NutrientViewer.EventName.FORMS_DID_SUBMIT} */ export declare class FormField extends FormField_base { /** * A unique identifier to describe the form field record. When a form field is created in the UI, the * viewer has to generate a unique ID. * * When changes are saved to the underlying form field provider, we call * {@link NutrientViewer.Instance#ensureChangesSaved} to make sure the form field has been persisted * from the provider. */ id: ID; /** * Unique name of the form field (often referred to as fully qualified name). This name is used * to link {@link NutrientViewer.Annotations.WidgetAnnotation} and is also used as an identifier for * form field values. */ name: FormFieldName; /** * The object ID of the form field object in the PDF. */ pdfObjectId: number; /** * Holds an immutable list of {@link NutrientViewer.Annotations.WidgetAnnotation#id}s. */ annotationIds: List; /** * Used to identify the form field in the UI or for accessibility. */ label: string; /** * Read only form fields can not be filled out (similar to disabled HTML input elements). * * @default false */ readOnly: boolean; /** * Required form fields must be filled out in order to submit the form. * * {@link NutrientViewer.FormFields.TextFormField}, {@link NutrientViewer.FormFields.ComboBoxFormField} and * {@link NutrientViewer.FormFields.ListBoxFormField} with this flag set will be rendered with * the [`PSPDFKit-Annotation-Widget-Required`](https://www.nutrient.io/guides/web/customizing-the-interface/css-customization/) public CSS class and the HTML `required` attribute set. * * @default false */ required: boolean; /** * Form fields with the `noExport` flag won't appear in the serialized payload of a form * submission. * * @default false */ noExport: boolean; /** * Optional actions to execute when an event is triggered. * * @default null * * TODO_RITESH: https://www.nutrient.io/api/web/NutrientViewer.FormFieldAdditionalActions.html */ additionalActions: FormFieldAdditionalActionsType | undefined | null; /** * This property is used to define the permission scope for this form-field, it's corresponding widget-annotations and form field values. If you change the `group` of a form field, the corresponding widget annotations and form field values will inherit it. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ group?: string | null; /** * This property defines whether this form-field can be edited or not. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly isEditable?: boolean; /** * This property defines whether this form-field can be filled or not. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly isFillable?: boolean; /** * This property defines whether this form field can be deleted or not. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly isDeletable?: boolean; /** * This property defines whether the user has permission to edit the group of this form field. * The value of this field depends on the set of collaboration permissions defined in the JWT token. * * It is only available when collaboration permissions is enabled on Server-Backed deployments. */ readonly canSetGroup?: boolean; constructor(args?: IFormField); } declare const FormField_base: Immutable.Record.Factory; /** @inline */ declare type FormFieldAdditionalActionsType = { /** * Execute an action when the value of the field changes. * * The name of this event in the PDF spec is `V` and can check the new value for validity. */ onChange?: Action; /** * Action to be performed to recalculate the value of a field. * * The name of this event in the PDF spec is `C`. */ onCalculate?: Action; } & WidgetAnnotationAdditionalActionsType; declare type FormFieldEventTriggerType = keyof FormFieldAdditionalActionsType; /** @inline */ declare type FormFieldFlags = Array<'readOnly' | 'required' | 'noExport'>; /** @inline */ declare type FormFieldInputAdditionalActionsType = FormFieldAdditionalActionsType & { /** * Action to be performed when the user types a key-stroke into a text field or combo box * or modifies the selection in a scrollable list box. * * The name of this event in the PDF spec is `K`. */ onInput?: Action; /** * Action to be performed before the field is formatted to display its current value. * * For signature form fields, this action will be executed when the form field * is digitally signed. * * The name of this event in the PDF spec is `F`. */ onFormat?: Action; }; declare type FormFieldInputEventTriggerType = keyof FormFieldInputAdditionalActionsType; /** @inline */ declare type FormFieldName = string; export declare namespace FormFields { export { FormField, ButtonFormField, CheckBoxFormField, ChoiceFormField, ComboBoxFormField, ListBoxFormField, RadioButtonFormField, TextFormField, SignatureFormField, UnknownFormField, serializeFormField as toSerializableObject, deserializeFormField as fromSerializableObject }; } /** * @class * Record representing a form field value. * * To retrieve a list of all form field values, use {@link Instance#getFormFieldValues}. * * Please see our {@link https://www.nutrient.io/guides/web/forms/introduction-to-forms/ | forms guide * article} to learn more about forms and for examples on how to set form field values. * @example * Setting a form field value. * ```ts * const formFieldValue = new FormFieldValue({ * name: 'Form field name', * value: 'Form field value' * }); * instance.update(formFieldValue); * ``` * * @summary Type representing a single form field value. * @see {@link Instance#update} * @see {@link Instance#setFormFieldValues} * @see {@link Instance#getFormFieldValues} */ export declare class FormFieldValue extends FormFieldValue_base { /** * Unique name of the form field (often referred to as fully qualified name). This name is used * to link form field value to a {@link FormFields.FormField}. */ name: string; /** * The value of the form field. */ value: string | Immutable.List | null; /** * Radio buttons and checkboxes can have multiple widgets with the same form value associated, but can be * selected independently. `optionIndexes` contains the value indexes that should be actually set. * * If set, the `value` field doesn't get used, and the widget found at the corresponding indexes in the form field's * `annotationIds` property are checked. * * If set on fields other than radio buttons or checkboxes, setting the form value will fail. */ optionIndexes?: Immutable.List; isFitting?: boolean; static defaultValues: IObject; constructor(args?: IObject); } declare const FormFieldValue_base: Immutable.Record.Factory<{ name?: string; value?: string | Immutable.List | number | null; optionIndexes?: Immutable.List; isFitting?: boolean; }>; /** * @class * A form option is used to identify all possible options for the following form field types: * * - {@link NutrientViewer.FormFields.CheckBoxFormField} * - {@link NutrientViewer.FormFields.ListBoxFormField} * - {@link NutrientViewer.FormFields.RadioButtonFormField} * - {@link NutrientViewer.FormFields.ComboBoxFormField} * * The index of the {@link WidgetAnnotation#id} in the * {@link FormField#annotationIds} property is used to find the option * for this widget annotation (the index is the same): * * ``` * const index = formField.annotationIds.findIndex(id => id === annotation.id); * const option = formField.options.get(index); * console.log(option.value); * ``` * @public * @summary Form field options */ export declare class FormOption extends FormOption_base {} declare const FormOption_base: Record_2.Factory<{ label: string; value: string; }>; /** * Defines specific configuration options related to forms. * * @summary Object containing configuration options for forms * @example * NutrientViewer.load({ * formsConfiguration: { * export: { disableComboBoxArrow: true } * } * }); */ export declare type FormsConfiguration = { export?: FormsConfigurationExport; }; /** * Defines configuration options regarding settings when exporting/saving a PDF. * * @summary Object containing configuration options for exporting/saving a PDF with forms. * @example * NutrientViewer.load({ * formsConfiguration: { * export: { disableComboBoxArrow: true } * } * }); */ export declare type FormsConfigurationExport = { /** * When true, disables writing the arrow button into the saved PDF. * * @default false */ disableComboBoxArrow?: boolean; }; declare function FormsMixin>(Base: T): { new (...args: any[]): { /** * Returns a {@link NutrientViewer.Immutable.List} of all {@link NutrientViewer.FormFields} for this * document. * * @example * instance.getFormFields().then(formFields => { * formFields.forEach(formField => { * console.log(formField.name); * }); * * // Filter form fields by type * formFields.filter(formField => ( * formField instanceof NutrientViewer.FormFields.TextFormField * )); * * // Get the total number of form fields * const totalFormFields = formFields.size; * }) * * @returns Resolves to a list of all form fields. */ getFormFields(): Promise>; /** * Returns a simplified object that contains all form fields currently loaded and maps to their values. This * object can be used to serialize form field values. * * Values can be of type `null`, `string`, or `Array.`. * * This method does not check if all the form fields have been loaded. If you want to make sure that * the all the document's form field values are retrieved, you have to make sure that the form fields * have been retrieved first. * * @example * await instance.getFormFields() * const formFieldValues = instance.getFormFieldValues(); * console.log(formFieldValues); // => { textField: 'Text Value', checkBoxField: ['A', 'B'], buttonField: null } * * @returns A simplified object that contains all form field values. */ getFormFieldValues(): Record>; /** * Updates the values of form fields. It's possible to update multiple form fields at once. * * The object must use the {@link NutrientViewer.FormFields.FormField#name} as a key and the * values must be of type `null`, `string`, or `Array.`. A `null` value will reset * the form field to either `null`, or its default value if available. * * This method returns a Promise that resolves when all the form fields have been updated, so * it should be awaited whenever you need to get or modify form fields immediately to ensure the form field * value is synchronized. * * @example * instance.setFormFieldValues({ * textField: "New Value", * checkBoxField: ["B", "C"], * }); * * @param formFieldValues - An object that contains the form field names that should be updated as keys and their value as values. * @returns Resolves when the values have been set. */ setFormFieldValues(formFieldValues: Record>): Promise; /** * You can programmatically modify the properties of the widget annotation and the associated form field just * before it is created via the form creator UI. * * @example * instance.setOnWidgetAnnotationCreationStart((annotation, formField) => { * return { annotation: annotation.set('opacity', 0.7) }; * }); * * @param callback - The callback to set the values of created form fields programmatically. */ setOnWidgetAnnotationCreationStart(callback: OnWidgetAnnotationCreationStartCallback): void; }; } & T; /** * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. * * If a `reviver` is optionally provided, it will be called with every * collection as a Seq (beginning with the most nested collections * and proceeding to the top-level collection itself), along with the key * referring to each collection and the parent JS object provided as `this`. * For the top level, object, the key will be `""`. This `reviver` is expected * to return a new Immutable Collection, allowing for custom conversions from * deep JS objects. Finally, a `path` is provided which is the sequence of * keys to this value from the starting value. * * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. * * If `reviver` is not provided, the default behavior will convert Objects * into Maps and Arrays into Lists like so: * * * ```js * const { fromJS, isKeyed } = require('immutable') * function (key, value) { * return isKeyed(value) ? value.toMap() : value.toList() * } * ``` * * `fromJS` is conservative in its conversion. It will only convert * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom * prototype) to Map. * * Accordingly, this example converts native JS data to OrderedMap and List: * * * ```js * const { fromJS, isKeyed } = require('immutable') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() * }) * * > "b", [ 10, 20, 30 ], [ "a", "b" ] * > "a", {b: [10, 20, 30]}, [ "a" ] * > "", {a: {b: [10, 20, 30]}, c: 40}, [] * ``` * * Keep in mind, when using JS objects to construct Immutable Maps, that * JavaScript Object properties are always strings, even if written in a * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * const { Map } = require('immutable') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" * * let map = Map(obj); * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined * ``` * * Property access for JavaScript Objects first converts the key to a string, * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. * * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter * "Using the reviver parameter" */ declare function fromJS( jsValue: any, reviver?: ( key: string | number, sequence: Collection.Keyed | Collection.Indexed, path?: Array) => any) : any; /** * Annotation deserializer. Converts an annotation object to a {@link AnnotationsUnion}. * * @param annotation - Serialized Annotation */ declare function fromSerializableObject(annotation: K): AnnotationJSONToAnnotation; /** * *Generates a new unique ID usable as an ID of annotation, formField, bookmark or comment. * * @returns A unique identifier. */ declare function generateInstantId(): InstantID; export declare namespace Geometry { export { Point, DrawingPoint, Rect, Size, Inset }; } /** * Returns the value within the provided collection associated with the * provided key, or notSetValue if the key is not defined in the collection. * * A functional alternative to `collection.get(key)` which will also work on * plain Objects and Arrays as an alternative for `collection[key]`. * * * ```js * const { get } = require('immutable') * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' * get({ x: 123, y: 456 }, 'x') // 123 * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' * ``` */ declare function get(collection: Collection, key: K): V | undefined; declare function get(collection: Collection, key: K, notSetValue: NSV): V | NSV; declare function get(record: Record_2, key: K, notSetValue: any): TProps[K]; declare function get(collection: Array, key: number): V | undefined; declare function get(collection: Array, key: number, notSetValue: NSV): V | NSV; declare function get(object: C, key: K, notSetValue: any): C[K]; declare function get(collection: {[key: string]: V;}, key: string): V | undefined; declare function get(collection: {[key: string]: V;}, key: string, notSetValue: NSV): V | NSV; /** @inline */ declare interface GetCommentsOptions { /** * Whether to include draft comments in the returned list. * * @default false */ includeDrafts?: boolean; } /** * Returns the value at the provided key path starting at the provided * collection, or notSetValue if the key path is not defined. * * A functional alternative to `collection.getIn(keypath)` which will also * work with plain Objects and Arrays. * * * ```js * const { getIn } = require('immutable') * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` */ declare function getIn(collection: any, keyPath: Iterable, notSetValue: any): any; declare type GetTypeFromAnnotationJSON = T extends { type: infer U; } ? U : never; /** * @class * PDF action to go to a destination (page) in the current document. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `action.set("pageIndex", 2);`. * * A GoToAction can define a different `pageIndex` in the same document. When clicking on it, we * will update the scroll position to make the page visible. We will not update the zoom level in * that case. * @example * Create a new GoToAction * ```ts * const action = new NutrientViewer.Actions.GoToAction({ pageIndex: 10 }); * ``` * * @summary Go to a destination (page) in the current document. */ export declare class GoToAction extends Action { /** * The page index of the page that should be made visible when triggering this action. * * `pageIndex` is zero-based and has a maximum value of `totalPageCount - 1`. */ pageIndex: number; constructor(options?: IGoToAction); } /** * @class * PDF action to go to an embedded file. This action is not implemented yet. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: * `action.set("relativePath", "/other_document.pdf");`. * @example * Create a new GoToEmbeddedAction * ```ts * const action = new NutrientViewer.Actions.GoToEmbeddedAction({ * relativePath: "/other_document.pdf" * }); * ``` * * @summary Go to an embedded file. */ export declare class GoToEmbeddedAction extends Action { /** * Should the file be opened in a new window? */ newWindow: boolean; /** * The relative path to the embedded file. */ relativePath: string; /** * The target type. Can either be `parent` or `child`. */ targetType: 'parent' | 'child'; constructor(args?: IGoToEmbeddedAction); } /** * @class * PDF action to go to a different (remote) file. This action is not implemented yet. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: * `action.set("relativePath", "/other_document.pdf");`. * @example * Create a new GoToRemoteAction * ```ts * const action = new NutrientViewer.Actions.GoToRemoteAction({ * relativePath: "/other_document.pdf" * }); * ``` * * @summary Go to a different (remote) file. */ export declare class GoToRemoteAction extends Action { /** * The relative path of the file to open. */ relativePath: string; /** * A named destination. */ namedDestination: string; constructor(options?: IGoToRemoteAction); } /** * Returns true if the key is defined in the provided collection. * * A functional alternative to `collection.has(key)` which will also work with * plain Objects and Arrays as an alternative for * `collection.hasOwnProperty(key)`. * * * ```js * const { has } = require('immutable') * has([ 'dog', 'frog', 'cat' ], 2) // true * has([ 'dog', 'frog', 'cat' ], 5) // false * has({ x: 123, y: 456 }, 'x') // true * has({ x: 123, y: 456 }, 'z') // false * ``` */ declare function has(collection: Object, key: any): boolean; /** * The `hash()` function is an important part of how Immutable determines if * two values are equivalent and is used to determine how to store those * values. Provided with any value, `hash()` will return a 31-bit integer. * * When designing Objects which may be equal, it's important that when a * `.equals()` method returns true, that both values `.hashCode()` method * return the same value. `hash()` may be used to produce those values. * * For non-Immutable Objects that do not provide a `.hashCode()` functions * (including plain Objects, plain Arrays, Date objects, etc), a unique hash * value will be created for each *instance*. That is, the create hash * represents referential equality, and not value equality for Objects. This * ensures that if that Object is mutated over time that its hash code will * remain consistent, allowing Objects to be used as keys and values in * Immutable.js collections. * * Note that `hash()` attempts to balance between speed and avoiding * collisions, however it makes no attempt to produce secure hashes. * * *New in Version 4.0* */ declare function hash(value: any): number; /** * Returns true if the key path is defined in the provided collection. * * A functional alternative to `collection.hasIn(keypath)` which will also * work with plain Objects and Arrays. * * * ```js * const { hasIn } = require('immutable') * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` */ declare function hasIn(collection: any, keyPath: Iterable): boolean; /** * @class * PDF action to hide an annotation or form field. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `action.set("hide", true);`. * * When clicking on an annotation with a `HideAction`, the annotations specified in its * `annotationReferences` property will be hidden. * @example * Create a new HideAction * ```ts * const action = new NutrientViewer.Actions.HideAction({ hide: true }); * ``` * * @summary Hide an annotation or form field. */ export declare class HideAction extends Action { /** * If `true`, the action will hide the annotation, otherwise it will show it. */ hide: boolean; /** * A list of references to annotations, either via the `pdfObjectId` or a form field name. */ annotationReferences: List; constructor(options?: IHideAction); } /** * @class * A highlight markup annotation. Please refer to {@link NutrientViewer.Annotations.MarkupAnnotation} for * more information. * *
* *
* @example * Create a highlight annotation * ```ts * var rects = NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 200, height: 10 }), * new NutrientViewer.Geometry.Rect({ left: 10, top: 25, width: 200, height: 10 }) * ]); * var annotation = new NutrientViewer.Annotations.HighlightAnnotation({ * pageIndex: 0, * rects: rects, * boundingBox: NutrientViewer.Geometry.Rect.union(rects) * }); * ``` * * @summary Highlight markup annotation. */ export declare class HighlightAnnotation extends TextMarkupAnnotation { /** * The blend mode defines how the color of the annotation will be applied to its background. * * @default "multiply" */ blendMode: IBlendMode; /** * The color of the highlight annotation. * * @default Color.LIGHT_YELLOW */ color: Color; static className: string; static readableName: string; } export declare class HighlightState extends HighlightState_base {} declare const HighlightState_base: Record_2.Factory; declare type Hints = { glyphs: Array; }; declare function HistoryMixin>(Base: T): { new (...args: any[]): { /** * The History API includes methods to undo and redo annotation operations: creation, * updates and deletions may be reverted and restored by means of this API. * * The implementation does not fully revert an annotation to its previous state: * - The `updatedAt` field will have changed to the current time. * - If an annotation deletion is undone, the restored annotation will have a different `id` * than the original. * - If an annotation deletion is undone, the restored annotation will appear at the front, * regardless of its original stacking position. * - Annotation changes that only affect the `updatedAt` property are not tracked, and the updated * annotation is considered identical to the previous one in this case. * - Newly created empty text annotations are not recorded in the history. This ensures that * accidental creation of such annotations, followed by pressing escape or clicking outside, * will not persist in the undo and redo history. * * The feature only accounts for annotations modified locally, wether using the API or the * toolbar Undo and Redo buttons. If an annotation is modified externally, by another Instant client, * for example, undoing will not revert the annotation state to the one just before the external change, * but to the previous to that one: external annotation operations are not undone, but * overridden. * * Annotation operations performed while the History API is disabled can also be considered external * for that effect. This is also the case for annotation operations that result from Instant Comments * changes, like deleting the last comment of a comment thread, which results on the comment marker * being deleted, and which cannot therefore be undone. * * However, comment markers directly deleted with the API may be restored with its former comments. * * {@link AnnotationPresets | Annotation presets} are not restored by undo and redo operations. * * @summary History namespace. */ history: { /** * When called, the last local annotation operation will be reverted. The outcome * will vary depending on the type of that operation: * * - Annotation creation: the annotation will be deleted. * - Annotation modification: the previous state of the annotation will be reverted. * - Annotation deletion: the annotation will be restored. * * Note that if a deleted annotation is restored by calling this function, it will * reappear in front of any other annotations, even if that was not its original stacking order. * * Returns `true` if the operation has been undone successfully, `false` if there are no * undoable operations available or the History API is disabled. * * @example * await instance.create(new NutrientViewer.Annotations.RectangleAnnotation({ * pageIndex: 0, * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 200, * top: 150, * width: 250, * height: 75 * }) * })); * console.log("Annotation created!"); * await instance.history.undo(); * console.log("Annotation creation undone: annotation deleted!"); * * @example * Undo all previous actions * ```ts * // Undo all previous actions * while (await instance.history.undo()) {} * ``` * * @returns The result of the undo operation. */ undo: () => boolean; /** * When called, the last undone annotation operation will be performed again. * * Note that if an annotation deletion has been undone, and then redone by calling this function, it will * reappear in front of any other annotations, even if that was not its original stacking order. * * Returns `true` if the operation has been redone successfully, `false` if there are no * redoable operations available or the History API is disabled. * * @example * await instance.create(new NutrientViewer.Annotations.RectangleAnnotation({ * pageIndex: 0, * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 200, * top: 150, * width: 250, * height: 75 * }) * })); * console.log("Annotation created!"); * await instance.delete(); * console.log("Annotation deleted!"); * await instance.history.undo(); * console.log("Annotation creation undone: annotation deleted!"); * await instance.history.redo(); * console.log("Annotation creation redone: annotation created!"); */ redo: () => boolean; /** * Returns `true` if it's possible to undo a previous operation, `false` otherwise, * also if the History API is disabled. */ canUndo: () => boolean; /** * Returns `true` if it's possible to redo a previously undone operation, `false` otherwise, * also if the History API is disabled. */ canRedo: () => boolean; /** * Removes all undoable and redoable operations available. * */ clear: () => void; /** * Enables the History API, making undoing and redoing possible. If there were previous undoable or * redoable operations, they will be now available. * */ enable: () => void; /** * Disables the History API: attempting to undo or redo previous operations with the API or the UI * will not be possible, but the previous undoable and redoable operations will be preserved, and * available if the History API is enabled again with {@link NutrientViewer.Instance#history}.enable. * */ disable: () => void; }; }; } & T; declare function I18nMixin>(Base: T): { new (...args: any[]): { /** * Sets the locale for the application. When setting a locale that doesn't exist it tries to * fall back to the parent locale when available. For example `en-US` falls back to `en`. * * See {@link NutrientViewer.I18n.locales} to get a list of all the available locales. * * @throws {Error} Will throw an error when the locale does not exist. * @param locale - The locale to set the app to. It must be one of {@link NutrientViewer.I18n.locales}. * @returns Returns a promise that resolves once the locale is set. */ setLocale(locale: string): Promise; /** * Returns the current locale for the application. * * @returns The current locale for the application. */ readonly locale: string; }; } & T; declare interface IAIComparisonOperationOptions extends IComparisonOperationOptions { operationType: IAIComparisonOperationType; categories?: string[]; } declare type IAIComparisonOperationType = (typeof AIComparisonOperationType)[keyof typeof AIComparisonOperationType]; declare type IAIComparisonPhase = (typeof AIComparisonPhase)[keyof typeof AIComparisonPhase]; /** @inline */ declare type IAlignment = ValueOf; declare type IAnnotationJSON = Omit; /** @inline */ declare type IAnnotationToolbarType = BuiltInAnnotationToolbarItem['type']; /** @inline */ declare type IAutoSaveMode = ValueOf; /** @inline */ declare type IBlendMode = ValueOf; /** @inline */ declare type IBorderStyle = ValueOf; /** @inline */ declare type ICallout = { start: Point | null; knee: Point | null; end: Point | null; cap: ILineCap | null; innerRectInset: Inset | null; }; /** @inline */ declare type ICollaboratorPermissionsOptions = { group?: IGroup; permissions?: IPermissions; }; /** @inline */ declare type ICommentDisplay = ValueOf; declare interface IComparisonOperation { type: IComparisonOperationType; options?: IComparisonOperationOptions; } declare interface IComparisonOperationOptions { [key: string]: any; } /** @inline */ declare type IComparisonOperationType = ValueOf; /** * @inline * */ declare interface IconAnnotationToolbarItem extends Omit { id: string; type: 'custom'; /** * Icon for the custom item. * * In case of mobile devices, the icon is displayed on the first level of the annotation toolbar. Once * you click on the icon, the `node` element opens on the second level. * * If you do not pass the `icon`, the node is present on the first level. */ icon?: string | Node; /** * The `custom` tool items can define a DOM node. * NutrientViewer renders this node instead of a standard tool button. * * In this case the tool item is rendered inside of a container * which gets the `title` and `className` attributes set. * * The `selected` and `disabled` are used just to toggle the * PSPDFKit-Tool-Node-active and PSPDFKit-Tool-Node-disabled * class names but making the node effectively selected or disabled is up to * the implementation of the item. * * The `onPress` event is registered and fires any time the item is either clicked * or tapped (on touch devices). */ node?: Node; } /** @inline */ declare type IConformance = ValueOf; /** @inline */ declare interface ICustomOverlayItem { disableAutoZoom?: boolean; id: CustomOverlayItemID | null; node: Node | null; noRotate?: boolean; pageIndex: number; position: Point; onAppear?: null | ((...args: Args) => void); onDisappear?: null | ((...args: Args) => void); } /** @inline */ declare type ID = string; /** @inline */ declare type ID_2 = string; /** @inline */ declare type IDocumentComparisonSourceType = ValueOf; /** @inline */ declare interface IDocumentDescriptor { filePath?: string | ArrayBuffer; password?: string; pageIndexes: Array; jwt?: string; } /** @inline */ declare type IDocumentOfficeFormat = ValueOf; /** @inline */ declare type IDocumentPermissions = ValueOf; /** @inline */ declare interface IDrawingPoint extends PointCtorProps { intensity?: number; } /** @inline */ declare type IElectronicSignatureCreationMode = ValueOf; /** @inline */ declare interface IEllipseAnnotation extends IShapeAnnotation { cloudyBorderIntensity?: number | null; cloudyBorderInset?: Inset | null; } /** @inline */ declare interface IEmbeddedFile { id: ID; attachmentId: string; description: null | string; fileName: null | string; fileSize: null | number; updatedAt: null | Date; } /** @inline */ declare interface IFont { name: string | null; callback: FontCallback | null; } /** @inline */ declare interface IFormField { id?: ID; pdfObjectId?: number | null; annotationIds?: List; name?: FormFieldName; label?: string; readOnly?: boolean; required?: boolean; noExport?: boolean; additionalActions?: any; group?: string | null; isEditable?: boolean; isFillable?: boolean; isDeletable?: boolean; canSetGroup?: boolean; [key: string]: any; } /** @inline */ declare type IFunction = (...args: any[]) => T; /** @inline */ declare interface IGoToAction extends ActionProperties { pageIndex?: number; } /** @inline */ declare interface IGoToEmbeddedAction extends ActionProperties { newWindow?: boolean; relativePath?: string; targetType?: 'parent' | 'child'; } /** @inline */ declare interface IGoToRemoteAction extends ActionProperties { relativePath?: string; namedDestination?: string; } declare type IGroup = string | null | undefined; /** @inline */ declare interface IHideAction extends ActionProperties { hide?: boolean; annotationReferences?: List; } /** @inline */ declare interface IHighlightAnnotation extends ITextMarkupAnnotation { color: Color; blendMode: IBlendMode | 'multiply'; } /** @inline */ declare interface IHighlightState { pageIndex: number; rectsOnPage: List; } /** @inline */ declare interface IImageAnnotation extends AnnotationProperties { description: string | null; fileName: string | null; contentType: string | null; imageAttachmentId: string | null; isSignature: boolean; xfdfAppearanceStream: string | null; xfdfAppearanceStreamOriginalPageRotation: number | null; } /** @inline */ declare interface IInkAnnotation extends AnnotationProperties { lines: List>; lineWidth: number | null; strokeColor: Color | null; backgroundColor: Color | null; isDrawnNaturally: boolean; isSignature: boolean; } /** @inline */ declare interface IInset { left: number; top: number; right: number; bottom: number; } /** @inline */ declare type IInteractionMode = ValueOf; /** @inline */ declare interface IJavaScriptAction extends ActionProperties { script?: string; } /** @inline */ declare interface ILaunchAction extends ActionProperties { filePath?: string; } /** @inline */ declare type ILayoutMode = ValueOf; /** @inline */ declare interface ILineAnnotation extends IShapeAnnotation { startPoint: Point | null; endPoint: Point | null; lineCaps: LineCapsType | null; points: List | null; } /** @inline */ declare type ILineCap = ValueOf; /** @inline */ declare interface ILinkAnnotation extends AnnotationProperties { action: Action | null; borderColor: Color | null; borderStyle: IBorderStyle | null; borderWidth: number | null; } /** * @class * Image annotations are images that are added to a PDF document. * * It is also possible to import the first page of a PDF by setting the * appropriate {@link ImageAnnotation#contentType | `contentType`}, * however the imported PDF won't include the annotations unless they are flattened in * advance. * @example * Create an image annotation * ```ts * const request = await fetch("https://example.com/image.jpg"); * const blob = await request.blob(); * const imageAttachmentId = await instance.createAttachment(blob); * const annotation = new NutrientViewer.Annotations.ImageAnnotation({ * pageIndex: 0, * contentType: "image/jpeg", * imageAttachmentId, * description: "Example Image Annotation", * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 10, * top: 20, * width: 150, * height: 150, * }), * }); * ``` * * @summary Display an image annotation, which represent an images in a PDF file. * @see {@link Instance#createAttachment} * @see {@link Instance#getAttachment} */ export declare class ImageAnnotation extends Annotation { /** * A description of the image content. */ description: null | string; /** * The file name of the attached file. */ fileName: null | string; /** * The content type of the connected attachment binary data. * * We currently support: * - `image/jpeg` * - `image/png` * - `application/pdf` */ contentType: string; /** * The attachment identifier of the image. It holds the image data as binary. */ imageAttachmentId: string; /** * The counter-clockwise rotation value in degrees relative to the rotated PDF page. Inserting an * annotation with a rotation value of `0` will make it appear in the same direction as the UI * appears, when no {@link ViewState#pagesRotation} is set. * * Can either be 0°, 90°, 180°, or 270°. Multiple or negative values are normalized to this * interval. * * @default 0 */ rotation: number; /** * When an image annotation is created via the signature UI, this flag is set to true. * * @default false */ isSignature: boolean; xfdfAppearanceStream: null | string; xfdfAppearanceStreamOriginalPageRotation: null | number; static readableName: string; } /** * @deprecated Use {@link Serializers.ImageAnnotationJSON} instead. * @hidden */ export declare type ImageAnnotationJSON = Serializers.ImageAnnotationJSON; declare class ImageAnnotationSerializer extends AnnotationSerializer { annotation: ImageAnnotation; constructor(annotation: ImageAnnotation); toJSON(): Serializers.ImageAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): ImageAnnotation; } declare interface IMauiBridge { initialize(webEventDispatcher: DotNetObject): void; addAdvanceAccessScript(path: string): Promise; loadDocumentFromPath(path: string, viewerConfigurationJson: string): Promise; loadDocumentFromBase64String(fileContentAsBase64String: string, viewerConfigurationJson: string): Promise; loadDocumentFromStream(streamReference: DotNetDisposableStreamReference, viewerConfigurationJson: string): Promise; loadDocumentFromBuffer(documentBuffer: Uint8Array, viewerConfigurationJson: string): Promise; setMainToolbarItems(toolbarItems: string): void; setAnnotationToolbarItems(annotationType: string, toolbarItems: string): void; setViewState(propertyName: keyof IViewState, value: object): void; exportDocument(configurationJSON: string): Promise; unload(): void; applyRedactions(): void; createAnnotation(annotationJson: string): Promise; deleteAnnotations(annotationIdsJson: string): void; flattenAnnotations(pageIndices: number[]): Promise; getAnnotations(pageIndex: number): Promise; setSelectedAnnotations(annotationIdsJson: string): void; updateAnnotation(annotationJson: string): void; subscribeToEvent(event: string): void; unsubscribeFromEvent(event: string): void; showDocumentLoadingIndicator(): void; showGenericProcessingIndicator(): void; hideGenericProcessingIndicator(): void; } /** @inline */ declare type IMeasurementPrecision = ValueOf; /** @inline */ declare interface IMeasurementScale { unitFrom: IMeasurementScaleUnitFrom; unitTo: IMeasurementScaleUnitTo; fromValue: number; toValue: number; fromDescription?: string; toDescription?: string; } /** @inline */ declare type IMeasurementScaleUnitFrom = ValueOf; /** @inline */ declare type IMeasurementScaleUnitTo = ValueOf; /** @inline */ declare interface IMediaAnnotation extends AnnotationProperties { description: null | string; fileName: null | string; contentType: string | null; mediaAttachmentId: string | null; } declare namespace Immutable { export { List, Map_2 as Map, OrderedMap, Set_2 as Set, OrderedSet, Stack, Range_2 as Range, Repeat, Record_2 as Record, Seq, Collection, fromJS, is, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject, isSeq, isList, isMap, isOrderedMap, isStack, isSet, isOrderedSet, isRecord, get, has, remove, set, update, getIn, hasIn, removeIn, setIn, updateIn, merge, mergeWith, mergeDeep, mergeDeepWith, RecordOf, ValueObject }; } export declare namespace Immutable_2 { export { List, Set_2 as Set, Map_2 as Map }; } /** @inline */ declare type IModificationType = ValueOf; /** @inline */ declare type ImportPageIndex = Array; /** @inline */ declare interface INamedAction extends ActionProperties { action?: string; } declare const InheritableImmutableRecord: new >(values?: Partial | Iterable<[string, unknown]>) => __dangerousImmutableRecordFactory; /** * @class * Ink annotations are used for free hand drawings on a page. They can contain multiple segments * (see the definition of `lines` below). Points within the same segment are connected to a line. * * Ink annotations are only selectable around their visible lines. This means that you can create a * page full of line annotations while annotations behind the ink annotation are still selectable. * * Right now, ink annotations are implemented using SVG images. This behavior is object to change. * *
* * *
* @example * Create an ink annotation that displays a cross * ```ts * const annotation = new NutrientViewer.Annotations.InkAnnotation({ * pageIndex: 0, * lines: NutrientViewer.Immutable.List([ * NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.DrawingPoint({ x: 5, y: 5 }), * new NutrientViewer.Geometry.DrawingPoint({ x: 95, y: 95}), * ]), * NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.DrawingPoint({ x: 95, y: 5 }), * new NutrientViewer.Geometry.DrawingPoint({ x: 5, y: 95}), * ]) * ]), * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 0, * top: 0, * width: 100, * height: 100, * }), * }); * ``` * * @public * @summary Display free hand drawings on a page. * @param args - An object of the members. * @see {@link Instance#getInkSignatures} | {@link Instance#setInkSignatures} * @see {@link Configuration#populateInkSignatures} * @see {@link NutrientViewer.EventName.INK_SIGNATURES_CREATE} | {@link NutrientViewer.EventName.INK_SIGNATURES_CHANGE} * @see {@link NutrientViewer.EventName.INK_SIGNATURES_UPDATE} | {@link NutrientViewer.EventName.INK_SIGNATURES_DELETE} */ export declare class InkAnnotation extends Annotation { /** * A list of line segments. Every segment consists again of a list of points with additional * intensity information. * * The two nested lists are required since one ink annotation can consist of multiple lines. * Within one segment, points will be connected using lines or curves. * * We use {@link NutrientViewer.Geometry.DrawingPoint} for an additional intensity value (usually * the pressure of a pointer device) that is used to reconstruct the naturally drawn image. If a * device without intensity is used, the default intensity of `0.5` will be used. * * If no lines are present, the annotation will not be visible. * * @default NutrientViewer.Immutable.List() Empty list */ lines: List>; /** * The blend mode defines how the color of the annotation will be applied to its background. * * @default "normal" */ blendMode: IBlendMode; /** * The width of the lines in page size pixels. Per default, we use values between 1 and 40 in * the UI. * * The line width will scale when you zoom in. * * @default 5 */ lineWidth: number; /** * A {@link NutrientViewer.Color} for the visible line * * @default Color.BLUE */ strokeColor: Color | null; /** * Optional background color that will fill the complete bounding box. * * @default null */ backgroundColor: Color | null; /** * NutrientViewer's Natural Drawing mode. This value will currently not effect rendering on NutrientViewer * for Web. * * @default false */ isDrawnNaturally: boolean; /** * When an ink annotation is created via the signature UI, this flag is set to true. * * @default false */ isSignature: boolean; static readableName: string; } /** * @deprecated Use {@link Serializers.InkAnnotationJSON} instead. * @hidden */ export declare type InkAnnotationJSON = Serializers.InkAnnotationJSON; declare class InkAnnotationSerializer extends AnnotationSerializer { annotation: InkAnnotation; constructor(annotation: InkAnnotation); toJSON(): Serializers.InkAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): InkAnnotation; _linesToJSON(): { points: Array>; intensities: Array>; }; static _JSONToLines(linesJSON: { points: Array>; intensities: Array>; }): List>; } declare const InkEraserMode: { /** Individual points of the ink annotation are removed as they're touched. This is the default mode. */ readonly POINT: "POINT"; /** Whole strokes of the ink annotation are removed as they're touched. */ readonly STROKE: "STROKE"; }; export declare type InlineTextSelectionToolbarItem = Omit & { type: InlineToolbarType | 'custom'; }; /** * This callback can be run on specific text selection to modify its inline toolbar items. Nutrient Web SDK comes with a built-in toolbar that shows whenever some text is selected on a document, we will refer to said tooltip as inline toolbar from now on. * This callback allows users to customize said inline toolbar. * * @param options - The object that can be helpful in implementing custom toolbar. * @param selection - The reference to the text that is currently selected. */ export declare type InlineTextSelectionToolbarItemsCallback = (options: { /** The list of default items that are shown for this particular annotation. */ defaultItems: InlineTextSelectionToolbarItem[]; /** Whether the screen is in desktop layout. */ hasDesktopLayout: boolean; }, selection: TextSelection_2) => InlineTextSelectionToolbarItem[]; declare type InlineToolbarType = (typeof builtInItems)[number]; /** @inline */ declare interface INoteAnnotation extends AnnotationProperties { text: { format: 'plain'; value: string; }; icon: string | INoteIcon; color: Color; } /** @inline */ declare type INoteIcon = ValueOf; /** * An inset describes a rectangle by enumerating the distance from each side to the corresponding * side of a reference rectangle. Therefore it does not hold coordinates, nor dimensions, only * relative values for `left`, `top`, `right` and `bottom`. Provided values are defined in same units * used by the page, point units. Point units are only equal to pixels when zoom value is `1`. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `inset.set("right", 15)`. * * @example * Create and update an inset. * ```ts * const inset = new NutrientViewer.Geometry.Inset({ * left: 5, * top: 15, * right: 10, * bottom: 5 * }); * inset = inset.set("bottom", 7); * rect.bottom; // => 7 * ``` * * @public * @summary A relative rectangle inset in 2D space. * @param args - An object used to initialize the Point. If `left`, `top`, `right` or `bottom` * is omitted, `0` will be used instead. * @default { left: 0, top: 0, right: 0, bottom: 0 } */ export declare class Inset extends Inset_base { /** * Returns a new Rect by adding the provided inset values to the provided Rect. * * @example * const rect = NutrientViewer.Geometry.Inset.applyToRect( * rectangleAnnotation.cloudyBorderInset, * rectangleAnnotation.boundingBox * ); * * @param inset - An Inset instance. * @param rect - A Rect instance. * @returns A new `Rect`. */ static applyToRect(inset: Inset, rect: Rect): Rect; static fromRect(rect: Rect): Inset; /** * Returns a new inset using the provided vale for all properties. * * @example * const inset = NutrientViewer.Geometry.Inset.fromValue(10); * // inset -> * // { * // left: 10, * // top: 10, * // right: 10, * // bottom: 10, * // } * * @param insetValue - An inset value to be applied to all the properties. * @returns A new `Inset`. */ static fromValue(insetValue: number): Inset; /** * Applies a transformation to the inset. We will transform * each of the corners represented by the inset and then * find the max and min values to generate the resulting * inset. */ apply(matrix: TransformationMatrix): Inset; /** * Returns a new inset with the provided scale applied to all properties. * * @param scale - The scale to apply to the inset. */ setScale(scale: number): Inset; } declare const Inset_base: Record_2.Factory; /** @inline */ declare type InsetJSON = [left: number, top: number, right: number, bottom: number]; /** * A mounted document instance. * * You can generate an instance by using {@link NutrientViewer.load}. * * @summary A mounted document instance. * @public * @hideconstructor */ export declare class Instance extends Instance_base { constructor(config: any); } export declare interface Instance extends BaseMixin, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType>, InstanceType> { } declare const Instance_base: any; declare type Instant = { public: boolean; }; /** * @class * An InstantClient describes a single connection of a given user with the server. * * This class is only available if you have a valid Nutrient Instant license. * * You can retrieve an instance of InstantClient by using {@link Instance#connectedClients}. * @summary A single Instant connection. * @hideconstructor * @public * @server */ export declare class InstantClient { /** * A unique ID string for every connected client. It does not persist across client reconnects. * * @server * */ readonly clientId: string; /** * A user ID of the client. This ID is supplied by your backend. If the value is `null`, the client is considered anonymous. * * @server * */ userId: string | null | undefined; } /** @inline */ declare type InstantID = string; declare type InstantID_2 = InstantID; export declare interface InstantJSON extends SerializedJSON { format: 'https://pspdfkit.com/instant-json/v1'; pdfId?: { permanent: string; changing: string; }; } /** * Controls the current interaction mode in the viewer. * * @enum */ declare const InteractionMode: { /** When this mode is activated, the creation of new highlight annotations will be enabled and the text will be highlighted as it's selected. */ readonly TEXT_HIGHLIGHTER: "TEXT_HIGHLIGHTER"; /** When this mode is activated, the creation of new ink annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created. */ readonly INK: "INK"; /** When this mode is activated, the creation of new ink signatures will be enabled. This shows a dialog where it is possible to select an existing ink signature or create a new one and store it. */ readonly INK_SIGNATURE: "INK_SIGNATURE"; /** When this mode is activated, the creation of new signatures will be enabled. This shows a dialog where it is possible to select an existing signature or create a new one and potentially save it. */ readonly SIGNATURE: "SIGNATURE"; /** When this mode is activated, the stamp annotation templates picker modal UI will be shown. Once a template is selected, the new annotation is configured and created\ in the document. */ readonly STAMP_PICKER: "STAMP_PICKER"; /** When this mode is activated, the custom stamp annotation template editor modal UI will be shown. Once a the custom template is edited, the new custom stamp annotation will be created in the document. */ readonly STAMP_CUSTOM: "STAMP_CUSTOM"; /** When this mode is activated, the creation of new line annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. */ readonly SHAPE_LINE: "SHAPE_LINE"; /** When this mode is activated, the creation of new rectangle annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. */ readonly SHAPE_RECTANGLE: "SHAPE_RECTANGLE"; /** When this mode is activated, the creation of new ellipse annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created. */ readonly SHAPE_ELLIPSE: "SHAPE_ELLIPSE"; /** When this mode is activated, the creation of new polygon annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created. */ readonly SHAPE_POLYGON: "SHAPE_POLYGON"; /** When this mode is activated, the creation of new polyline annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created. */ readonly SHAPE_POLYLINE: "SHAPE_POLYLINE"; /** When this mode is activated, removing of current ink annotation points will be enabled. This transforms the page to a canvas where the cursor can remove ink annotation points by hand, as well as choose the cursor width. */ readonly INK_ERASER: "INK_ERASER"; /** When this mode is activated, the creation of new note annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click. */ readonly NOTE: "NOTE"; /** When this mode is activated, the creation of new comment marker annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click. */ readonly COMMENT_MARKER: "COMMENT_MARKER"; /** When this mode is activated, the creation of new text annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click. */ readonly TEXT: "TEXT"; /** When this mode is activated, the creation of new callout annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click. */ readonly CALLOUT: "CALLOUT"; /** This enables the pan tool to allow the user to navigate on a desktop browser using mouse dragging. This will disable text selection. */ readonly PAN: "PAN"; /** Enables the search mode and focuses the search input field. */ readonly SEARCH: "SEARCH"; /** This shows the document editor modal. */ readonly DOCUMENT_EDITOR: "DOCUMENT_EDITOR"; /** This enables the Marquee Zoom tool. When enabled, you can draw a rectangle on the screen which is zoomed into and scrolled to, once the pointer is released. */ readonly MARQUEE_ZOOM: "MARQUEE_ZOOM"; /** When this mode is activated, the creation of new redaction annotations will be enabled by highlighting regions of text and the text will be marked for redaction as it's selected. */ readonly REDACT_TEXT_HIGHLIGHTER: "REDACT_TEXT_HIGHLIGHTER"; /** When this mode is activated, the creation of new redaction annotations will be enabled by drawing rectangles on the pages. This transforms the page to a drawable canvas and annotations are created while drawing on it. */ readonly REDACT_SHAPE_RECTANGLE: "REDACT_SHAPE_RECTANGLE"; /** When this mode is activated, the creation of cropping area selection is enabled. */ readonly DOCUMENT_CROP: "DOCUMENT_CROP"; /** When this mode is activated, the creation of button widget annotations is enabled. */ readonly BUTTON_WIDGET: "BUTTON_WIDGET"; /** When this mode is activated, the creation of text widget annotations is enabled. */ readonly TEXT_WIDGET: "TEXT_WIDGET"; /** When this mode is activated, the creation of radio button widget annotations is enabled. */ readonly RADIO_BUTTON_WIDGET: "RADIO_BUTTON_WIDGET"; /** When this mode is activated, the creation of checkbox widget annotations is enabled. */ readonly CHECKBOX_WIDGET: "CHECKBOX_WIDGET"; /** When this mode is activated, the creation of combo box widget annotations is enabled. */ readonly COMBO_BOX_WIDGET: "COMBO_BOX_WIDGET"; /** When this mode is activated, the creation of list box widget annotations is enabled. */ readonly LIST_BOX_WIDGET: "LIST_BOX_WIDGET"; /** When this mode is activated, the creation of signature widget annotations is enabled. */ readonly SIGNATURE_WIDGET: "SIGNATURE_WIDGET"; /** When this mode is activated, the creation of date widget annotations is enabled. */ readonly DATE_WIDGET: "DATE_WIDGET"; /** When this mode is activated, you will be able to edit and create widget annotations. */ readonly FORM_CREATOR: "FORM_CREATOR"; /** When this mode is activated, you will be able to create link annotations. */ readonly LINK: "LINK"; /** When this mode is activated, you will be able to create distance annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it. */ readonly DISTANCE: "DISTANCE"; /** When this mode is activated, you will be able to create perimeter annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it. */ readonly PERIMETER: "PERIMETER"; /** When this mode is activated, you will be able to create Rectangle Area annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it. */ readonly RECTANGLE_AREA: "RECTANGLE_AREA"; /** When this mode is activated, you will be able to create Ellipse Area annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it. */ readonly ELLIPSE_AREA: "ELLIPSE_AREA"; /** When this mode is activated, you will be able to create Polygon Area annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it. */ readonly POLYGON_AREA: "POLYGON_AREA"; /** Available only in Standalone mode with the content editor license: when this mode is activated, you will be able to edit the page contents. */ readonly CONTENT_EDITOR: "CONTENT_EDITOR"; /** When this mode is activated, multiple annotations can be selected with the UI. */ readonly MULTI_ANNOTATIONS_SELECTION: "MULTI_ANNOTATIONS_SELECTION"; /** Available only with the measurement license: when this mode is activated, the measurement annotations mode will be activated. */ readonly MEASUREMENT: "MEASUREMENT"; /** Available only with the measurement license: when this mode is activated, the measurement settings mode will be activated. */ readonly MEASUREMENT_SETTINGS: "MEASUREMENT_SETTINGS"; /** When this mode is activated, the attachment preview mode will be activated. */ readonly ATTACHMENT_PREVIEW: "ATTACHMENT_PREVIEW"; }; export declare type Interfaces = Record; declare type Intersection = T extends U ? T : never; /** @inline */ declare type IObject = Record; /** @inline */ declare type IPermissions = { edit: boolean; delete: boolean; setGroup: boolean; fill?: boolean; reply?: boolean; }; /** @inline */ declare interface IPolygonAnnotation extends IShapeAnnotation { points: List | null; cloudyBorderIntensity: number | null; } /** @inline */ declare interface IPolyLineAnnotation extends IShapeAnnotation { points: List | null; lineCaps: LineCapsType | null; } /** @inline */ declare type IPrintMode = ValueOf; /** @inline */ declare type IPrintQuality = ValueOf; /** @inline */ declare type IProcessorEngine = ValueOf; /** @inline */ declare type IProductId = (typeof ProductId)[keyof typeof ProductId]; /** @inline */ declare interface IRect { left?: number; top?: number; width?: number; height?: number; } /** @inline */ declare interface IRectangleAnnotation extends IShapeAnnotation { cloudyBorderIntensity?: number | null; cloudyBorderInset?: Inset | null; } /** @inline */ declare type IRectJSON = [left: number, top: number, width: number, height: number]; /** @inline */ declare interface IRedactionAnnotation extends ITextMarkupAnnotation { color: Color; fillColor: null | Color; overlayText: null | string; repeatOverlayText: null | boolean; outlineColor: null | Color; fontSize: null | number; } /** @inline */ declare interface IResetFormAction extends ActionProperties { fields?: List | null | undefined; includeExclude?: boolean; } /** * Value equality check with semantics similar to `Object.is`, but treats * Immutable `Collection`s as values, equal if the second `Collection` includes * equivalent values. * * It's used throughout Immutable when checking for equality, including `Map` * key equality and `Set` membership. * * * ```js * const { Map, is } = require('immutable') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) * assert.equal(Object.is(map1, map2), false) * assert.equal(is(map1, map2), true) * ``` * * `is()` compares primitive types like strings and numbers, Immutable.js * collections like `Map` and `List`, but also any custom object which * implements `ValueObject` by providing `equals()` and `hashCode()` methods. * * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same * value, matching the behavior of ES6 Map key equality. */ declare function is(first: any, second: any): boolean; /** * Type guard to determine if a result is an AIDocumentAnalysisResult * This helper checks if the result comes from an "analyze" operation (AIADocumentChangesAnalysisResponse). * * @param result - The result to check * @returns Whether the result is an AI document analysis result * @example * if (NutrientViewer.isAIDocumentAnalysisResult(result)) { * console.log('AI Summary:', result.summary); * console.log('Categories:', result.categories); * } */ declare function isAIDocumentAnalysisResult(result: DocumentComparison.DocumentComparisonResult | AIDocumentComparisonResult): result is AIADocumentChangesAnalysisResponse; /** * Type guard to determine if a result is an AIDocumentComparisonResult * This helper checks if the result comes from any AI-powered comparison operation * (either "analyze" or "tag" operation types). * * @param result - The result to check * @returns Whether the result is an AI document comparison result * @example * if (NutrientViewer.isAIDocumentComparisonResult(result)) { * // Result is from AI comparison - could be analysis or tagging * if (NutrientViewer.isAIDocumentAnalysisResult(result)) { * console.log('AI Analysis Result:', result.summary); * } else if (NutrientViewer.isAIDocumentTaggingResult(result)) { * console.log('AI Tagging Result:', result.references); * } * } */ declare function isAIDocumentComparisonResult(result: DocumentComparison.DocumentComparisonResult | AIDocumentComparisonResult): result is AIDocumentComparisonResult; /** * Type guard to determine if a result is an AIDocumentTaggingResult * Checks if the result is from a "tag" operation (AIADocumentChangesTaggingResponse). * * @param result - The result to check * @returns Whether the result is an AI document tagging result * @example * if (NutrientViewer.isAIDocumentTaggingResult(result)) { * console.log('Tagged references:', result.references); * } */ declare function isAIDocumentTaggingResult(result: unknown): result is AIADocumentChangesTaggingResponse; /** * True if `maybeAssociative` is either a Keyed or Indexed Collection. * * * ```js * const { isAssociative, Map, List, Stack, Set } = require('immutable'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true * isAssociative(List()); // true * isAssociative(Stack()); // true * isAssociative(Set()); // false * ``` */ declare function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** * True if `maybeCollection` is a Collection, or any of its subclasses. * * * ```js * const { isCollection, Map, List, Stack } = require('immutable'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true * isCollection(List()); // true * isCollection(Stack()); // true * ``` */ declare function isCollection(maybeCollection: any): maybeCollection is Collection; /** @inline */ declare type IScrollMode = ValueOf; /** @inline */ declare type ISearchPattern = ValueOf; /** @inline */ declare type ISearchType = ValueOf; /** * This callback defines which annotations are read-only. This callback will receive the Annotation * a user wants to modify and by returning `true` or `false` you can define if the annotation should * be read-only (`false`) or modifiable (`true`). * * For more information, see {@link Configuration#isEditableAnnotation}. * * @public * @param annotation - The annotation. * @example * Only allow the modification of annotations from the same author * ```ts * NutrientViewer.load({ * isEditableAnnotation: function(annotation) { * return annotation.creatorName === myCurrentUser.name; * }, * }); * ``` * */ export declare type IsEditableAnnotationCallback = (annotation: AnnotationsUnion) => boolean; /** * This callback can be run on individual comments to detect whether the comment * can be edited based on its returned boolean. * * For more information, see {@link Configuration#isEditableComment} * * @public * @param comment - The comment. * @example * Only allow the modification of comment from the same author. * ```ts * NutrientViewer.load({ * isEditableComment: function(comment) { * return comment.creatorName === myCurrentUser.name; * }, * }); * ``` * */ export declare type IsEditableCommentCallback = (comment: Comment_2) => boolean; /** @inline */ declare interface IShapeAnnotation extends AnnotationProperties { strokeDashArray: [number, number] | null; strokeWidth: number | null; strokeColor: Color | null; fillColor: Color | null; measurementScale: MeasurementScale | null; measurementPrecision: IMeasurementPrecision | null; } /** @inline */ declare type IShowSignatureValidationStatusMode = ValueOf; /** @inline */ declare type ISidebarMode = ValueOf | (string & object); /** @inline */ declare type ISidebarPlacement = ValueOf; /** @inline */ declare type ISignatureAppearanceMode = ValueOf; /** @inline */ declare type ISignatureSaveMode = ValueOf; /** * True if `maybeImmutable` is an Immutable Collection or Record. * * Note: Still returns true even if the collections is within a `withMutations()`. * * * ```js * const { isImmutable, Map, List, Stack } = require('immutable'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true * isImmutable(List()); // true * isImmutable(Stack()); // true * isImmutable(Map().asMutable()); // true * ``` */ declare function isImmutable(maybeImmutable: any): maybeImmutable is Collection; /** * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. * * * ```js * const { isIndexed, Map, List, Stack, Set } = require('immutable'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false * isIndexed(List()); // true * isIndexed(Stack()); // true * isIndexed(Set()); // false * ``` */ declare function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. * * * ```js * const { isKeyed, Map, List, Stack } = require('immutable'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true * isKeyed(List()); // false * isKeyed(Stack()); // false * ``` */ declare function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** * True if `maybeList` is a List. */ declare function isList(maybeList: any): maybeList is List; /** * True if `maybeMap` is a Map. * * Also true for OrderedMaps. */ declare function isMap(maybeMap: any): maybeMap is Map_2; /** * True if `maybeOrdered` is a Collection where iteration order is well * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. * * * ```js * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false * isOrdered(OrderedMap()); // true * isOrdered(List()); // true * isOrdered(Set()); // false * ``` */ declare function isOrdered(maybeOrdered: any): boolean; /** * True if `maybeOrderedMap` is an OrderedMap. */ declare function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; /** * True if `maybeOrderedSet` is an OrderedSet. */ declare function isOrderedSet(maybeOrderedSet: any): maybeOrderedSet is OrderedSet; /** @inline */ declare interface ISquiggleAnnotation extends ITextMarkupAnnotation { color: Color; } /** * True if `maybeRecord` is a Record. */ declare function isRecord(maybeRecord: any): maybeRecord is Record_2; /** * True if `maybeSeq` is a Seq. */ declare function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed | Seq.Keyed | Seq.Set; /** * True if `maybeSet` is a Set. * * Also true for OrderedSets. */ declare function isSet(maybeSet: any): maybeSet is Set_2; /** * True if `maybeStack` is a Stack. */ declare function isStack(maybeStack: any): maybeStack is Stack; /** @inline */ declare interface IStampAnnotation extends AnnotationProperties { stampType: string | StampKind | null; title: string | null; subtitle: string | null; color: Color | null; multiline: boolean | null; font: string | null; fontSize: number | null; fontColor: Color | null; isBold: boolean | null; isItalic: boolean | null; imageAttachmentId: string | null; imageContentType: string | null; imagePosition: { row: number; align: 'left' | 'center' | 'right'; } | null; xfdfAppearanceStream: string | null; xfdfAppearanceStreamOriginalPageRotation: number | null; } /** @inline */ declare interface IStrikeOutAnnotation extends ITextMarkupAnnotation { color: Color; } /** @inline */ declare interface ISubmitFormAction extends ActionProperties { uri?: string; fields?: List; includeExclude?: boolean; includeNoValueFields?: boolean; exportFormat?: boolean; getMethod?: boolean; submitCoordinated?: boolean; xfdf?: boolean; includeAppendSaves?: boolean; includeAnnotations?: boolean; submitPDF?: boolean; canonicalFormat?: boolean; excludeNonUserAnnotations?: boolean; excludeFKey?: boolean; embedForm?: boolean; } /** * True if `maybeValue` is a JavaScript Object which has *both* `equals()` * and `hashCode()` methods. * * Any two instances of *value objects* can be compared for value equality with * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. */ declare function isValueObject(maybeValue: any): maybeValue is ValueObject; declare type ItemCustomRenderer = (itemRendererProps: ItemRendererProps) => void; declare type ItemRendererProps = { itemContainerNode: Node; item: any; }; /** @inline */ declare interface ITextAnnotation extends AnnotationProperties { text: { format: 'plain' | 'xhtml'; value: string | null; }; fontColor: Color | null; backgroundColor: Color | null; font: string; fontSize: number | null; isBold: boolean | null; isItalic: boolean | null; isUnderline: boolean | null; horizontalAlign: 'left' | 'center' | 'right'; verticalAlign: 'top' | 'center' | 'bottom'; callout: Callout | null; borderStyle: IBorderStyle | null; borderWidth: number | null; borderColor: Color | null; isFitting: boolean; lineHeightFactor: number | null; } /** @inline */ declare interface ITextComparisonOperationOptions extends IComparisonOperationOptions { numberOfContextWords?: number; wordLevel?: boolean; } /** @inline */ declare interface ITextLine { /** An ID that is unique inside one page to reference the text line across the document. */ id: number | null; /** * The page index on which the text line is placed. * * `pageIndex` is zero-based and has a maximum value of `totalPageCount - 1`. */ pageIndex: number | null; /** Position of this text line on the page. */ boundingBox: Rect; /** * Content of the text line. * * Text lines end with CRLF (`\r\n`). */ contents: string; /** Hints for the text line. */ hints: Hints | null; } /** @inline */ declare interface ITextMarkupAnnotation extends AnnotationProperties { rects: List; color: Color; blendMode: IBlendMode; } /** @inline */ declare interface ITextRange { startNode: Text | null; startOffset: number | null; endNode: Text | null; endOffset: number | null; } /** @inline */ declare interface ITextSelection { startNestedContentBlockId: string | null; startTextLineId: number | null; startPageIndex: number | null; startNode: Text | null; startOffset: number | null; endNestedContentBlockId: string | null; endTextLineId: number | null; endPageIndex: number | null; endNode: Text | null; endOffset: number | null; getText: (() => Promise) | null; getSelectedTextLines: (() => Promise>) | null; getBoundingClientRect: (() => Promise) | null; getSelectedRectsPerPage: (() => Promise; }>>) | null; } /** @inline */ declare interface ITextSelection_2 { textRange: TextRange | null; startTextLineId: number | null; endTextLineId: number | null; startNestedContentBlockId: string | null; endNestedContentBlockId: string | null; startPageIndex: number | null; endPageIndex: number | null; } /** @inline */ declare type ITheme = ValueOf; /** @inline */ declare type IToolbarPlacement = ValueOf; /** @inline */ declare type IUIDateTimeElement = ValueOf; /** @inline */ declare type IUIElement = ValueOf; /** @inline */ declare interface IUnderlineAnnotation extends ITextMarkupAnnotation { color: Color; } /** @inline */ declare interface IURIAction extends ActionProperties { uri?: string; } /** @inline */ declare interface IViewState { /** * Control whether or not the printing button in the toolbar should be disabled. If the user has * insufficient permissions, the feature will automatically be disabled. * * This feature requires the `download` permission in the JWT, because on some browsers we have to * fall back to downloading the PDF in order to allow performant printing. * * It is possible to remove the print button with the {@link Instance#setToolbarItems Toolbar API}. * * @default true */ allowPrinting: boolean; /** * Control whether or not the export PDF button in the toolbar should be disabled. If the user has * insufficient permissions, the feature will automatically be disabled. * * This feature requires the `download` permission in the JWT. * * It is possible to remove the export PDF button with the {@link Instance#setToolbarItems Toolbar API}. * * @default true */ allowExport: boolean; /** * The page index of the page that's currently visible. If there is more than one page visible * this will return the page that is using the most space in the viewport. The `pageIndex` is * zero-based and has a maximum value of `totalPageCount - 1`. * * @default 0 */ currentPageIndex: number; /** * An optional reference to a mounted {@link Instance}. This is required to call the * following methods on {@link ViewState}: * * - `{@link ViewState#zoomIn}` * - `{@link ViewState#zoomOut}` * - `{@link ViewState#nextZoomLevel}` */ instance: Instance | null; /** * Controls the current interaction mode in the viewer. When this value is changed, we will make * sure that the state is properly transformed. * * If, for example, the user is currently creating an ink annotation and you change this value to * `InteractionMode.TEXT`, we will delete the current in-memory ink annotation. * * For a list of all available mode, please refer to {@link InteractionMode}. * * If this value is null, no interaction mode will be enabled. This corresponds to the default * mode that allows text selection and scrolling using the mouse wheel or scrollbars (and panning * on mobile devices). * * @example * instance.setViewState(viewState => ( * viewState.set("interactionMode", NutrientViewer.InteractionMode.PAN) * )); * * @default null */ interactionMode: IInteractionMode | null; /** * Configuration for cursor behavior keyed by input modality. * * The `keyboard` property is a function that receives the current {@link InteractionMode} * and returns configuration for that mode. This allows per-mode configuration. * * ## Supported InteractionModes for Keyboard Creation * * When keyboard returns `{ enabled: true }` for a mode: * - NOTE, TEXT, CALLOUT - single point placement * - SHAPE_LINE, SHAPE_RECTANGLE, SHAPE_ELLIPSE - 2 point placement * - SHAPE_POLYGON, SHAPE_POLYLINE - multi-point (Shift+Enter to complete) * * @example * // Disable keyboard for all modes * instance.setViewState(viewState => ( * viewState.set("pageCursor", { keyboard: () => ({ enabled: false }) }) * )); * * @example * // Disable keyboard only for INK mode * instance.setViewState(viewState => ( * viewState.set("pageCursor", { * keyboard: (mode) => ({ enabled: mode !== InteractionMode.INK }) * }) * )); * * @default { keyboard: () => ({ enabled: true }) } */ pageCursor: PageCursorConfiguration; /** * When this is enabled, the first spread will always show a single page, even when * {@link LayoutMode.DOUBLE} is enabled. This is useful for magazines that want to show * a cover page before the regular content starts. * * A spread is a container for either one or two pages, based on the configured * {@link ViewState#layoutMode}. * * @default false */ keepFirstSpreadAsSinglePage: boolean; /** * Controls how pages inside a view are displayed. * * @default {@link LayoutMode | LayoutMode.SINGLE} */ layoutMode: ILayoutMode; /** * The spacing between pages in pixels. This value will adjust to the current zoom level, so when * you zoom in, it does not appear fixed to the viewport. This spacing only applies for * {@link LayoutMode.DOUBLE}. * * @default 0 */ pageSpacing: number; /** * The current rotation of all pages. The value is in degrees and describes a clockwise rotation. * * Can either be 0°, 90°, 180°, or 270°. Negative values and values above 270 are normalized to one of the * valid rotations. * * When a page rotation is set, the values are not persisted in the PDF. This setting only affects * how the PDF is viewed in the application. * * @example * instance.setViewState(viewState => viewState.set("pagesRotation", -450)) * // ... later * instance.viewState.pagesRotation; // => 270 * * @default 0 */ pagesRotation: Rotation; /** * When the read only mode is activated, the UI for creating, updating and deleting annotations * will be completely hidden. In addition, the user will also no longer be able to select * annotations or modify form field values. * * However, it is still possible to add annotations programmatically. * * If a read only mode is specified within the JWT itself or in the PDF document permissions, * and {@link NutrientViewer.Options.IGNORE_DOCUMENT_PERMISSIONS} is not set, this option cannot be unset. * * @default false */ readOnly: boolean; /** * Controls how pages can be scrolled. * * @default {@link ScrollMode.CONTINUOUS} */ scrollMode: IScrollMode; /** * When this is set to false, annotations will no longer be rendered. * * This option can also be set to `false`, when {@link NutrientViewer.ViewState#readOnly} mode is enabled. * * @default true */ showAnnotations: boolean; /** * When this is set to false, comments will no longer be rendered. * * NutrientViewer ignores this value when you haven't purchased the comments component. * * @default true */ showComments: boolean; /** * When this is set to false, annotation notes will no longer be rendered. * * @default true */ showAnnotationNotes: boolean; /** * Set this to `true` if you want a toolbar for navigation and annotation controls or `false` * if you don't. * * @default true */ showToolbar: boolean; /** * Set this to `false` if you want NutrientViewer to disable the annotation toolbar when an annotation is being created or modified. * * @default true */ enableAnnotationToolbar: boolean; /** * Controls the current sidebar mode in the viewer. * * For a list of all available mode, please refer to {@link SidebarMode}. This can also be set to a custom sidebar ID corresponding to a sidebar passed in `ui.sidebar`. * * If this value is null, the sidebar is hidden. This corresponds to the default * mode. * * @example * instance.setViewState(viewState => ( * viewState.set("sidebarMode", NutrientViewer.SidebarMode.THUMBNAILS) * )); * * @default null */ sidebarMode: ISidebarMode | null | undefined; /** * Defines specific options that affect each individual sidebar. * * For a list of all available options, please refer to {@link SidebarOptions}. * * @example * Customizing the annotations sidebar to include only Text and Highlight annotations * ```ts * instance.setViewState(viewState => ( * viewState.set("sidebarOptions", { * [NutrientViewer.SidebarMode.ANNOTATIONS]: { * includeContent: [ * NutrientViewer.Annotations.TextAnnotation, * NutrientViewer.Annotations.HighlightAnnotation, * ], * }, * } * ) * )); * ``` * * @example * Customizing the annotations sidebar to include Comments * ```ts * instance.setViewState(viewState => ( * viewState.set("sidebarOptions", { * [NutrientViewer.SidebarMode.ANNOTATIONS]: { * includeContent: [ * ...NutrientViewer.defaultAnnotationsSidebarContent, * NutrientViewer.Comment, * ], * }, * } * ) * )); * ``` */ sidebarOptions: SidebarOptions | SidebarOptions | SidebarOptions | IObject; /** * Controls the current sidebar placement in the viewer. * * @example * instance.setViewState(viewState => ( * viewState.set("sidebarPlacement", NutrientViewer.SidebarPlacement.END) * )); * * @default null */ sidebarPlacement: ISidebarPlacement; /** * The spacing between spreads in pixels. This value will adjust to the current zoom level, so when * you zoom in, it does not appear fixed to the viewport. This spacing only applies for * {@link ScrollMode.CONTINUOUS}. * * A spread is a container for either one or two pages, based on the configured * {@link ViewState#layoutMode}. * * @default 20 */ spreadSpacing: number; /** * The padding between the viewport and the document in pixels. This value will not increase, when * you zoom in. * * The `horizontal` value will be used as `padding-left` and `padding-right` and the `vertical` * value for `padding-top` and `padding-bottom`. The same value for both sides will be used, this * means that `horizontal: 20` is equal to `padding-left: 20px; padding-right: 20px;`. * * When you set those values to zero, there will be no space between the viewport and the * document. * * @default { horizontal: 20, vertical: 20 } */ viewportPadding: ViewportPadding; /** * Controls the current zoom factor. This could either be a number multiplier or a * {@link ZoomConfiguration} or a {@link ZoomMode}. * * If a number value is used, it must be between {@link Instance#minimumZoomLevel} and * {@link Instance#maximumZoomLevel}. * * Note: Using a {@link ZoomMode}} will override the padding set using {@link ViewState#viewportPadding} * * @default * { * zoomMode: NutrientViewer.ZoomMode.AUTO, * wheelZoomMode: NutrientViewer.WheelZoomMode.WITH_CTRL, * options: { * enableKeyboardZoom: true, * enableGestureZoom: true, * }, * } */ zoom: ZoomConfiguration | IZoomMode | number; /** * Controls how comments are displayed in the viewer in desktop and tablet modes. In mobile devices, comments are always displayed in a drawer a the bottom of the viewport: * * - NutrientViewer.CommentDisplay.FITTING: Comments are displayed in a dialog or floating depending on the available viewport space. This is the default value. * - NutrientViewer.CommentDisplay.POPOVER: Comments are displayed in a dialog next to their reference annotation marker. * - NutrientViewer.CommentDisplay.FLOATING: Comments are displayed floating next to the page side, at the same height as their reference annotation marker, except when {@link ViewState#zoom} is set to .ZoomeMode#FIT_TO_WIDTH`, in which case they are displayed in a popover dialog instead. * * @default {@link CommentDisplay#FITTING} */ commentDisplay: ICommentDisplay; /** * Controls the zoom step when zooming in or out using the toolbar buttons. * * @default 1.25 * @example * instance.setViewState(viewState => ( * viewState.set("zoomStep", 1.1) * )); */ zoomStep: number; /** * This flag controls what kind of UI interaction is active for widget * annotations. * * - When set to `false`, (default), clicking on a widget annotation will allow * to modify its value. * - When set to `true`, clicking on a widget annotation will select it and * allow moving, resizing and deleting it using the annotation toolbar. * * This flag can only be set to `true` if the Form Creator component is included * in the license and the current backend supports it. * * @example * instance.setViewState(viewState => ( * viewState.set("formDesignMode", true) * )); * * @default false */ formDesignMode: boolean; /** * Controls when the digital signature validation UI will be shown. * * @example * instance.setViewState(viewState => ( * viewState.set("showSignatureValidationStatus", NutrientViewer.ShowSignatureValidationStatusMode.IF_SIGNED) * )); * * @default {@link ShowSignatureValidationStatusMode.NEVER} */ showSignatureValidationStatus: IShowSignatureValidationStatusMode; /** * This flag controls whether to show the marked state or redacted state for * redaction annotations. * * - When set to `false`, (default), the marked state of redaction annotations * will be shown. * - When set to `true`, the redacted state of redaction annotations will be used. * * This flag can only be set to `true` if the Redactions component is included * in the license. * * @example * instance.setViewState(viewState => ( * viewState.set("previewRedactionMode", true) * )); * * @default false */ previewRedactionMode: boolean; /** * This flag controls whether to enable/disable finger scrolling during * Ink Drawing using a pen (safari only) * * - When set to `false`, (default), scrolling with the finger in drawing mode * is disabled. * - When set to `true`, once a pen input has been detected, finger input will result in scrolling * the document. * * @example * instance.setViewState(viewState => ( * viewState.set("canScrollWhileDrawing", true) * )); * * @default false */ canScrollWhileDrawing: boolean; /** * This flag controls whether a selected tool should maintain its selected state after an * annotation is created * * - When set to `false`, (default), after an annotation has been created the tool is not * selected anymore. * - When set to `true`, the tool used to create the annotation will still be selected * and so it'll be possible to keep adding annotations. * * This feature is available for Note Annotation, Text Annotation, Redaction Annotation, Shape Annotation and Comments. Ink Annotation behaves like this by default, the ink tool stays selected until its deselected either programmatically or via the UI. * * @example * instance.setViewState(viewState => ( * viewState.set("keepSelectedTool", true) * )); * * @default false */ keepSelectedTool: boolean; /** * When in {@link LayoutMode.AUTO} mode, this property is set to the actual rendered layout mode, * which can either be {@link LayoutMode.SINGLE} or {@link LayoutMode.DOUBLE}. * It can be used to be notified when the layout mode changes while still being in {@link LayoutMode.AUTO} mode: if the rendered layout mode changes while in NutrientViewer.LayoutMode.AUTO (because of user UI * interactions, for example), the viewState.change event will be dispatched, and this property will hold the * updated value. * * @example * instance.addEventListener("viewState.change", (viewState) => { * console.log(viewState.resolvedLayoutMode); * }); */ resolvedLayoutMode: ILayoutMode; /** * Controls the width of the sidebar in client, pixel units. Changing the `ViewState.sidebarMode` does not affect this value. * * The default value depends on the current viewport width: if the viewport width is less than 768px, * the sidebar will take 100% of the viewport width by default. If the viewport width is greater, the sidebar will take 300px by default. * * @example * instance.setViewState(viewState => ( * viewState.set("sidebarWidth", 400) * )); */ sidebarWidth: number; /** * Snapping to the nearest point is enabled by default in ur SDK for measurement tools. It can be disabled by this API. * * @default false * @example * instance.setViewState(viewState => * viewState.set("disablePointSnapping", true) * ); */ disablePointSnapping: boolean; forceRenderWidgetsInAnnotationsOrder: boolean; /** * Number of page spreads to prerender. * * Apart from the current page, Nutrient Web SDK prerenders a specific number of page spreads before and after the current page * to improve the user experience when scrolling through the document. * * A page spread is a container for either one or two pages, based on the configured layout mode. The number of prerendered page * spreads is set to 5 by default, which means that Nutrient Web SDK will prerender 5 page spreads before and after the current page. * * If set to `null`, all the page spreads in the document will be prerendered. This setting is not recommended for large documents, as it may * lead to performance issues. * * @example * // Prerender 10 page spreads * instance.setViewState(viewState => * viewState.set("prerenderedPageSpreads", 10) * ); * // Prerender all page spreads * instance.setViewState(viewState => * viewState.set("prerenderedPageSpreads", null) * ); * * @default 5 */ prerenderedPageSpreads: number | null; /** * When this is enabled, the AI Assistant chat dialog will be shown. * If this is disabled, the chat dialog will not be shown. * * @example * NutrientViewer.load({ * initialViewState: new NutrientViewer.ViewState({ * showAIAssistant: true, * }), * }); * * @default false */ showAIAssistant: boolean; } /** @inline */ declare type IWheelZoomMode = ValueOf; /** @inline */ declare interface IWidgetAnnotation extends AnnotationProperties { formFieldName: string | null; borderColor: Color | null; borderStyle: IBorderStyle | null; borderDashArray: number[] | null; borderWidth: number | null; backgroundColor: Color | null; fontSize: FontSize | null; font: string | null; fontColor: Color | null; isBold: boolean | null; isItalic: boolean | null; horizontalAlign: 'left' | 'center' | 'right' | null; verticalAlign: 'top' | 'center' | 'bottom' | null; additionalActions: WidgetAnnotationAdditionalActionsType | null; rotation: number; lineHeightFactor: number | null; widgetAttachmentId: string | null; contentType: string | null; buttonIconUpdatedAt: number | null; } /** @inline */ declare type IZoomMode = ValueOf; /** @inline */ declare type IZoomOptions = { /** * Enable zooming via keyboard shortcuts (Ctrl/Cmd + [+-]). * * @default true */ enableKeyboardZoom?: boolean; /** * Enable zooming via touch gestures. * * @default true */ enableGestureZoom?: boolean; }; /** * @class * PDF action to run arbitrary JavaScript. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `action.set("script", "alert(...)");`. * @example * Create a new JavaScriptAction * ```ts * const action = new NutrientViewer.Actions.JavaScriptAction({ * script: "alert(...)" * }); * ``` * * @example * Create a button to import a image using a JavaScriptAction * ```ts * const widget = new NutrientViewer.Annotations.WidgetAnnotation({ * id: NutrientViewer.generateInstantId(), * pageIndex: 0, * formFieldName: "buttonIcon", * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 100, * top: 200, * width: 100, * height: 100 * }), * action: new NutrientViewer.Actions.JavaScriptAction({ * script: "event.target.buttonImportIcon()" * }), * borderWidth: 0 * }); * const formField = new NutrientViewer.FormFields.ButtonFormField({ * name: "buttonIcon", * annotationIds: NutrientViewer.Immutable.List([widget.id]) * }); * await instance.create([widget, formField]); * ``` * * @summary Run arbitrary JavaScript. */ export declare class JavaScriptAction extends Action { /** * The JavaScript to run. */ script: string; constructor(args?: IJavaScriptAction); } /** * @class * PDF action to launch a file. This action is not implemented yet. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `action.set("filePath", 2);`. * @example * Create a new LaunchAction * ```ts * const action = new NutrientViewer.Actions.LaunchAction({ filePath: "./some/file.mp4" }); * ``` * * @summary Launch a file. */ export declare class LaunchAction extends Action { /** * The file path to launch. */ filePath: string; constructor(args?: ILaunchAction); } /** * The layers sidebar options allow to specify options available for the Layers sidebar. * * Here you can define Currently, you can define a `lockedLayers` array in which you * can provide an array of `id`s for the layers for which visibility should not be modifieable * using the sidebar. * * @public * @summary Keyed list of options that apply to the layers sidebar. * @example * Customizing the layers sidebar to align icons to the right * ```ts * NutrientViewer.load({ * initialViewState: new NutrientViewer.ViewState({ * sidebarOptions: { * [NutrientViewer.SidebarMode.LAYERS]: { * LockedLayers: [], * iconsAlignment: NutrientViewer.Alignment.START * } * } * }) * }); * ``` * * @see {@link ViewState#sidebarOptions} */ export declare type LayersSidebarOptions = { /** Array of ocg.ocgId present in the document */ lockedLayers: number[]; /** Alignment relative to the parent container */ iconsAlignment: IAlignment; }; /** * Describes how the pages will be laid out in the document view. * * @enum */ declare const LayoutMode: { /** Pages will always be displayed in the single page mode. */ readonly SINGLE: "SINGLE"; /** Pages will always be displayed in side-by-side pairs. */ readonly DOUBLE: "DOUBLE"; /** * Automatically sets the layout mode to {@link NutrientViewer.LayoutMode.SINGLE} or * {@link NutrientViewer.LayoutMode.DOUBLE} depending on the available space. * * Specifically {@link NutrientViewer.LayoutMode.DOUBLE} is chosen when the NutrientViewer container is * sufficiently large and two pages can be shown without too much shrinking. * * This mode is a perfect fit for tablets in particular since it will automatically update the * layout mode then device orientation changes. * * When the dimensions of the viewport change (i.e. the browser window is resized), the view will * be restored to make the current page visible. */ readonly AUTO: "AUTO"; }; /** * @class * Line annotations are used to draw straight lines on a page. * * Line annotations are only selectable around their visible line. This means that you can create a * page full of line annotations while annotations behind the line annotation are still selectable. * * Right now, line annotations are implemented using SVG images. This behavior is subject to change. * *
* *
* @example * Create a line annotation * ```ts * const annotation = new NutrientViewer.Annotations.LineAnnotation({ * pageIndex: 0, * startPoint: new NutrientViewer.Geometry.Point({ x: 95, y: 95}), * endPoint: new NutrientViewer.Geometry.Point({ x: 195, y: 195}), * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 90, * top: 90, * width: 200, * height: 200, * }), * }); * ``` * * @summary Display a straight line on a page. */ export declare class LineAnnotation extends ShapeAnnotation { /** * A point tuple with x and y coordinates of the line starting point. * * If no starting point is provided, the annotation will not be visible. */ startPoint: Point; /** * A point tuple with x and y coordinates of the line ending point. * * If no ending point is provided, the annotation will not be visible. */ endPoint: Point; /** * An object with start and / or end entries for line caps. * * Line caps can have one of these values: "square", "circle", "diamond", "openArrow", "closedArrow", * "butt", "reverseOpenArrow", "reverseClosedArrow" or "slash". * * If the fillColor field is provided, its value is used as fill color for the line cap interior. */ lineCaps: LineCapsType | null; /** @deprecated Use `startPoint` and `endPoint` instead. */ points: List | null; static defaultValues: IObject; static readableName: string; } /** * @deprecated Use {@link Serializers.LineAnnotationJSON} instead. * @hidden */ export declare type LineAnnotationJSON = Serializers.LineAnnotationJSON; declare class LineAnnotationSerializer extends ShapeAnnotationSerializer { annotation: LineAnnotation; toJSON(): Serializers.LineAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): LineAnnotation; } /** * Represents one of the available line caps for the line and polyline annotations. * * @enum */ declare const LineCap: { /** Square line cap. */ readonly square: "square"; /** Circle line cap. */ readonly circle: "circle"; /** Diamond line cap. */ readonly diamond: "diamond"; /** Open arrow line cap. */ readonly openArrow: "openArrow"; /** Closed arrow line cap. */ readonly closedArrow: "closedArrow"; /** Butt line cap. */ readonly butt: "butt"; /** Reverse open arrow line cap. */ readonly reverseOpenArrow: "reverseOpenArrow"; /** Reverse closed arrow line cap. */ readonly reverseClosedArrow: "reverseClosedArrow"; /** Slash line cap. */ readonly slash: "slash"; }; declare type LineCapPresets = 'none' | 'square' | 'circle' | 'diamond' | 'openArrow' | 'closedArrow' | 'butt' | 'reverseOpenArrow' | 'reverseClosedArrow' | 'slash'; declare type LineCapsType = { start?: ILineCap | null; end?: ILineCap | null; }; /** * @class * A link can be used to trigger an action when clicked. They will not be drawn on the page but the * bounding box will be used for hit testing. * * Link annotations are generated for example, when the PDF document contains a reference to another * page or an URL. * * Every link annotation must have an `action` property. * *
* *
* @summary Display Link annotation on the page which will trigger an action when clicked. */ export declare class LinkAnnotation extends Annotation { /** * _The border on the image above is only for visual guidance and will not be rendered in the * viewer._ * * The action that will be triggered when the link annotation is either clicked or tapped. * * Please refer to {@link Actions} for an in-depth look at PDF actions. * * @example Create a link with a go to action * var action = new NutrientViewer.Actions.GoToAction({ pageIndex: 10 }); * var annotation = new NutrientViewer.Annotations.LinkAnnotation({ * pageIndex: 0, * boundingBox: new NutrientViewer.Geometry.Rect({ left: 10, top: 20, width: 30, height: 40 }), * action: action, * borderColor: new NutrientViewer.Color({ r: 245, g: 0, b: 0 }), * borderStyle: NutrientViewer.BorderStyle.solid, * borderWidth: 5 * }); * * @summary Triggers an action when clicked. */ action: Action; /** * Optional border color that will be drawn at the border of the bounding box. * * @default null */ borderColor: null | Color; /** * Optional border style used for the border of the bounding box. Valid options * are: * * - `solid` * - `dashed` * - `beveled` * - `inset` * - `underline` * * @default null */ borderStyle: null | IBorderStyle; /** * Optional border width in PDF pixels, that will be used for the border of the * bounding box. * * @default 0 */ borderWidth: null | number; static readableName: string; } declare class LinkAnnotationSerializer extends AnnotationSerializer { annotation: LinkAnnotation; constructor(annotation: LinkAnnotation); toJSON(): Serializers.LinkAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): LinkAnnotation; } /** * Create a new immutable List containing the values of the provided * collection-like. * * Note: `List` is a factory function and not a class, and does not use the * `new` keyword during construction. * * * ```js * const { List, Set } = require('immutable') * * const emptyList = List() * // List [] * * const plainArray = [ 1, 2, 3, 4 ] * const listFromPlainArray = List(plainArray) * // List [ 1, 2, 3, 4 ] * * const plainSet = Set([ 1, 2, 3, 4 ]) * const listFromPlainSet = List(plainSet) * // List [ 1, 2, 3, 4 ] * * const arrayIterator = plainArray[Symbol.iterator]() * const listFromCollectionArray = List(arrayIterator) * // List [ 1, 2, 3, 4 ] * * listFromPlainArray.equals(listFromCollectionArray) // true * listFromPlainSet.equals(listFromCollectionArray) // true * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ export declare function List(): List; export declare function List(): List; export declare function List(collection: Iterable): List; /** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /** * Immutable data encourages pure functions (data-in, data-out) and lends itself * to much simpler application development and enabling techniques from * functional programming such as lazy evaluation. * * While designed to bring these powerful functional concepts to JavaScript, it * presents an Object-Oriented API familiar to Javascript engineers and closely * mirroring that of Array, Map, and Set. It is easy and efficient to convert to * and from plain Javascript types. * * ## How to read these docs * * In order to better explain what kinds of values the Immutable.js API expects * and produces, this documentation is presented in a statically typed dialect of * JavaScript (like [Flow][] or [TypeScript][]). You *don't need* to use these * type checking tools in order to use Immutable.js, however becoming familiar * with their syntax will help you get a deeper understanding of this API. * * **A few examples and how to read them.** * * All methods describe the kinds of data they accept and the kinds of data * they return. For example a function which accepts two numbers and returns * a number would look like this: * * ```js * sum(first: number, second: number): number * ``` * * Sometimes, methods can accept different kinds of data or return different * kinds of data, and this is described with a *type variable*, which is * typically in all-caps. For example, a function which always returns the same * kind of data it was provided would look like this: * * ```js * identity(value: T): T * ``` * * Type variables are defined with classes and referred to in methods. For * example, a class that holds onto a value for you might look like this: * * ```js * class Box { * constructor(value: T) * getValue(): T * } * ``` * * In order to manipulate Immutable data, methods that we're used to affecting * a Collection instead return a new Collection of the same type. The type * `this` refers to the same kind of class. For example, a List which returns * new Lists when you `push` a value onto it might look like: * * ```js * class List { * push(value: T): this * } * ``` * * Many methods in Immutable.js accept values which implement the JavaScript * [Iterable][] protocol, and might appear like `Iterable` for something * which represents sequence of strings. Typically in JavaScript we use plain * Arrays (`[]`) when an Iterable is expected, but also all of the Immutable.js * collections are iterable themselves! * * For example, to get a value deep within a structure of data, we might use * `getIn` which expects an `Iterable` path: * * ``` * getIn(path: Iterable): any * ``` * * To use this method, we could pass an array: `data.getIn([ "key", 2 ])`. * * * Note: All examples are presented in the modern [ES2015][] version of * JavaScript. Use tools like Babel to support older browsers. * * For example: * * ```js * // ES2015 * const mappedFoo = foo.map(x => x * x); * // ES5 * var mappedFoo = foo.map(function (x) { return x * x; }); * ``` * * [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla * [TypeScript]: http://www.typescriptlang.org/ * [Flow]: https://flowtype.org/ * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols */ /** * Lists are ordered indexed dense collections, much like a JavaScript * Array. * * Lists are immutable and fully persistent with O(log32 N) gets and sets, * and O(1) push and pop. * * Lists implement Deque, with efficient addition and removal from both the * end (`push`, `pop`) and beginning (`unshift`, `shift`). * * Unlike a JavaScript Array, there is no distinction between an * "unset" index and an index set to `undefined`. `List#forEach` visits all * indices from 0 to size, regardless of whether they were explicitly defined. */ export declare module List { /** * True if the provided value is a List * * * ```js * const { List } = require('immutable'); * List.isList([]); // false * List.isList(List()); // true * ``` */ export function isList(maybeList: any): maybeList is List; /** * Creates a new List containing `values`. * * * ```js * const { List } = require('immutable'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` * * Note: Values are not altered or converted in any way. * * * ```js * const { List } = require('immutable'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` */ export function of(...values: Array): List; } export declare interface List extends Collection.Indexed { /** * The number of items in this List. */ readonly size: number; // Persistent changes /** * Returns a new List which includes `value` at `index`. If `index` already * exists in this List, it will be replaced. * * `index` may be a negative number, which indexes back from the end of the * List. `v.set(-1, "value")` sets the last item in the List. * * If `index` larger than `size`, the returned List's `size` will be large * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); * // List [ 0 ] * originalList.set(1, 1); * // List [ 0, 1 ] * originalList.set(0, 'overwritten'); * // List [ "overwritten" ] * originalList.set(2, 2); * // List [ 0, undefined, 2 ] * * List().set(50000, 'value').size; * // 50001 * ``` * * Note: `set` can be used in `withMutations`. */ set(index: number, value: T): List; /** * Returns a new List which excludes this `index` and with a size 1 less * than this List. Values at indices above `index` are shifted down by 1 to * fill the position. * * This is synonymous with `list.splice(index, 1)`. * * `index` may be a negative number, which indexes back from the end of the * List. `v.delete(-1)` deletes the last item in the List. * * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); * // List [ 1, 2, 3, 4 ] * ``` * * Since `delete()` re-indexes values, it produces a complete copy, which * has `O(N)` complexity. * * Note: `delete` *cannot* be used in `withMutations`. * * @alias remove */ delete(index: number): List; remove(index: number): List; /** * Returns a new List with `value` at `index` with a size 1 more than this * List. Values at indices above `index` are shifted over by 1. * * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) * // List [ 0, 1, 2, 3, 4, 5 ] * ``` * * Since `insert()` re-indexes values, it produces a complete copy, which * has `O(N)` complexity. * * Note: `insert` *cannot* be used in `withMutations`. */ insert(index: number, value: T): List; /** * Returns a new List with 0 size and no values in constant time. * * * ```js * List([ 1, 2, 3, 4 ]).clear() * // List [] * ``` * * Note: `clear` can be used in `withMutations`. */ clear(): List; /** * Returns a new List with the provided `values` appended, starting at this * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) * // List [ 1, 2, 3, 4, 5 ] * ``` * * Note: `push` can be used in `withMutations`. */ push(...values: Array): List; /** * Returns a new List with a size ones less than this List, excluding * the last index in this List. * * Note: this differs from `Array#pop` because it returns a new * List rather than the removed value. Use `last()` to get the last value * in this List. * * ```js * List([ 1, 2, 3, 4 ]).pop() * // List[ 1, 2, 3 ] * ``` * * Note: `pop` can be used in `withMutations`. */ pop(): List; /** * Returns a new List with the provided `values` prepended, shifting other * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); * // List [ 1, 2, 3, 4 ] * ``` * * Note: `unshift` can be used in `withMutations`. */ unshift(...values: Array): List; /** * Returns a new List with a size ones less than this List, excluding * the first index in this List, shifting all other values to a lower index. * * Note: this differs from `Array#shift` because it returns a new * List rather than the removed value. Use `first()` to get the first * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); * // List [ 1, 2, 3, 4 ] * ``` * * Note: `shift` can be used in `withMutations`. */ shift(): List; /** * Returns a new List with an updated value at `index` with the return * value of calling `updater` with the existing value, or `notSetValue` if * `index` was not set. If called with a single argument, `updater` is * called with the List itself. * * `index` may be a negative number, which indexes back from the end of the * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) * const result = list.update(2, val => val.toUpperCase()) * // List [ "a", "b", "C" ] * ``` * * This can be very useful as a way to "chain" a normal function into a * sequence of methods. RxJS calls this "let" and lodash calls it "thru". * * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) * } * * List([ 1, 2, 3 ]) * .map(x => x + 1) * .filter(x => x % 2 === 0) * .update(sum) * // 6 * ``` * * Note: `update(index)` can be used in `withMutations`. * * @see `Map#update` */ update(index: number, notSetValue: T, updater: (value: T) => T): this; update(index: number, updater: (value: T) => T): this; update(updater: (value: this) => R): R; /** * Returns a new List with size `size`. If `size` is less than this * List's size, the new List will exclude values at the higher indices. * If `size` is greater than this List's size, the new List will have * undefined values for the newly available indices. * * When building a new List and the final size is known up front, `setSize` * used in conjunction with `withMutations` may result in the more * performant construction. */ setSize(size: number): List; // Deep persistent changes /** * Returns a new List having set `value` at this `keyPath`. If any keys in * `keyPath` do not exist, a new immutable Map will be created at that key. * * Index numbers are used as keys to determine the path to follow in * the List. * * * ```js * const { List } = require('immutable') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] * ``` * * Plain JavaScript Object or Arrays may be nested within an Immutable.js * Collection, and setIn() can update those values as well, treating them * immutably by creating new copies of those values with the changes applied. * * * ```js * const { List } = require('immutable') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.setIn([3, 'plain'], 'value'); * // List([ 0, 1, 2, { plain: 'value' }]) * ``` * * Note: `setIn` can be used in `withMutations`. */ setIn(keyPath: Iterable, value: any): this; /** * Returns a new List having removed the value at this `keyPath`. If any * keys in `keyPath` do not exist, no change will occur. * * * ```js * const { List } = require('immutable') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] * ``` * * Plain JavaScript Object or Arrays may be nested within an Immutable.js * Collection, and removeIn() can update those values as well, treating them * immutably by creating new copies of those values with the changes applied. * * * ```js * const { List } = require('immutable') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.removeIn([3, 'plain']); * // List([ 0, 1, 2, {}]) * ``` * * Note: `deleteIn` *cannot* be safely used in `withMutations`. * * @alias removeIn */ deleteIn(keyPath: Iterable): this; removeIn(keyPath: Iterable): this; /** * Note: `updateIn` can be used in `withMutations`. * * @see `Map#updateIn` */ updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; updateIn(keyPath: Iterable, updater: (value: any) => any): this; /** * Note: `mergeIn` can be used in `withMutations`. * * @see `Map#mergeIn` */ mergeIn(keyPath: Iterable, ...collections: Array): this; /** * Note: `mergeDeepIn` can be used in `withMutations`. * * @see `Map#mergeDeepIn` */ mergeDeepIn(keyPath: Iterable, ...collections: Array): this; // Transient changes /** * Note: Not all methods can be safely used on a mutable collection or within * `withMutations`! Check the documentation for each method to see if it * allows being used in `withMutations`. * * @see `Map#withMutations` */ withMutations(mutator: (mutable: this) => any): this; /** * An alternative API for withMutations() * * Note: Not all methods can be safely used on a mutable collection or within * `withMutations`! Check the documentation for each method to see if it * allows being used in `withMutations`. * * @see `Map#asMutable` */ asMutable(): this; /** * @see `Map#wasAltered` */ wasAltered(): boolean; /** * @see `Map#asImmutable` */ asImmutable(): this; // Sequence algorithms /** * Returns a new List with other values or collections concatenated to this one. * * Note: `concat` can be used in `withMutations`. * * @alias merge */ concat(...valuesOrCollections: Array | C>): List; merge(...collections: Array>): List; /** * Returns a new List with values passed through a * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) * // List [ 10, 20 ] * ``` */ map( mapper: (value: T, key: number, iter: this) => M, context?: any) : List; /** * Flat-maps the List, returning a new List. * * Similar to `list.map(...).flatten(true)`. */ flatMap( mapper: (value: T, key: number, iter: this) => Iterable, context?: any) : List; /** * Returns a new List with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: T, index: number, iter: this) => value is F, context?: any) : List; filter( predicate: (value: T, index: number, iter: this) => any, context?: any) : this; /** * Returns a List "zipped" with the provided collection. * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ zip(other: Collection): List<[T, U]>; zip(other: Collection, other2: Collection): List<[T, U, V]>; zip(...collections: Array>): List; /** * Returns a List "zipped" with the provided collections. * * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); * const b = List([ 3, 4, 5 ]); * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` * * Note: Since zipAll will return a collection as large as the largest * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ zipAll(other: Collection): List<[T, U]>; zipAll(other: Collection, other2: Collection): List<[T, U, V]>; zipAll(...collections: Array>): List; /** * Returns a List "zipped" with the provided collections by using a * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); * const c = a.zipWith((a, b) => a + b, b); * // List [ 5, 7, 9 ] * ``` */ zipWith( zipper: (value: T, otherValue: U) => Z, otherCollection: Collection) : List; zipWith( zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection) : List; zipWith( zipper: (...any: Array) => Z, ...collections: Array>) : List; } /** * @class * * A list box where multiple values can be selected. * * To retrieve a list of all form fields, use {@link Instance#getFormFields}. * * Please note that {@link Instance#getFormFieldValues} will not return * the latest value for this field until the user leaves this field by default. If you * want this value to update on every change then set the {@link FormFields.ChoiceFormField#commitOnChange} to * true. * @public * @summary A list box where multiple values can be selected. */ export declare class ListBoxFormField extends ChoiceFormField { additionalActions: FormFieldInputAdditionalActionsType | null | undefined; } /** * Creates a new NutrientViewer instance. * * Returns a {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise | Promise} * resolving to a new {@link NutrientViewer.Instance}, or rejecting with a {@link NutrientViewer.Error}. * * It requires a {@link Configuration | configuration object}. When the configuration is * invalid, the promise will be rejected with a {@link NutrientViewer.Error}. * * @example * Load Nutrient Web SDK Server * ```ts * NutrientViewer.load({ * authPayload: { jwt: "xxx.xxx.xxx" }, * container: ".foo", * documentId: "85203", * instant: true, * }).then((instance) => { * console.log("Successfully mounted NutrientViewer", instance); * }).catch((error) => { * console.error(error.message); * }) * ``` * * @example * Load Nutrient Web SDK Standalone * ```ts * NutrientViewer.load({ * document: "/sales-report.pdf", * container: ".foo", * licenseKey: "YOUR_LICENSE_KEY", * }).then((instance) => { * console.log("Successfully mounted NutrientViewer", instance); * }).catch((error) => { * console.error(error.message); * }) * ``` * * @public */ declare function load(configuration: Configuration): Promise; /** * Loads and initializes the Text Comparison UI for comparing two documents. * * This method creates a complete text comparison interface with side-by-side document views, * highlighting differences between documents, and providing navigation through changes. * Optionally supports AI-powered analysis for categorizing and summarizing differences. * * @param configuration - Configuration object containing document sources, UI options, and comparison settings * @returns Promise that resolves to a TextComparisonInstance for programmatic control * @example * * const textComparisonInstance = await NutrientViewer.loadTextComparison({ * container: '.text-comparison-container', * documentA: 'path/to/document-a.pdf', * documentB: 'path/to/document-b.pdf', * comparisonSidebarConfig: { * diffColors: { * insertionColor: new NutrientViewer.Color({ r: 0, g: 255, b: 0 }), * deletionColor: new NutrientViewer.Color({ r: 255, g: 0, b: 0 }) * }, * openByDefault: true * } * }); * */ declare function loadTextComparison(configuration: TextComparisonConfiguration): Promise; /** * Creates a new Immutable Map. * * Created with the same key value pairs as the provided Collection.Keyed or * JavaScript Object or expects a Collection of [K, V] tuple entries. * * Note: `Map` is a factory function and not a class, and does not use the * `new` keyword during construction. * * * ```js * const { Map } = require('immutable') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` * * Keep in mind, when using JS objects to construct Immutable Maps, that * JavaScript Object properties are always strings, even if written in a * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } * Object.keys(obj) // [ "1" ] * assert.equal(obj["1"], obj[1]) // "one" === "one" * * let map = Map(obj) * assert.notEqual(map.get("1"), map.get(1)) // "one" !== undefined * ``` * * Property access for JavaScript Objects first converts the key to a string, * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. */ declare function Map_2(collection: Iterable<[K, V]>): Map_2; declare function Map_2(collection: Iterable>): Map_2; declare function Map_2(obj: {[key: string]: V;}): Map_2; declare function Map_2(): Map_2; declare function Map_2(): Map_2; /** * Immutable Map is an unordered Collection.Keyed of (key, value) pairs with * `O(log32 N)` gets and `O(log32 N)` persistent sets. * * Iteration order of a Map is undefined, however is stable. Multiple * iterations of the same Map will iterate in the same order. * * Map's keys can be of any type, and use `Immutable.is` to determine key * equality. This allows the use of any value (including NaN) as a key. * * Because `Immutable.is` returns equality based on value semantics, and * Immutable collections are treated as values, any Immutable collection may * be used as a key. * * * ```js * const { Map, List } = require('immutable'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` * * Any JavaScript object may be used as a key, however strict identity is used * to evaluate key equality. Two similar looking objects will represent two * different keys. * * Implemented by a hash-array mapped trie. */ declare module Map_2 { /** * True if the provided value is a Map * * * ```js * const { Map } = require('immutable') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` */ function isMap(maybeMap: any): maybeMap is Map_2; /** * Creates a new Map from alternating keys and values * * * ```js * const { Map } = require('immutable') * Map.of( * 'key', 'value', * 'numerical value', 3, * 0, 'numerical key' * ) * // Map { 0: "numerical key", "key": "value", "numerical value": 3 } * ``` * * @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' }) */ function of(...keyValues: Array): Map_2; } declare interface Map_2 extends Collection.Keyed { /** * The number of entries in this Map. */ readonly size: number; // Persistent changes /** * Returns a new Map also containing the new key, value pair. If an equivalent * key already exists in this Map, it will be replaced. * * * ```js * const { Map } = require('immutable') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') * * originalMap * // Map {} * newerMap * // Map { "key": "value" } * newestMap * // Map { "key": "newer value" } * ``` * * Note: `set` can be used in `withMutations`. */ set(key: K, value: V): this; /** * Returns a new Map which excludes this `key`. * * Note: `delete` cannot be safely used in IE8, but is provided to mirror * the ES6 collection API. * * * ```js * const { Map } = require('immutable') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' * }) * // Map { "key": "value", "otherKey": "other value" } * originalMap.delete('otherKey') * // Map { "key": "value" } * ``` * * Note: `delete` can be used in `withMutations`. * * @alias remove */ delete(key: K): this; remove(key: K): this; /** * Returns a new Map which excludes the provided `keys`. * * * ```js * const { Map } = require('immutable') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } * ``` * * Note: `deleteAll` can be used in `withMutations`. * * @alias removeAll */ deleteAll(keys: Iterable): this; removeAll(keys: Iterable): this; /** * Returns a new Map containing no keys or values. * * * ```js * const { Map } = require('immutable') * Map({ key: 'value' }).clear() * // Map {} * ``` * * Note: `clear` can be used in `withMutations`. */ clear(): this; /** * Returns a new Map having updated the value at this `key` with the return * value of calling `updater` with the existing value. * * Similar to: `map.set(key, updater(map.get(key)))`. * * * ```js * const { Map } = require('immutable') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } * ``` * * This is most commonly used to call methods on collections within a * structure of data. For example, in order to `.push()` onto a nested `List`, * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) * const newMap = aMap.update('nestedList', list => list.push(4)) * // Map { "nestedList": List [ 1, 2, 3, 4 ] } * ``` * * When a `notSetValue` is provided, it is provided to the `updater` * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('noKey', 'no value', value => value + value) * // Map { "key": "value", "noKey": "no valueno value" } * ``` * * However, if the `updater` function returns the same value it was called * with, then no change will occur. This is still true if `notSetValue` * is provided. * * * ```js * const aMap = Map({ apples: 10 }) * const newMap = aMap.update('oranges', 0, val => val) * // Map { "apples": 10 } * assert.strictEqual(newMap, map); * ``` * * For code using ES2015 or later, using `notSetValue` is discourged in * favor of function parameter default values. This helps to avoid any * potential confusion with identify functions as described above. * * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) * const newMap = aMap.update('oranges', (val = 0) => val) * // Map { "apples": 10, "oranges": 0 } * ``` * * If no key is provided, then the `updater` function return value is * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) * const result = aMap.update(aMap => aMap.get('key')) * // "value" * ``` * * This can be very useful as a way to "chain" a normal function into a * sequence of methods. RxJS calls this "let" and lodash calls it "thru". * * For example, to sum the values in a Map * * * ```js * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) * } * * Map({ x: 1, y: 2, z: 3 }) * .map(x => x + 1) * .filter(x => x % 2 === 0) * .update(sum) * // 6 * ``` * * Note: `update(key)` can be used in `withMutations`. */ update(key: K, notSetValue: V, updater: (value: V) => V): this; update(key: K, updater: (value: V) => V): this; update(updater: (value: this) => R): R; /** * Returns a new Map resulting from merging the provided Collections * (or JS objects) into this Map. In other words, this takes each entry of * each collection and sets it on this Map. * * Note: Values provided to `merge` are shallowly converted before being * merged. No nested values are altered. * * * ```js * const { Map } = require('immutable') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } * two.merge(one) // Map { "b": 20, "a": 10, "d": 60, "c": 30 } * ``` * * Note: `merge` can be used in `withMutations`. * * @alias concat */ merge(...collections: Array>): Map_2; merge(...collections: Array<{[key: string]: C;}>): Map_2; concat(...collections: Array>): Map_2; concat(...collections: Array<{[key: string]: C;}>): Map_2; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging * the provided Collections (or JS objects) into this Map, but uses the * `merger` function for dealing with conflicts. * * * ```js * const { Map } = require('immutable') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) * // { "a": 0.2, "b": 0.5, "c": 30, "d": 60 } * two.mergeWith((oldVal, newVal) => oldVal / newVal, one) * // { "b": 2, "a": 5, "d": 60, "c": 30 } * ``` * * Note: `mergeWith` can be used in `withMutations`. */ mergeWith( merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array | {[key: string]: V;}>) : this; /** * Like `merge()`, but when two Collections conflict, it merges them as well, * recursing deeply through the nested data. * * Note: Values provided to `merge` are shallowly converted before being * merged. No nested values are altered unless they will also be merged at * a deeper level. * * * ```js * const { Map } = require('immutable') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) * // Map { * // "a": Map { "x": 2, "y": 10 }, * // "b": Map { "x": 20, "y": 5 }, * // "c": Map { "z": 3 } * // } * ``` * * Note: `mergeDeep` can be used in `withMutations`. */ mergeDeep(...collections: Array | {[key: string]: V;}>): this; /** * Like `mergeDeep()`, but when two non-Collections conflict, it uses the * `merger` function to determine the resulting value. * * * ```js * const { Map } = require('immutable') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) * // Map { * // "a": Map { "x": 5, "y": 10 }, * // "b": Map { "x": 20, "y": 10 }, * // "c": Map { "z": 3 } * // } * ``` * Note: `mergeDeepWith` can be used in `withMutations`. */ mergeDeepWith( merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | {[key: string]: V;}>) : this; // Deep persistent changes /** * Returns a new Map having set `value` at this `keyPath`. If any keys in * `keyPath` do not exist, a new immutable Map will be created at that key. * * * ```js * const { Map } = require('immutable') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', * subSubObject: Map({ * subSubKey: 'subSubValue' * }) * }) * }) * * const newMap = originalMap.setIn(['subObject', 'subKey'], 'ha ha!') * // Map { * // "subObject": Map { * // "subKey": "ha ha!", * // "subSubObject": Map { "subSubKey": "subSubValue" } * // } * // } * * const newerMap = originalMap.setIn( * ['subObject', 'subSubObject', 'subSubKey'], * 'ha ha ha!' * ) * // Map { * // "subObject": Map { * // "subKey": "subvalue", * // "subSubObject": Map { "subSubKey": "ha ha ha!" } * // } * // } * ``` * * Plain JavaScript Object or Arrays may be nested within an Immutable.js * Collection, and setIn() can update those values as well, treating them * immutably by creating new copies of those values with the changes applied. * * * ```js * const { Map } = require('immutable') * const originalMap = Map({ * subObject: { * subKey: 'subvalue', * subSubObject: { * subSubKey: 'subSubValue' * } * } * }) * * originalMap.setIn(['subObject', 'subKey'], 'ha ha!') * // Map { * // "subObject": { * // subKey: "ha ha!", * // subSubObject: { subSubKey: "subSubValue" } * // } * // } * ``` * * If any key in the path exists but cannot be updated (such as a primitive * like number or a custom Object like Date), an error will be thrown. * * Note: `setIn` can be used in `withMutations`. */ setIn(keyPath: Iterable, value: any): this; /** * Returns a new Map having removed the value at this `keyPath`. If any keys * in `keyPath` do not exist, no change will occur. * * Note: `deleteIn` can be used in `withMutations`. * * @alias removeIn */ deleteIn(keyPath: Iterable): this; removeIn(keyPath: Iterable): this; /** * Returns a new Map having applied the `updater` to the entry found at the * keyPath. * * This is most commonly used to call methods on collections nested within a * structure of data. For example, in order to `.push()` onto a nested `List`, * `updateIn` and `push` can be used together: * * * ```js * const { Map, List } = require('immutable') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } * ``` * * If any keys in `keyPath` do not exist, new Immutable `Map`s will * be created at those keys. If the `keyPath` does not already contain a * value, the `updater` function will be called with `notSetValue`, if * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) * // Map { "a": Map { "b": Map { "c": 20 } } } * ``` * * If the `updater` function returns the same value it was called with, then * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) * const newMap = map.updateIn(['a', 'b', 'x'], 100, val => val) * // Map { "a": Map { "b": Map { "c": 10 } } } * assert.strictEqual(newMap, aMap) * ``` * * For code using ES2015 or later, using `notSetValue` is discourged in * favor of function parameter default values. This helps to avoid any * potential confusion with identify functions as described above. * * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) * const newMap = map.updateIn(['a', 'b', 'x'], (val = 100) => val) * // Map { "a": Map { "b": Map { "c": 10, "x": 100 } } } * ``` * * Plain JavaScript Object or Arrays may be nested within an Immutable.js * Collection, and updateIn() can update those values as well, treating them * immutably by creating new copies of those values with the changes applied. * * * ```js * const map = Map({ a: { b: { c: 10 } } }) * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) * // Map { "a": { b: { c: 20 } } } * ``` * * If any key in the path exists but cannot be updated (such as a primitive * like number or a custom Object like Date), an error will be thrown. * * Note: `updateIn` can be used in `withMutations`. */ updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; updateIn(keyPath: Iterable, updater: (value: any) => any): this; /** * A combination of `updateIn` and `merge`, returning a new Map, but * performing the merge at a point arrived at by following the keyPath. * In other words, these two lines are equivalent: * * ```js * map.updateIn(['a', 'b', 'c'], abc => abc.merge(y)) * map.mergeIn(['a', 'b', 'c'], y) * ``` * * Note: `mergeIn` can be used in `withMutations`. */ mergeIn(keyPath: Iterable, ...collections: Array): this; /** * A combination of `updateIn` and `mergeDeep`, returning a new Map, but * performing the deep merge at a point arrived at by following the keyPath. * In other words, these two lines are equivalent: * * ```js * map.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)) * map.mergeDeepIn(['a', 'b', 'c'], y) * ``` * * Note: `mergeDeepIn` can be used in `withMutations`. */ mergeDeepIn(keyPath: Iterable, ...collections: Array): this; // Transient changes /** * Every time you call one of the above functions, a new immutable Map is * created. If a pure function calls a number of these to produce a final * return value, then a penalty on performance and memory has been paid by * creating all of the intermediate immutable Maps. * * If you need to apply a series of mutations to produce a new immutable * Map, `withMutations()` creates a temporary mutable copy of the Map which * can apply mutations in a highly performant manner. In fact, this is * exactly how complex mutations like `merge` are done. * * As an example, this results in the creation of 2, not 4, new Maps: * * * ```js * const { Map } = require('immutable') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) * }) * assert.equal(map1.size, 0) * assert.equal(map2.size, 3) * ``` * * Note: Not all methods can be used on a mutable collection or within * `withMutations`! Read the documentation for each method to see if it * is safe to use in `withMutations`. */ withMutations(mutator: (mutable: this) => any): this; /** * Another way to avoid creation of intermediate Immutable maps is to create * a mutable copy of this collection. Mutable copies *always* return `this`, * and thus shouldn't be used for equality. Your function should never return * a mutable copy of a collection, only use it internally to create a new * collection. * * If possible, use `withMutations` to work with temporary mutable copies as * it provides an easier to use API and considers many common optimizations. * * Note: if the collection is already mutable, `asMutable` returns itself. * * Note: Not all methods can be used on a mutable collection or within * `withMutations`! Read the documentation for each method to see if it * is safe to use in `withMutations`. * * @see `Map#asImmutable` */ asMutable(): this; /** * Returns true if this is a mutable copy (see `asMutable()`) and mutative * alterations have been applied. * * @see `Map#asMutable` */ wasAltered(): boolean; /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, * this operation is *mutable* and may return itself (though may not * return itself, i.e. if the result is an empty collection). Once * performed, the original mutable copy must no longer be mutated since it * may be the immutable result. * * If possible, use `withMutations` to work with temporary mutable copies as * it provides an easier to use API and considers many common optimizations. * * @see `Map#asMutable` */ asImmutable(): this; // Sequence algorithms /** * Returns a new Map with values passed through a * `mapper` function. * * Map({ a: 1, b: 2 }).map(x => 10 * x) * // Map { a: 10, b: 20 } */ map( mapper: (value: V, key: K, iter: this) => M, context?: any) : Map_2; /** * @see Collection.Keyed.mapKeys */ mapKeys( mapper: (key: K, value: V, iter: this) => M, context?: any) : Map_2; /** * @see Collection.Keyed.mapEntries */ mapEntries( mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any) : Map_2; /** * Flat-maps the Map, returning a new Map. * * Similar to `data.map(...).flatten(true)`. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, context?: any) : Map_2; /** * Returns a new Map with only the entries for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: V, key: K, iter: this) => value is F, context?: any) : Map_2; filter( predicate: (value: V, key: K, iter: this) => any, context?: any) : this; /** * @see Collection.Keyed.flip */ flip(): Map_2; } declare let Maui: { MauiBridge: typeof MauiBridgeInstance; } | undefined; declare const MauiBridgeInstance: IMauiBridge; /** * Precision values for length of measurement annotations. * * @enum */ declare const MeasurementPrecision: { /** Displays measurements as whole numbers with no decimal places. */ readonly WHOLE: "whole"; /** Displays measurements with one decimal place precision. */ readonly ONE: "oneDp"; /** Displays measurements with two decimal places precision. */ readonly TWO: "twoDp"; /** Displays measurements with three decimal places precision. */ readonly THREE: "threeDp"; /** Displays measurements with four decimal places precision. */ readonly FOUR: "fourDp"; /** Displays measurements in fractions with halves (1/2) precision. */ readonly HALVES: "1/2"; /** Displays measurements in fractions with quarters (1/4) precision. */ readonly QUARTERS: "1/4"; /** Displays measurements in fractions with eighths (1/8) precision. */ readonly EIGHTHS: "1/8"; /** Displays measurements in fractions with sixteenths (1/16) precision. */ readonly SIXTEENTHS: "1/16"; }; /** * MeasurementScale is a class that represents the scale of measurement annotations. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `scale.set("fromValue", 15)` * * @example * Create and update a scale. * ```ts * const scale = new NutrientViewer.MeasurementScale({ * unitFrom: NutrientViewer.MeasurementScaleUnitFrom.Millimeters, * unitTo: NutrientViewer.MeasurementScaleUnitTo.Inches, * fromValue: 1, * toValue: 10 * }); * const newScale = scale.set("fromValue", 2); * newScale.fromValue // => 2 * ``` * * @hideconstructor * @summary The scale value of a measurement annotation. */ export declare class MeasurementScale extends MeasurementScale_base {} declare const MeasurementScale_base: Record_2.Factory; /** @inline */ declare type MeasurementScaleJSON = { unitFrom: IMeasurementScaleUnitFrom; unitTo: IMeasurementScaleUnitTo; from: number; to: number; fromDescription?: string; toDescription?: string; }; /** * Represents one of the units from which you can scale from for measurement annotations. * * @enum */ declare const MeasurementScaleUnitFrom: { /** Inches (in) - Imperial unit of length. */ readonly INCHES: "in"; /** Millimeters (mm) - Metric unit of length. */ readonly MILLIMETERS: "mm"; /** Centimeters (cm) - Metric unit of length. */ readonly CENTIMETERS: "cm"; /** Points (pt) - Typographic unit of measurement (1/72 of an inch). */ readonly POINTS: "pt"; }; /** * Represents one of the units to which you can scale from for measurement annotations. * * @enum */ declare const MeasurementScaleUnitTo: { /** Inches (in) - Imperial unit of length. */ readonly INCHES: "in"; /** Millimeters (mm) - Metric unit of length. */ readonly MILLIMETERS: "mm"; /** Centimeters (cm) - Metric unit of length. */ readonly CENTIMETERS: "cm"; /** Points (pt) - Typographic unit of measurement (1/72 of an inch). */ readonly POINTS: "pt"; /** Feet (ft) - Imperial unit of length. */ readonly FEET: "ft"; /** Meters (m) - Metric unit of length. */ readonly METERS: "m"; /** Yards (yd) - Imperial unit of length. */ readonly YARDS: "yd"; /** Kilometers (km) - Metric unit of length. */ readonly KILOMETERS: "km"; /** Miles (mi) - Imperial unit of length. */ readonly MILES: "mi"; }; /** @inline */ export declare interface MeasurementValueConfiguration { /** Your custom configuration name. It has to be unique. */ name?: string; /** The custom scale passed in the configuration, it represent the scale used in the document */ scale: IMeasurementScale; /** Precision values for the length of measurement annotations */ precision: IMeasurementPrecision; /** Whether a custom scale is selected or not. */ selected?: boolean; } /** * Nutrient Web SDK allows you to pass a customized configuration for measurements annotation scale and precision through the following callback * * @example * Configure a custom scale and pass it to our viewer. * ```ts * * const customScales = [ * { * scale: { * unitFrom: NutrientViewer.MeasurementScaleUnitFrom.CENTIMETERS, * unitTo: NutrientViewer.MeasurementScaleUnitTo.METERS, * fromValue: 1, * toValue: 2 * }, * precision: NutrientViewer.MeasurementPrecision.FOUR, * selected: true * } * ]; * * NutrientViewer.load({ * // Other options. * measurementValueConfiguration: (documentScales) => { * return [...customScales, ...documentScales]; * } * }); * ``` * * @see {@link NutrientViewer.MeasurementScale} * @see {@link NutrientViewer.MeasurementPrecision} */ export declare type MeasurementValueConfigurationCallback = (configuration: MeasurementValueConfiguration[]) => MeasurementValueConfiguration[]; /** * @class * Media Annotations specifies a region of a page upon which media clips may be played. * * With the Nutrient Web SDK you can display and delete Media Annotations, meanwhile creating them is not supported. * @summary Display a media file in a document. */ export declare class MediaAnnotation extends Annotation { /** * A description of the media content. */ description: null | string; /** * The file name of the attached file. */ fileName: null | string; /** * The content type of the connected attachment data. We expect it to be a MIME type (mp4, video, etc..). */ contentType: string | null; /** * The attachment identifier of the media. It holds the media data as binary. */ mediaAttachmentId: string | null; static readableName: string; } declare class MediaAnnotationSerializer extends AnnotationSerializer { annotation: MediaAnnotation; constructor(annotation: MediaAnnotation); toJSON(): Serializers.MediaAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): MediaAnnotation; } export declare type MentionableUser = { /** The unique ID of the user. */ id: string; /** The name of the user. */ name: string; /** The URL of the user's avatar. */ avatarUrl?: string; /** The display name of the user. */ displayName: string; /** * The description of the user. This is shown in the mention list. * If you want to show the email, you can pass it here. */ description?: string; }; /** * Returns a copy of the collection with the remaining collections merged in. * * A functional alternative to `collection.merge()` which will also work with * plain Objects and Arrays. * * * ```js * const { merge } = require('immutable') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } * console.log(original) // { x: 123, y: 456 } * ``` */ declare function merge( collection: C, ...collections: Array | Iterable<[any, any]> | {[key: string]: any;}>) : C; /** * Returns a copy of the collection with the remaining collections merged in * deeply (recursively). * * A functional alternative to `collection.mergeDeep()` which will also work * with plain Objects and Arrays. * * * ```js * const { mergeDeep } = require('immutable') * const original = { x: { y: 123 }} * mergeDeep(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} * ``` */ declare function mergeDeep( collection: C, ...collections: Array | Iterable<[any, any]> | {[key: string]: any;}>) : C; /** * Returns a copy of the collection with the remaining collections merged in * deeply (recursively), calling the `merger` function whenever an existing * value is encountered. * * A functional alternative to `collection.mergeDeepWith()` which will also * work with plain Objects and Arrays. * * * ```js * const { mergeDeepWith } = require('immutable') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, * original, * { x: { y: 456 }} * ) // { x: { y: 579 }} * console.log(original) // { x: { y: 123 }} * ``` */ declare function mergeDeepWith( merger: (oldVal: any, newVal: any, key: any) => any, collection: C, ...collections: Array | Iterable<[any, any]> | {[key: string]: any;}>) : C; /** * Returns a copy of the collection with the remaining collections merged in, * calling the `merger` function whenever an existing value is encountered. * * A functional alternative to `collection.mergeWith()` which will also work * with plain Objects and Arrays. * * * ```js * const { mergeWith } = require('immutable') * const original = { x: 123, y: 456 } * mergeWith( * (oldVal, newVal) => oldVal + newVal, * original, * { y: 789, z: 'abc' } * ) // { x: 123, y: 1245, z: 'abc' } * console.log(original) // { x: 123, y: 456 } * ``` */ declare function mergeWith( merger: (oldVal: any, newVal: any, key: any) => any, collection: C, ...collections: Array | Iterable<[any, any]> | {[key: string]: any;}>) : C; declare function MiscellaneousMixin>(Base: T): { new (...args: any[]): { /** * **NOTE** This method is only available with Nutrient Instant. * * Use this method to obtain an up-to-date list of the current connected instance clients. * * The return value is an {@link https://immutable-js.com/docs/v5/Map/ | Immutable.Map}, * which can be used like the regular ES2015 Map. * * The {@link NutrientViewer.EventName.INSTANT_CONNECTED_CLIENTS_CHANGE | "instant.connectedClients.change"} event will be triggered, whenever * a new client will connect to the document, or a current client will disconnect. The event * will always include the full up-to-date list of the currently connected clients (the same * that would be returned when you call this method). * * @example * Find out how many total clients are currently connected * ```ts * instance.connectedClients.count(); * ``` * * @example * Find out how many distinct users are currently connected * ```ts * instance.connectedClients.groupBy(c => c.userId).count(); * ``` * * @example * Find out how many anonymous clients are currently connected * ```ts * instance.connectedClients.filter(c => !c.userId).count(); * ``` * * @returns An {@link NutrientViewer.Immutable.Map} of the connected clients. */ readonly connectedClients: Map_2; /** * Enable actions like cut, copy, paste and duplicate for annotations using keyboard shortcuts `Cmd/Ctrl+X`, `Cmd/Ctrl+C`, `Cmd/Ctrl+V` and `Cmd/Ctrl+D` respectively. * * @param enabled - Whether to enable/disable the clipboard actions. */ toggleClipboardActions(enabled: boolean): void; /** * Allows the user to toggle the snapping behavior while creation of measurement annotations. The snapping points are the points are a combination of endpoints, midpoints and intersections. * * @param enabled - Whether to enable/disable snapping behaviour for creation of measurement annotations. */ setMeasurementSnapping(enabled: boolean): void; /** * Set the precision value of all the newly created measurement annotations. * * @example * instance.setMeasurementPrecision(NutrientViewer.MeasurementPrecision.THREE); * * @param precision - Precision value */ setMeasurementPrecision(precision: IMeasurementPrecision): void; /** * Set the default value of scale for all newly created measurement annotations. * * @example * instance.setMeasurementScale(new NutrientViewer.MeasurementScale({ * unitFrom: NutrientViewer.MeasurementScaleUnitFrom.CENTIMETERS, * unitTo: NutrientViewer.MeasurementScaleUnitTo.INCHES, * fromValue: 1, * toValue: 2, * })); * * @param scale - Scale value */ setMeasurementScale(scale: MeasurementScale): void; setMeasurementValueConfiguration(configurationCallback: MeasurementValueConfigurationCallback): void; /** * Given a list of rects and their page index, extracts the text intersecting them. This can be * useful to get the text that overlaps a focused annotation to give more context to screen reader users. * * Warning: The computed text might be partial as we just look behind the absolute coordinates of * a rect to see what text it is intersecting. * * @example * Get the text of all ink annotations on the first page: * ```ts * const annotations = await instance.getAnnotations(0); * const inkAnnotationsRects = annotations.filter( * annotation => annotation instanceof NutrientViewer.Annotations.InkAnnotation * ).map(annotation => annotation.boundingBox); * const text = await instance.getTextFromRects(0, inkAnnotationsRects); * console.log(text); * ``` * * @param pageIndex - The page index where the rects are located * @param rects - An immutable list of rects * @returns The text that intersect the rects. */ getTextFromRects(pageIndex: number, rects: List): Promise; /** * Extracts the text behind a {@link NutrientViewer.Annotations.MarkupAnnotation}. This can be * useful to get the highlighted text. * * Warning: This is only an approximation. Highlighted text might not always 100% represent the * text, as we just look behind the absolute coordinates to see what text is beneath. PDF * highlight annotations are not markers in the content itself. * * @example * Get the text of all text markup annotations on the first page: * ```ts * const annotations = await instance.getAnnotations(0); * const markupAnnotations = annotations.filter( * annotation => annotation instanceof NutrientViewer.Annotations.MarkupAnnotation * ); * const text = await Promise.all( * markupAnnotations.map(instance.getMarkupAnnotationText) * ); * console.log(text); * ``` * * @param annotation - The text markup annotation you want to extract the text behind. * @returns The text behind the annotation. */ getMarkupAnnotationText(annotation: TextMarkupAnnotationsUnion): Promise; /** * Load all {@link TextLine}s for the specified `pageIndex`. If there is no page * at the given index, the list will be empty. * * @param pageIndex - The index of the page you want to extract text from. * @returns A promise that resolves the text lines of the given page. */ textLinesForPageIndex(pageIndex: number): Promise>; /** * Returns the current {@link DocumentPermissions} of the document. * * @example * const permissions = await instance.getDocumentPermissions(); * * @returns A Promise resolving to an object containing the {@link DocumentPermissions | document permissions} keys along with their status (`true` or `false`). */ getDocumentPermissions(): Promise>; /** * The current zoom level. This will be either the number set in the current * {@link ViewState} or calculated using the {@link ZoomMode}. */ readonly currentZoomLevel: number; /** * The current annotation creator name. This is set using {@link Instance#setAnnotationCreatorName | `instance.setAnnotationCreatorName()`}. */ readonly annotationCreatorName: string | null; /** * The maximum zoom level. This value depends on the current viewport and page dimensions. * Defaults to `10` but can be bigger so that the `FIT_TO_WIDTH` and `FIT_TO_VIEWPORT` * {@link ZoomMode}s always fit. */ readonly maximumZoomLevel: number; /** * The minimum zoom level. This value depends on the current viewport and page dimensions. * Defaults to `0.5` but can be bigger so that the `FIT_TO_WIDTH` and `FIT_TO_VIEWPORT` * {@link ZoomMode}s always fit. */ readonly minimumZoomLevel: number; readonly zoomStep: number; /** * Whether to disable snapping to points when creating annotations * for measurement tools * * @example * instance.setViewState(viewState => viewState.set('disablePointSnapping', true)) */ readonly disablePointSnapping: boolean; /** * Registers an event listener for a specific event type. * * Use this method to listen for changes and actions within the viewer, such as annotation updates, * page navigation, form field changes, and more. Each supported event type is associated with a * specific handler signature, ensuring type safety and clarity. * * A list of all supported events can be found in {@link NutrientViewer.EventName}. * * ##### Usage Notes * - The `action` parameter must be one of the supported event names listed above. * - The `listener` parameter must match the corresponding event listener type for the event. * - You can register multiple listeners for the same event. * - To remove a listener, use {@link Instance#removeEventListener} with the same function reference. * - The event system is modeled after the DOM API: removing a listener requires the exact same function reference as was used for registration. * * If you attempt to register a listener for an unsupported event, a {@link NutrientViewer.Error} will be thrown. * * @example * Registering a listener for a view state change * ```ts * instance.addEventListener("viewState.change", (viewState) => { * console.log(viewState.toJS()); * }); * ``` * * @example * Handling an unknown event (throws an error) * ```ts * try { * instance.addEventListener("doesnotexist", () => {}); * } catch (error) { * (error instanceof NutrientViewer.Error); // => true * } * ``` * * @typeParam K - The event name to listen for. Must be a key of {@link Events.EventNameToHandlerMap}. * @param action - The event name to listen for. See the table above for supported values. * @param listener - The function to be called when the event is emitted. * @throws {NutrientViewer.Error} If the supplied event name is not valid. */ addEventListener(action: K, listener: Events.EventNameToHandlerMap[K]): void; /** * This method can be used to remove an event listener registered via * {@link Instance#addEventListener}. * * It requires the same reference to the function that was used when registering the function * (equality will be verified the same way as it is in the DOM API). * * @example * Proper approach - Use the same reference for registering and removing * ```ts * const callback = someFunction.bind(this) * instance.addEventListener("viewState.zoom.change", callback); * instance.removeEventListener("viewState.zoom.change", callback); * ``` * * @example * Wrong approach - Creates two different functions * ```ts * instance.addEventListener("viewState.zoom.change", someFunction.bind(this)); * // This will not work because `Function#bind()` will create a new function! * instance.removeEventListener("viewState.zoom.change", someFunction.bind(this)); * ``` * * @throws {Error} Will throw an error when the supplied event is not valid. * @param action - The action you want to add an event listener to. See the list * on {@link Instance#addEventListener} for possible event types. * @param listener - A listener function. */ removeEventListener(action: K, listener: Events.EventNameToHandlerMap[K]): void; /** * Brings the rect (in PDF page coordinates) into the viewport. This function will not change * the zoom level. * * This can be used to scroll to specific annotations or search results. * * @example * Jump to the ink annotation * ```ts * instance.jumpToRect(inkAnnotation.pageIndex, inkAnnotation.boundingBox); * ``` * * @throws {Error} Will throw an error when the supplied arguments is not valid. * @param pageIndex - The index of the page you want to have information about. If none * is provided, the first page (pageIndex `0`) will be used. * @param rect - The rect in PDF page coordinates that you want to jump to. */ jumpToRect(pageIndex: number, rect: Rect): void; /** * Brings the rect (in PDF page coordinates) into the viewport. This * function will also change the zoom level so that the rect is visible * completely in the best way possible. * * @example * Jump and zoom to the ink annotation * ```ts * instance.jumpAndZoomToRect(inkAnnotation.pageIndex, inkAnnotation.boundingBox); * ``` * * @throws {Error} Will throw an error when the supplied arguments * are not valid. * @param pageIndex - The index of the page you want to have information about. If none is provided, the first page (pageIndex `0`) will be used. * @param rect - The rect in PDF page coordinates that you want to jump to. */ jumpAndZoomToRect(pageIndex: number, rect: Rect): void; /** * Transforms a {@link NutrientViewer.Geometry.Point} or a {@link NutrientViewer.Geometry.Rect} from the * client space inside the content frame to the PDF page space. * * The content client space is relative to the NutrientViewer mounting container and the same * coordinates that you receive by DOM APIs like `Element.getBoundingClientRect()` or * `MouseEvent.clientX`, etc. that originate within the Nutrient Web SDK's iframe. * * Use this transform when you receive events inside the content frame. * * @throws {Error} Will throw an error when the supplied arguments is not valid. * @param rectOrPoint - The rectangle or point that needs to be transformed * that needs to be transformed * @param pageIndex - The index of the page you want to have information about. If none is provided, the first page (pageIndex `0`) will be used. * @returns The transformed point or rectangle. */ transformContentClientToPageSpace(rectOrPoint: T_1, pageIndex: number): T_1; /** * Transforms a {@link NutrientViewer.Geometry.Point} or a {@link NutrientViewer.Geometry.Rect} from the * PDF page space to the client space inside the content frame. * * The content client space is relative to the NutrientViewer mounting container and the same * coordinates that you receive by DOM APIs like `Element.getBoundingClientRect()` or * `MouseEvent.clientX`, etc. that originate within the Nutrient Web SDK's iframe. * * Use this transform when you want to position elements inside the NutrientViewer content frame. * * @throws {Error} Will throw an error when the supplied arguments is not valid. * @param rectOrPoint - The rectangle or point that needs to be transformed * that needs to be transformed * @param pageIndex - The index of the page you want to have information about. If none is provided, the first page (pageIndex `0`) will be used. * @returns The transformed point or rectangle. */ transformContentPageToClientSpace(rectOrPoint: T_1, pageIndex: number): T_1; /** * Transforms a {@link NutrientViewer.Geometry.Point} or a {@link NutrientViewer.Geometry.Rect} from the * client space inside the main frame to the PDF page space. * * The client space is relative to your HTML viewport and the same coordinates that you receive * by DOM APIs like `Element.getBoundingClientRect()` or `MouseEvent.clientX`, etc. * * Use this transform when you receive events inside the main frame (The `document` of your * application). * * Note: If you apply a CSS scale transformation to the mounting node of Nutrient Web SDK, this * calculation will not work. In this case make sure to manually scale afterwards. * * @throws {Error} Will throw an error when the supplied arguments is not valid. * @param rectOrPoint - The rectangle or point that needs to be transformed * that needs to be transformed * @param pageIndex - The index of the page you want to have information about. If none is provided, the first page (pageIndex `0`) will be used. * @returns The transformed point or rectangle. */ transformClientToPageSpace(rectOrPoint: T_1, pageIndex: number): T_1; /** * Transforms a {@link NutrientViewer.Geometry.Point} or a {@link NutrientViewer.Geometry.Rect} from the * PDF page space to the client space inside the main frame. * * The client space is relative to your HTML viewport and the same coordinates that you receive * by DOM APIs like `Element.getBoundingClientRect()` or `MouseEvent.clientX`, etc. * * Use this transform when you want to position elements inside the main frame. * * Note: If you apply a CSS scale transformation to the mounting node of Nutrient Web SDK, this * calculation will not work. In this case make sure to manually scale afterwards. * * @throws {Error} Will throw an error when the supplied arguments is not valid. * @param rectOrPoint - The rectangle or point that needs to be transformed * that needs to be transformed * @param pageIndex - The index of the page you want to have information about. If none is provided, the first page (pageIndex `0`) will be used. * @returns The transformed point or rectangle. */ transformPageToClientSpace(rectOrPoint: T_1, pageIndex: number): T_1; /** * Transforms a raw PDF bounding rect from the PDF page space to NutrientViewer's page space. * * Use this transform when you want to manage entities using their raw, original coordinates * and dimensions according to the PDF spec (e.g. from a XFDF file). * * @throws {Error} Will throw an error when the supplied arguments is not valid. * @param rawInset - The inset to be transformed * @param pageIndex - The index of the page you want to have information about. * @returns The resulting transformed rectangle. */ transformRawToPageSpace(rawInset: InsetJSON | Inset, pageIndex: number): Rect; /** * Transforms a NutrientViewer page space bounding box to a raw PDF bounding rect. * * A raw PDF bounding rect is an array of inset values: `[left, bottom, right, top]`, * in PDF page space units (as opposted to NutrientViewer page units) where the `top` and `bottom` * coordinates are actually relative to the distance to the bottom of the page. * * Use this transform when you want to manage document entities with external tools. * * @throws {Error} Will throw an error when the supplied arguments is not valid. * @param rect - The rectangle to be transformed * @param pageIndex - The index of the page you want to have information about. * @returns The resulting transformed rectangle as inset coordinates. */ transformPageToRawSpace(rect: Rect, pageIndex: number): Inset; /** * Exports the document converted to the specified output format as an `ArrayBuffer`. This can be used to download the resulting file. * * An `options` object should be passed to the method with a `format` property * set to one of the supported conversion output formats: {@link OfficeDocumentFormat}. * * @example * Download as DOCX * ```ts * instance.exportOffice({ format: NutrientViewer.OfficeDocumentFormat.docx }) * .then(function (buffer) { * const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }); * const objectUrl = window.URL.createObjectURL(blob); * downloadPdf(objectUrl); * window.URL.revokeObjectURL(objectUrl); * }); * * function downloadPdf(blob) { * const a = document.createElement("a"); * a.href = blob; * a.style.display = "none"; * a.download = "download.docx"; * a.setAttribute("download", "download.docx"); * document.body.append(a); * a.click(); * a.remove(); * } * ``` * * @param options - Export options object. * @returns The binary contents of the PDF. */ exportOffice(options: ExportOfficeFlags): Promise; /** * Exports the PDF contents as an `ArrayBuffer`. This can be used to download the PDF. * * If the document is digitally signed and the license includes the Digital Signatures component, * the method will export the document incrementally saved by default, so as not to corrupt signed * data. Otherwise, it will be exported as fully saved by default. * * It's not possible to use `flatten` and `incremental` both set to `true` at the same time, * as flattening is a destructive operation that will necessarily modify the provided document. * * Please see {@link https://www.nutrient.io/guides/web/features/document-processing/ | this guide article} for more information and examples. * * @example * Export the PDF content * ```ts * instance.exportPDF().then(function (buffer) { * buffer; // => ArrayBuffer * }); * ``` * * @example * Export the PDF with password and permissions * ```ts * instance.exportPDF({ * permissions: { * userPassword: "123", * ownerPassword: "123", * documentPermissions: [NutrientViewer.DocumentPermissions.annotationsAndForms] * } * }).then(function (buffer) { * buffer; // => ArrayBuffer * }); * ``` * * @example * Download the PDF by using an `<a>` tag * ```ts * instance.exportPDF().then(function(buffer) { * const supportsDownloadAttribute = HTMLAnchorElement.prototype.hasOwnProperty( * "download" * ); * const blob = new Blob([buffer], { type: "application/pdf" }); * if (navigator.msSaveOrOpenBlob) { * navigator.msSaveOrOpenBlob(blob, "download.pdf"); * } else if (!supportsDownloadAttribute) { * const reader = new FileReader(); * reader.onloadend = function() { * const dataUrl = reader.result; * downloadPdf(dataUrl); * }; * reader.readAsDataURL(blob); * } else { * const objectUrl = window.URL.createObjectURL(blob); * downloadPdf(objectUrl); * window.URL.revokeObjectURL(objectUrl); * } * }); * function downloadPdf(blob) { * const a = document.createElement("a"); * a.href = blob; * a.style.display = "none"; * a.download = "download.pdf"; * a.setAttribute("download", "download.pdf"); * document.body.appendChild(a); * a.click(); * document.body.removeChild(a); * } * ``` * * @param flags - Export options object. * @returns The binary contents of the PDF. */ exportPDF(flags?: ExportPDFFlags): Promise; /** * [XFDF](https://en.wikipedia.org/wiki/Portable_Document_Format#XML_Forms_Data_Format_(XFDF)) can be * used to instantiate a viewer with a diff that is applied to the raw PDF. This format can be * used to store annotation and form field value changes on your server and conveniently * instantiate the viewer with the same content at a later time. * * Instead of storing the updated PDF, this serialization only contains a diff that is applied * on top of the existing PDF and thus allows you to cache the PDF and avoid transferring a * potentially large PDF all the time. * * This method is used to export the current annotations as XFDF. Use * {@link Configuration#XFDF} to load it. * * For Server-Backed setups, only [saved](https://www.nutrient.io/guides/web/annotations/annotation-saving-mechanism/) * annotations will be exported. * * @example * instance.exportXFDF().then(function (xmlString) { * // Persist it to a server * fetch("https://example.com/annotations", { * "Content-Type": "application/vnd.adobe.xfdf", * method: "POST", * body: xmlString * }).then(); * }); * * @param ignorePageRotation - Optional flag to ignore page rotation when exporting XFDF, by default false. * This means that the exported XFDF will contain the annotations in the same orientation as the page and if you * import this XFDF using {@link Configuration#XFDFIgnorePageRotation} the annotations will be imported in the same orientation * no matter the page rotation. * @returns XFDF as a plain text. */ exportXFDF(ignorePageRotation?: boolean): Promise; /** * Print the document programmatically. * * @param options - Print options object. * @throws {NutrientViewer.Error} This method will throw when printing is disabled, currently in * process or when an invalid {@link NutrientViewer.PrintMode} was supplied. */ print(options?: IPrintMode | { /**Optional print mode. See {@link NutrientViewer.PrintMode} */ mode?: IPrintMode; /** * Whether to exclude annotations from the printout. * * @default false */ excludeAnnotations?: boolean; }): void; /** * Sets the annotation creator name. * Each created annotation will have the creators name set in the author property. */ setAnnotationCreatorName(annotationCreatorName?: string | null): void; /** * Sets the current custom renderers. * When this function is called with a new {@link CustomRenderers} object, * all visible custom rendered annotations are immediately updated. */ setCustomRenderers(customRenderers: CustomRenderers): void; /** * Sets the current custom UI configuration. * When this function is called with a new {@link CustomUI} object, * all visible sidebars are immediately updated. * * @param customUIConfigurationOrCustomUIConfigurationSetter - The custom UI configuration or the custom UI configuration setter. */ setCustomUIConfiguration(customUIConfigurationOrCustomUIConfigurationSetter: CustomUIConfigurationSetter | Partial>>): void; /** * You can use this callback to set/modify the toolbar items present in the inline toolbar * after the document has loaded. * * The callback will receive the * default items of the inline toolbar and the text that is currently selected {@link NutrientViewer.TextSelection} * * You can do the following modifications using this API: * * - Add new items. * - Remove existing items. * - Change the order of the items. * - Customise each item eg change the `icon` of the a default toolbar item. * * You can also use the `hasDesktopLayout` flag provided to the callback to determine if the current UI is being rendered on * mobile or desktop. Based on that, you can implement different designs for Desktop and Mobile. * * This callback gets called every time the inline toolbar is mounted. * * @example * Add a custom button and a custom node to the toolbar. * ```ts * instance.setInlineTextSelectionToolbarItems(({ defaultItems, hasDesktopLayout }, selection) => { * console.log(selection) * if (hasDesktopLayout) { * const node = document.createElement("div"); * node.innerText = "Custom Item"; * return [ * ...defaultItems, * { * type: "custom", * id: "custom-1", * node: node, * className: "Custom-Node", * onPress: () => alert("Custom node pressed!"), * }, * { * type: "custom", * id: "custom-2", * title: "custom-button-2", * onPress: () => alert("Custom item pressed!"), * }, * ]; * } * return defaultItems * }); * ``` * * @public * @param inlineTextSelectionToolbarItemsCallback - The callback to set the inline text selection toolbar items. */ setInlineTextSelectionToolbarItems(inlineTextSelectionToolbarItemsCallback: InlineTextSelectionToolbarItemsCallback): void; /** * Aborts the current print job. * * @throws {Error} This method will throw when printing is disabled or no printing is currently being processed. */ abortPrint(): void; /** * Returns the document outline (table of content). * * @returns A promise that resolves to a {@link NutrientViewer.Immutable.List} of {@link NutrientViewer.OutlineElement} */ getDocumentOutline(): Promise>; /** * Sets the document outline (table of content). * * @standalone * @public * @param outline - The outline to set. * @returns A promise that resolves when the outline has been set. */ setDocumentOutline(outline: List): Promise; /** * *** Standalone only *** * * Creates a new OCG layer in the document. * * The created layer can be used as a target for {@link DocumentOperations.FlattenAnnotationsOperation} * to flatten annotations into a togglable layer rather than directly into page content. * * @example * const layer = await instance.createLayer({ name: 'User A Annotations' }); * console.log(layer); // => { name: 'User A Annotations', ocgId: 42 } * * @param options - Options for the new layer. * @param options.name - The name of the layer. * @returns A promise that resolves to the created {@link OCGLayer}. */ createLayer(options: { name: string; }): Promise; /** * Returns the {@link PageInfo} for the specified page index. * If there is no page at the given index, returns `null`. * * @example * // Get information about the first page * const info = instance.pageInfoForIndex(0); * if (info) { * console.log(info.width, info.height); * } * * @public * @param pageIndex - The index of the page you want to have information about * @returns The {@link PageInfo} or `null`. */ pageInfoForIndex(pageIndex: number): PageInfo | null; /** * The total number of pages in the current document. * * @example * // Log the total number of pages * console.log(instance.totalPageCount); */ readonly totalPageCount: number; /** * Access the shadow root object of the Nutrient Web SDK's viewer. This can be used to quickly * interact with elements (using our public CSS API) inside the viewer. * * When the iframe fallback is set, this property provides access the `document` object of * the Nutrient Web SDK's viewer frame instead. * * @example * instance.contentDocument.addEventListener("mouseup", handleMouseUp); */ readonly contentDocument: Document | ShadowRoot; /** * Access the `window` object of the Nutrient Web SDK's viewer frame. This can be used to quickly * interact with elements (using our public CSS API) inside the viewer. * * @example * instance.contentWindow.location; */ readonly contentWindow: Window; /** * *** Standalone only *** * * Sets the OCG visibility state. * * This method takes an {@link OCGLayersVisibilityState} object as an argument, which contains * a `visibleLayerIds` `Array` that contains the list of layers identified by their `ocgId`, and * makes them visible, hiding any other layers not included in the `Array`. * * @example * instance.setLayersVisibilityState({ * visibleLayerIds: [1, 2, 3] * }) * * @param layersVisibilityState - The OCG visibility state to set. * @returns A promise that resolves when the OCG visibility state has been set. */ setLayersVisibilityState(layersVisibilityState: OCGLayersVisibilityState): Promise; /** * *** Standalone only *** * * Returns the current OCG layers visibility state. * * OCG layers are groups of content in the document, that can be shown or hidden independently. * * This method returns the current visibility state of the layers in the document as an object * with a `visibleLayerIds` `Array` that contains the list of layers identified by their `ocgId` * number, which are currently visible. * * @example * instance.getLayersVisibilityState().then(function (layersVisibilityState) { * console.log(layersVisibilityState); // => { visibleLayerIds: [1, 2, 3] } * }); * * @returns A promise that resolves to a {@link NutrientViewer.LayersVisibilityState} */ getLayersVisibilityState(): Promise; /** * [Instant JSON](https://www.nutrient.io/guides/web/importing-exporting/instant-json/) can be * used to instantiate a viewer with a diff that is applied to the raw PDF. This format can be * used to store annotation and form field value changes on your server and conveniently * instantiate the viewer with the same content at a later time. * * Instead of storing the updated PDF, this serialization only contains a diff that is applied * on top of the existing PDF and thus allows you to cache the PDF and avoid transferring a * potentially large PDF all the time. * * This method is used to export the current annotations as Instant JSON. Use * {@link Configuration#instantJSON} to load it. * * `annotations` will follow the [Instant Annotation JSON format specification](https://www.nutrient.io/guides/document-engine/json/). * `formFieldValues` will follow the [Instant Form Field Value JSON format specification](https://www.nutrient.io/guides/document-engine/json/). * * Optionally a `version` argument can be provided to specify the Instant JSON version to use for exported annotations. * * For Server-Backed setups, only [saved](https://www.nutrient.io/guides/web/annotations/annotation-saving-mechanism/) * annotations will be exported. * * @example * instance.exportInstantJSON().then(function (instantJSON) { * // Persist it to a server * fetch("https://example.com/annotations", { * "Content-Type": "application/json", * method: "POST", * body: JSON.stringify(instantJSON) * }).then(); * }); * * @public * @param version - Optional Instant JSON version for annotations. * @returns Instant JSON as a plain JavaScript object. */ exportInstantJSON(version?: number): Promise; /** * Set the UI customization config. * This method allows you to change the UI configuration of an already mounted instance. * The provided configuration will replace the previous configuration entirely. * * In case of partial updates, you should merge the previous configuration with new changes. * * Refer to the [guide](https://www.nutrient.io/guides/web/user-interface/ui-customization/set-ui/) * for more information and examples. * * @example * instance.setUI({ * commentThread: () => ({ * render: () => { * const div = document.createElement("div"); * div.innerText = "Custom Comment Thread"; * div.style.padding = "10px"; * * return div; * } * }) * }) * * @public * @instance * @function setUI * @memberof NutrientViewer.Instance * @param configuration - The new UI configuration to set. */ setUI(configuration: UI.Configuration): void; }; } & T; declare const ModificationType: { /** The change was created. */ readonly CREATED: "CREATED"; /** The change was updated. */ readonly UPDATED: "UPDATED"; /** The change was deleted. */ readonly DELETED: "DELETED"; }; declare interface MutableRefObject { current: T; } /** * @class * PDF action to trigger a named action. This action is not implemented yet. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `action.set("action", "nextPage");`. * @example * Create a new NamedAction * ```ts * const action = new NutrientViewer.Actions.NamedAction({ action: "nextPage" }); * ``` * * @summary Trigger a named action. */ export declare class NamedAction extends Action { /** * The name of the action. This includes but is not limited to the following actions: * * Supported: * - `nextPage` * - `prevPage` * - `firstPage` * - `lastPage` * - `find` * - `print` * - `outline` * - `search` * - `zoomIn` * - `zoomOut` * - `saveAs` * - `fullScreen` * * Not supported: * - `goBack` * - `goForward` * - `goToPage` * - `brightness` * - `info` * - `close` * - `quit` */ action: string; constructor(options?: INamedAction); } declare type NamedCustomAction = 'GoBack' | 'GoForward' | 'GoToPage' | 'Find' | 'Print' | 'Outline' | 'Search' | 'Brightness' | 'ZoomIn' | 'ZoomOut' | 'SaveAs' | 'Info' | 'FullScreen' | 'Close' | 'Quit'; /** @inline */ declare interface NodeAnnotationToolbarItem extends Omit { /** * ***required*** * * The type of an annotation toolbar item. * * It can either be `custom` for user defined items, or one of the built-in annotation toolbar types. * * The built-in types are: * * - `stroke-color` * - `fill-color` * - `background-color` * - `opacity` * - `line-width` * - `line-style` * - `linecaps-dasharray` * - `blend-mode` * - `delete` * - `spacer` * - `annotation-note` * - `border-style` * - `border-width` * - `border-color` * - `apply-redactions` * - `color` * - `font` * - `outline-color` * - `overlay-text` * - `note-icon` * - `clockwise-rotation` * - `counterclockwise-rotation` * * Different annotations have different built-in toolbar items but all of them belong to the one mentioned above. If you pass a `type` * that isn't supported by an annotation, you will get an error. * * Note: It is ***not*** possible to override this option for built-in toolbar items. * * @example * NutrientViewer.load({ * ...otherOptions, * annotationToolbarItems: (annotation, { defaultAnnotationToolbarItems }) => { * return [...defaultAnnotationToolbarItems, { * type: 'custom', * // other properties... * }] * } * }); */ type: IAnnotationToolbarType; } /** * @class * Note annotations are "sticky notes" attached to a point in the PDF document. * They are represented as markers and each of them as an icon associated to it. * Its text content is revealed on selection. * *
* *
* @example Create a note annotation * const annotation = new NutrientViewer.Annotations.NoteAnnotation({ * pageIndex: 0, * text: { format: "plain", value : "Remember the milk" }, * boundingBox: new NutrientViewer.Geometry.Rect({ left: 10, top: 20, width: 30, height: 40 }), * }); * * @summary A text note that will be rendered inside the bounding box. * @see {@link Instance#setEditingAnnotation} */ export declare class NoteAnnotation extends Annotation { /** * The note contents in plain text formats. * We don't support rich text formatting in the text field. * * @default "" */ text: { format: 'plain'; value: string; }; /** * The icon to represent the collapsed annotation in the document. * * @default {@link NutrientViewer.NoteIcon|NutrientViewer.NoteIcon.COMMENT} */ icon: INoteIcon; /** * Background color that will fill the complete bounding box. * * @default new Color({ r: 255, g: 216, b: 63 }) - yellow */ color: Color; static isEditable: boolean; static readableName: string; } /** * @deprecated Use {@link Serializers.NoteAnnotationJSON} instead. * @hidden */ export declare type NoteAnnotationJSON = Serializers.NoteAnnotationJSON; declare class NoteAnnotationSerializer extends AnnotationSerializer { annotation: NoteAnnotation; constructor(annotation: NoteAnnotation); toJSON(): Serializers.NoteAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): NoteAnnotation; } /** * Available icons for Note Annotations. * * @enum */ declare const NoteIcon: { /** A speech bubble icon, typically used for general comments. */ readonly COMMENT: "COMMENT"; /** A pointing hand icon facing right. */ readonly RIGHT_POINTER: "RIGHT_POINTER"; /** An arrow icon pointing to the right. */ readonly RIGHT_ARROW: "RIGHT_ARROW"; /** A checkmark icon, typically used to indicate approval or completion. */ readonly CHECK: "CHECK"; /** A circular icon. */ readonly CIRCLE: "CIRCLE"; /** A cross or X icon, typically used to indicate rejection or deletion. */ readonly CROSS: "CROSS"; /** An insertion caret icon, typically used to indicate where text should be inserted. */ readonly INSERT: "INSERT"; /** A paragraph symbol icon indicating a new paragraph should be started. */ readonly NEW_PARAGRAPH: "NEW_PARAGRAPH"; /** A note or sticky note icon. */ readonly NOTE: "NOTE"; /** A paragraph symbol icon. */ readonly PARAGRAPH: "PARAGRAPH"; /** A help or question mark icon. */ readonly HELP: "HELP"; /** A star icon, typically used for highlighting important items. */ readonly STAR: "STAR"; /** A key icon, typically used to indicate important information. */ readonly KEY: "KEY"; }; declare namespace NutrientViewer { export { Annotations, Immutable_2 as Immutable, Geometry, Actions, AnnotationPresets, FormFields, Comment_2 as Comment, Bookmark, CustomOverlayItem, OutlineElement, FormFieldValue, FormOption, Callout, ComparisonOperation, DocumentDescriptor, Instance, preloadWorker, convertToOffice, convertToPDF, load, populateDocumentTemplate, unload, loadTextComparison, build, PSPDFKitError as Error, PSPDFKitSaveError as SaveError, ViewState, TextLine, PageInfo, InstantClient, TextSelection, SearchResult, SearchState, HighlightState, AutoSaveMode, SignatureSaveMode, LayoutMode, PrintMode, PrintQuality, ScrollMode, ZoomMode, CommentDisplay, InteractionMode, InkEraserMode as unstable_InkEraserMode, SidebarMode, UIElement, Alignment, BlendMode, BorderStyle, LineCap, SidebarPlacement, SignatureAppearanceMode, ShowSignatureValidationStatusMode, NoteIcon, Theme, ToolbarPlacement, ElectronicSignatureCreationMode, _default as I18n, CertificateChainValidationStatus, DocumentIntegrityStatus, PAdESLevel, SignatureContainerType, SignatureType, SignatureValidationStatus, DocumentValidationStatus, AnnotationsWillChangeReason, DocumentComparisonSourceType, MeasurementScaleUnitFrom, MeasurementScaleUnitTo, EventName, MeasurementPrecision, MeasurementScale, ProductId, ProcessorEngine, Conformance, DocumentPermissionsEnum as DocumentPermissions, ComparisonOperationType, OfficeDocumentFormat, WheelZoomMode, SearchPattern, SearchType, UIDateTimeElement, AIComparisonOperationType, AIComparisonPhase, isAIDocumentAnalysisResult, isAIDocumentComparisonResult, isAIDocumentTaggingResult, viewStateFromOpenParameters, version, baseUrl, Color, defaultElectronicSignatureColorPresets, defaultToolbarItems, defaultDocumentEditorFooterItems, defaultDocumentEditorToolbarItems, defaultTextComparisonToolbarItems, defaultTextComparisonInnerToolbarItems, defaultAnnotationPresets, defaultStampAnnotationTemplates, defaultAnnotationsSidebarContent, _default_2 as defaultEditableAnnotationTypes, _default_3 as defaultElectronicSignatureCreationModes, _default_4 as defaultSigningFonts, Options, generateInstantId, Font, UI_2 as UI, Maui }; } declare type OCGLayer = { /** The name of the layer. */ name: string; /** The unique ID of the layer. */ ocgId: number; /** The ID of the radio group this layer belongs to. */ radioGroup?: number; }; export declare type OCGLayersVisibilityState = { /** An array of visible layer IDs. */ visibleLayerIds: number[]; }; /** * *** Standalone Only *** * * Options for exporting the document to PDF from an office format. * * Some properties are only used when exporting specific Office formats, such as XLSX or DOCX. * * @example * ``` * const officeDocument = await fetch('example.xlsx').then(response => response.arrayBuffer()) * NutrientViewer.convertToPDF(file, null, { * splitExcelSheetsIntoPages: true, * spreadsheetMaximumContentHeightPerSheet: 1000, * spreadsheetMaximumContentWidthPerSheet: 50, * }) * ``` * * @example * ``` * const officeDocument = await fetch('example.docx').then(response => response.arrayBuffer()) * NutrientViewer.convertToPDF(file, null, { * documentMarkupMode: 'original', * }) * ``` * * @standalone * @default { splitExcelSheetsIntoPages: false, spreadsheetRenderOnlyPrintArea: true, documentMarkupMode: 'noMarkup' } */ export declare type OfficeConversionSettings = { /** If true, each sheet in the Excel document will be exported as a separate page in the PDF. */ splitExcelSheetsIntoPages?: boolean; /** The maximum height of the content in a single sheet. If the content exceeds this height, it will be split into multiple pages. */ spreadsheetMaximumContentHeightPerSheet?: number; /** The maximum width of the content in a single sheet. If the content exceeds this width, it will be split into multiple pages. */ spreadsheetMaximumContentWidthPerSheet?: number; /** If true, only the print area of spreadsheet sheets will be rendered. If no print area is defined, the entire sheet is rendered. */ spreadsheetRenderOnlyPrintArea?: boolean; documentMarkupMode?: DocumentMarkupMode; }; /** * Document conversion output formats. * * @enum */ export declare const OfficeDocumentFormat: { /** DOCX document format. */ readonly docx: "docx"; /** XLSX document format. */ readonly xlsx: "xlsx"; /** PPTX document format. */ readonly pptx: "pptx"; }; /** * You can programmatically modify the properties of the comment just before it is created. * * @public * @param comment - The comment. * @example * Set default text of a Comment * ```ts * NutrientViewer.load({ * onCommentCreationStart: comment => comment.set('text', { format: 'xhtml', value: '

This comment has a default value

' }) * // ... * }); * ``` * */ export declare type OnCommentCreationStartCallback = (comment: Comment_2) => Comment_2; /** * By default, all the URLs on which the user clicks explicitly open as expected but the URLs which open due to a result of JavaScript action are not opened due to security reasons. * You can override this behaviour using this callback. If this callback returns `true`, the URL will open. * * For more information, see {@link Configuration#onOpenURI}. * * @public * @param uri - The URL to open. * @param isUserInitiated - Tells you whether the URL is being opened because of user's interaction or not. * @example * Render rectangle annotations using their AP stream * ```ts * NutrientViewer.load({ * onOpenURI: (url, isUserInitiated) => { * if (url.startsWith('https://abc.com') && isUserInitiated) { * return true * } * * return false; * } * // ... * }); * ``` * */ export declare type OnOpenUriCallback = (uri: string, isUserInitiated: boolean) => boolean; /** * You can programmatically modify the properties of the widget annotation and the associated form field just * before it is created via the form creator UI. * * @public * @param annotation - The widget annotation that is about to be created. * @param formField - The original form field that is associated with the widget annotation. * @example * Set the opacity of all widget annotations. * ```ts * NutrientViewer.load({ * onWidgetAnnotationCreationStart: (annotation, formField) => { * return { annotation: annotation.set('opacity', 0.7) }; * } * // ... * }); * ``` * */ export declare type OnWidgetAnnotationCreationStartCallback = (annotation: WidgetAnnotation, formField: FormField) => { annotation?: WidgetAnnotation; formField?: FormField; }; /** @inline */ declare type OperationAttachment = string | File | Blob; declare type OPFSTempStorageConfiguration = { mode: 'opfs'; /** * Minimum file size in bytes required before OPFS is used. * If omitted, OPFS is attempted for eligible Core-directed URL loads regardless of size. */ minFileSize?: number; }; declare type OptimizationFlags = { documentFormat?: 'pdf' | 'pdfa'; grayscaleText?: boolean; grayscaleGraphics?: boolean; grayscaleFormFields?: boolean; grayscaleAnnotations?: boolean; grayscaleImages?: boolean; disableImages?: boolean; mrcCompression?: boolean; imageOptimizationQuality?: 1 | 2 | 3 | 4; linearize?: boolean; }; /** * Custom values for default options. These values will be frozen the first time * `NutrientViewer.load` is called, and won't be modifiable after that. * * @example * Set minimum ink annotation size. * ```ts * NutrientViewer.Options.MIN_INK_ANNOTATION_SIZE = 64; * NutrientViewer.load(); * ``` * * @namespace */ declare const Options: { /** * Minimum size of text annotations, in pixels. * * @default 5 */ MIN_TEXT_ANNOTATION_SIZE: number; /** * Minimum size of ink annotations, in pixels. * * @default 16 */ MIN_INK_ANNOTATION_SIZE: number; /** * Minimum size of shape annotations, in pixels. * * @default 16 */ MIN_SHAPE_ANNOTATION_SIZE: number; /** * Minimum size of image annotations, in pixels. * * @default 5 */ MIN_IMAGE_ANNOTATION_SIZE: number; /** * Minimum size of stamp annotations, in pixels. * * @default 15 */ MIN_STAMP_ANNOTATION_SIZE: number; /** * Minimum size of widget annotations, in pixels. * * @default 3 */ MIN_WIDGET_ANNOTATION_SIZE: number; /** * Enable smooth lines for ink annotations. * * @default true */ ENABLE_INK_SMOOTH_LINES: boolean; /** * Minimum range between two points for an ink annotation, in pixels. If set to 0, the optimization is disabled. * * @default 10 */ INK_EPSILON_RANGE_OPTIMIZATION: number; /** * Saving strategy for ink signatures. * * @default NutrientViewer.SignatureSaveMode.USING_UI */ SIGNATURE_SAVE_MODE: ISignatureSaveMode; /** * The default width of the sidebar on desktop browsers. * * @default 300 */ INITIAL_DESKTOP_SIDEBAR_WIDTH: number; /** * Enables all the features by ignoring the document permissions. * * @default false */ IGNORE_DOCUMENT_PERMISSIONS: boolean; /** * Receives a {@link NutrientViewer.Geometry.Size} object with the current viewport dimensions (width and * height) and returns the padding that will be added between an annotation and the selection * outline in px. * * The default implementation will increase the outline padding on small devices. * * @param viewportSize */ SELECTION_OUTLINE_PADDING: (viewportSize: Size) => number; /** * Receives a {@link Geometry.Size} object with the current viewport dimensions (width * and height) and returns the radius of the selection resize / modification anchors in px. * * The default implementation will increase the anchor radius on small device. * * @param viewportSize */ RESIZE_ANCHOR_RADIUS: (viewportSize: Size) => number; /** * Stroke width of the selection outline rectangle in px. * * @default 2 */ SELECTION_STROKE_WIDTH: number; /** * Control whether NutrientViewer should adjust the font size * to fit the text in the annotation bounding box when exporting the annotation. * * @default true */ TEXT_ANNOTATION_AUTOFIT_TEXT_ON_EXPORT: boolean; /** * Control whether NutrientViewer should adjust the text annotations' bounding box * to fit the text in the annotation when editing it. * * @default true */ TEXT_ANNOTATION_AUTOFIT_BOUNDING_BOX_ON_EDIT: boolean; /** * Control whether NutrientViewer should adjust the font size when resizing text annotations * with the bottom right knob. * * @default true */ TEXT_ANNOTATION_AUTOFIT_ON_BOTTOM_KNOB_RESIZE: boolean; /** * Disable all the NutrientViewer keyboard shortcuts. * * @default false */ DISABLE_KEYBOARD_SHORTCUTS: boolean; /** * Set the default width of the ink eraser cursor. * * Note: setting the default width of the ink eraser cursor using this setting is now deprecated. Use the `inkEraserWidth` property of the `ink` annotation preset instead. * * @deprecated * @default false */ DEFAULT_INK_ERASER_CURSOR_WIDTH: number; /** * The list of colors to use for color dropdowns in annotation toolbars. * * @deprecated * @default Red, Orange, Yellow, Green, Blue, Purple, Pink, Light Orange, Light Yellow, Light Green, Light Blue, Mauve, Transparent, White, Light Grey, Grey, Dark Grey, Black * @example * NutrientViewer.Options.COLOR_PRESETS = [ * { * color: new NutrientViewer.Color({ r: 255, g: 0, b: 0 }), * localization: { * id: "brightRed", * defaultMessage: "Bright Red" * } * }, * { * color: new NutrientViewer.Color({ r: 0, g: 0, b: 180 }), * localization: { * id: "deepBlue", * defaultMessage: "Deep Blue" * } * }, * { * color: new NutrientViewer.Color({ transparent: true }), * localization: { * id: "transparent", * defaultMessage: "Transparent" * } * } * ]; */ COLOR_PRESETS: ColorPreset[]; /** * The list of line caps to use for dropdowns in annotation toolbars. * * @default ["none", "square", "circle", "diamond", "openArrow", "closedArrow", "butt", "reverseOpenArrow", "reverseClosedArrow", "slash"] * @example * NutrientViewer.Options.LINE_CAP_PRESETS = ["openArrow", "closedArrow", "none"]; */ LINE_CAP_PRESETS: Array; /** * The list of line widths to use for dropdowns in annotation toolbars. * * @default null * @example * NutrientViewer.Options.LINE_WIDTH_PRESETS = [1, 2, 4, 8, 32]; */ LINE_WIDTH_PRESETS: Array | null | undefined; /** * The list of colors to use in the text highlight annotation toolbar. You can't use transparent for this. * * @default Light Yellow, Light Blue, Light Green, Light Red * @example * NutrientViewer.Options.HIGHLIGHT_COLOR_PRESETS = [ * { * color: new NutrientViewer.Color({ r: 255, g: 0, b: 0 }), * localization: { * id: "brightRed", * defaultMessage: "Bright Red" * } * }, * { * color: new NutrientViewer.Color({ r: 0, g: 0, b: 180 }), * localization: { * id: "deepBlue", * defaultMessage: "Deep Blue" * } * } * ]; */ HIGHLIGHT_COLOR_PRESETS: Array; /** * The list of colors to use in the text markup annotation toolbar. * * @default Black, Blue, Red, Green * @example * NutrientViewer.Options.TEXT_MARKUP_COLOR_PRESETS = [ * { * color: new NutrientViewer.Color({ r: 255, g: 0, b: 0 }), * localization: { * id: "brightRed", * defaultMessage: "Bright Red" * } * }, * { * color: new NutrientViewer.Color({ r: 0, g: 0, b: 180 }), * localization: { * id: "deepBlue", * defaultMessage: "Deep Blue" * } * } * ]; */ TEXT_MARKUP_COLOR_PRESETS: Array; /** * The list of colors to use for note annotations. You can't pass transparent color as an option. * * @default Yellow, Orange, Red, Fuchsia, Blue, Green * @example * NutrientViewer.Options.NOTE_COLOR_PRESETS = [ * { * color: new NutrientViewer.Color({ r: 255, g: 0, b: 0 }), * localization: { * id: "brightRed", * defaultMessage: "Bright Red" * } * }, * { * color: new NutrientViewer.Color({ r: 0, g: 0, b: 180 }), * localization: { * id: "deepBlue", * defaultMessage: "Deep Blue" * } * } * ]; */ NOTE_COLOR_PRESETS: Array; /** * Enables PDF JavaScript support. PDF documents may contain JavaScript for interactivity. * This enables things like form validation, formatting, or automatic calculation which are performed by a JavaScript scripts * inside the PDF document. * * Disabling JavaScript improves the general performance of the framework when PDF JavaScript support is not needed. * * This feature is only available on standalone deployments for now. * * @standalone * @default true */ PDF_JAVASCRIPT: boolean; /** * Internally our breakpoint logic is applied to singular toolbar buttons, not to the whole main toolbar. * The next two members allow to set custom breakpoints to control the toolbar buttons responsive mode. * * Specifies a viewport width breakpoint for medium screens used by some toolbar buttons to switch to responsive mode. * * @default 1070 */ BREAKPOINT_MD_TOOLBAR: number; /** * Specifies a viewport width breakpoint for small screens used by some toolbar buttons to switch to responsive mode. * * @default 768 */ BREAKPOINT_SM_TOOLBAR: number; /** * Specifies a viewport width breakpoint for secondary toolbar responsive mode. Beyond this breakpoint, the secondary toolbar will be displayed as a desktop toolbar * in its expanded state. * * @default 1070 */ ANNOTATION_TOOLBAR_RESPONSIVE_BREAKPOINT: number; }; /** * Creates a new Immutable OrderedMap. * * Created with the same key value pairs as the provided Collection.Keyed or * JavaScript Object or expects a Collection of [K, V] tuple entries. * * The iteration order of key-value pairs provided to this constructor will * be preserved in the OrderedMap. * * let newOrderedMap = OrderedMap({key: "value"}) * let newOrderedMap = OrderedMap([["key", "value"]]) * * Note: `OrderedMap` is a factory function and not a class, and does not use * the `new` keyword during construction. */ declare function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; declare function OrderedMap(collection: Iterable>): OrderedMap; declare function OrderedMap(obj: {[key: string]: V;}): OrderedMap; declare function OrderedMap(): OrderedMap; declare function OrderedMap(): OrderedMap; /** * A type of Map that has the additional guarantee that the iteration order of * entries will be the order in which they were set(). * * The iteration behavior of OrderedMap is the same as native ES6 Map and * JavaScript Object. * * Note that `OrderedMap` are more expensive than non-ordered `Map` and may * consume more memory. `OrderedMap#set` is amortized O(log32 N), but not * stable. */ declare module OrderedMap { /** * True if the provided value is an OrderedMap. */ function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; } declare interface OrderedMap extends Map_2 { /** * The number of entries in this OrderedMap. */ readonly size: number; /** * Returns a new OrderedMap also containing the new key, value pair. If an * equivalent key already exists in this OrderedMap, it will be replaced * while maintaining the existing order. * * * ```js * const { OrderedMap } = require('immutable') * const originalMap = OrderedMap({a:1, b:1, c:1}) * const updatedMap = originalMap.set('b', 2) * * originalMap * // OrderedMap {a: 1, b: 1, c: 1} * updatedMap * // OrderedMap {a: 1, b: 2, c: 1} * ``` * * Note: `set` can be used in `withMutations`. */ set(key: K, value: V): this; /** * Returns a new OrderedMap resulting from merging the provided Collections * (or JS objects) into this OrderedMap. In other words, this takes each * entry of each collection and sets it on this OrderedMap. * * Note: Values provided to `merge` are shallowly converted before being * merged. No nested values are altered. * * * ```js * const { OrderedMap } = require('immutable') * const one = OrderedMap({ a: 10, b: 20, c: 30 }) * const two = OrderedMap({ b: 40, a: 50, d: 60 }) * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } * two.merge(one) // OrderedMap { "b": 20, "a": 10, "d": 60, "c": 30 } * ``` * * Note: `merge` can be used in `withMutations`. * * @alias concat */ merge(...collections: Array>): OrderedMap; merge(...collections: Array<{[key: string]: C;}>): OrderedMap; concat(...collections: Array>): OrderedMap; concat(...collections: Array<{[key: string]: C;}>): OrderedMap; // Sequence algorithms /** * Returns a new OrderedMap with values passed through a * `mapper` function. * * OrderedMap({ a: 1, b: 2 }).map(x => 10 * x) * // OrderedMap { "a": 10, "b": 20 } * * Note: `map()` always returns a new instance, even if it produced the same * value at every step. */ map( mapper: (value: V, key: K, iter: this) => M, context?: any) : OrderedMap; /** * @see Collection.Keyed.mapKeys */ mapKeys( mapper: (key: K, value: V, iter: this) => M, context?: any) : OrderedMap; /** * @see Collection.Keyed.mapEntries */ mapEntries( mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any) : OrderedMap; /** * Flat-maps the OrderedMap, returning a new OrderedMap. * * Similar to `data.map(...).flatten(true)`. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, context?: any) : OrderedMap; /** * Returns a new OrderedMap with only the entries for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: V, key: K, iter: this) => value is F, context?: any) : OrderedMap; filter( predicate: (value: V, key: K, iter: this) => any, context?: any) : this; /** * @see Collection.Keyed.flip */ flip(): OrderedMap; } /** * Create a new immutable OrderedSet containing the values of the provided * collection-like. * * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ declare function OrderedSet(): OrderedSet; declare function OrderedSet(): OrderedSet; declare function OrderedSet(collection: Iterable): OrderedSet; /** * A type of Set that has the additional guarantee that the iteration order of * values will be the order in which they were `add`ed. * * The iteration behavior of OrderedSet is the same as native ES6 Set. * * Note that `OrderedSet` are more expensive than non-ordered `Set` and may * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not * stable. */ declare module OrderedSet { /** * True if the provided value is an OrderedSet. */ function isOrderedSet(maybeOrderedSet: any): boolean; /** * Creates a new OrderedSet containing `values`. */ function of(...values: Array): OrderedSet; /** * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing * the keys from this Collection or JavaScript Object. */ function fromKeys(iter: Collection): OrderedSet; function fromKeys(obj: {[key: string]: any;}): OrderedSet; } declare interface OrderedSet extends Set_2 { /** * The number of items in this OrderedSet. */ readonly size: number; /** * Returns an OrderedSet including any value from `collections` that does * not already exist in this OrderedSet. * * Note: `union` can be used in `withMutations`. * @alias merge * @alias concat */ union(...collections: Array>): OrderedSet; merge(...collections: Array>): OrderedSet; concat(...collections: Array>): OrderedSet; // Sequence algorithms /** * Returns a new Set with values passed through a * `mapper` function. * * OrderedSet([ 1, 2 ]).map(x => 10 * x) * // OrderedSet [10, 20] */ map( mapper: (value: T, key: T, iter: this) => M, context?: any) : OrderedSet; /** * Flat-maps the OrderedSet, returning a new OrderedSet. * * Similar to `set.map(...).flatten(true)`. */ flatMap( mapper: (value: T, key: T, iter: this) => Iterable, context?: any) : OrderedSet; /** * Returns a new OrderedSet with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: T, key: T, iter: this) => value is F, context?: any) : OrderedSet; filter( predicate: (value: T, key: T, iter: this) => any, context?: any) : this; /** * Returns an OrderedSet of the same type "zipped" with the provided * collections. * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * ```js * const a = OrderedSet([ 1, 2, 3 ]) * const b = OrderedSet([ 4, 5, 6 ]) * const c = a.zip(b) * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ zip(other: Collection): OrderedSet<[T, U]>; zip(other1: Collection, other2: Collection): OrderedSet<[T, U, V]>; zip(...collections: Array>): OrderedSet; /** * Returns a OrderedSet of the same type "zipped" with the provided * collections. * * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * * ```js * const a = OrderedSet([ 1, 2 ]); * const b = OrderedSet([ 3, 4, 5 ]); * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` * * Note: Since zipAll will return a collection as large as the largest * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ zipAll(other: Collection): OrderedSet<[T, U]>; zipAll(other1: Collection, other2: Collection): OrderedSet<[T, U, V]>; zipAll(...collections: Array>): OrderedSet; /** * Returns an OrderedSet of the same type "zipped" with the provided * collections by using a custom `zipper` function. * * @see Seq.Indexed.zipWith */ zipWith( zipper: (value: T, otherValue: U) => Z, otherCollection: Collection) : OrderedSet; zipWith( zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection) : OrderedSet; zipWith( zipper: (...any: Array) => Z, ...collections: Array>) : OrderedSet; } /** * This record is used to represent document outline elements. * These allow the user to navigate interactively from one part of the document to another. * * Outline elements can be nested in a tree-like structure where elements are collapsible/expandable * to hide/reveal their subtrees. * * @public * @summary Element in the document outline tree. */ export declare class OutlineElement extends OutlineElement_base {} declare const OutlineElement_base: Record_2.Factory; /** @inline */ declare type OutlineElementProps = { /** * Each outline element can have nested outline elements. * The visibility of which is controlled by {@link OutlineElement.isExpanded}. * * @see {@link Instance#getDocumentOutline} */ children: List; /** * The outline element title, must be human readable. */ title: string; /** * The text color of the outline element title. * When this value is `null` the color is the Nutrient Web SDK's UI's default color * which can be configured via NutrientViewer's public CSS API. * * @default null */ color: Color | null; /** * Whether the outline element title is bold. * * @default false */ isBold: boolean; /** * Whether the outline element title is italic. * * @default false */ isItalic: boolean; /** * Whether the outline element is expanded and shows its child elements. * * @default false */ isExpanded: boolean; /** * The action that will be triggered when the outline element is either clicked or tapped. * * Please refer to {@link NutrientViewer.Actions} for an in-depth look at PDF actions. */ action: Action | null; }; /** * The different PAdES (PDF Advanced Electronic Signatures) conformance levels. * * @enum */ export declare const PAdESLevel: { /** PAdES B-B (Basic) - Baseline signature with basic cryptographic verification. */ readonly b_b: "b-b"; /** PAdES B-T (Timestamp) - Baseline signature with trusted timestamp for long-term validation. */ readonly b_t: "b-t"; /** PAdES B-LT (Long Term) - Baseline signature with revocation information and timestamp for archival purposes. */ readonly b_lt: "b-lt"; }; /** @inline */ declare type PAdESLevelType = ValueOf; /** * Configuration for cursor behavior keyed by input modality. * * ## Terminology * * - **Modality**: How the user interacts (keyboard vs pointer) * - **InteractionMode**: SDK enum for annotation tools (NOTE, TEXT, INK, etc.) * * The `keyboard` function is called with the current InteractionMode to get settings. * * @inline */ declare type PageCursorConfiguration = { /** * Function that returns keyboard modality configuration for the given InteractionMode. * * This allows per-mode configuration (e.g., disable keyboard for some modes). */ keyboard?: PageCursorKeyboardFn; }; /** * Function type for keyboard modality configuration. * Receives the current InteractionMode and returns settings for that mode. * * @param mode - The current InteractionMode (NOTE, TEXT, SHAPE_*, etc.) or null * @returns Configuration object with `enabled` property * * @example * // Enable keyboard for all modes (default) * keyboard: () => ({ enabled: true }) * * @example * // Disable keyboard for INK mode only * keyboard: (mode) => ({ * enabled: mode !== InteractionMode.INK * }) * * @inline */ declare type PageCursorKeyboardFn = (mode: IInteractionMode | null) => PageCursorKeyboardResult; /** * Return type of the keyboard configuration function. * * @inline */ declare type PageCursorKeyboardResult = { /** * When `true`, enables keyboard-specific features for annotation creation. * * ## What this controls * * When enabled and the user is in keyboard modality: * - PointPicker UI appears for selecting annotation placement coordinates * - Arrow keys navigate the cursor position on the page * - Enter key confirms point selection * - Shift+Enter completes multi-point shapes (polygon, polyline) * * ## Supported InteractionModes * * The following InteractionModes support keyboard creation when enabled: * - `NOTE` - Note annotations (single point) * - `TEXT` - Text annotations (single point) * - `CALLOUT` - Callout annotations (single point) * - `SHAPE_LINE` - Line annotations (2 points) * - `SHAPE_RECTANGLE` - Rectangle annotations (2 points) * - `SHAPE_ELLIPSE` - Ellipse annotations (2 points) * - `SHAPE_POLYGON` - Polygon annotations (multiple points) * - `SHAPE_POLYLINE` - Polyline annotations (multiple points) * - `MULTI_ANNOTATIONS_SELECTION` - Rectangular area selection (2 points) * - `TEXT_WIDGET` - Text field widgets (single point) * - `CHECKBOX_WIDGET` - Checkbox widgets (single point) * - `RADIO_BUTTON_WIDGET` - Radio button widgets (single point) * - `COMBO_BOX_WIDGET` - Combo box widgets (single point) * - `LIST_BOX_WIDGET` - List box widgets (single point) * - `BUTTON_WIDGET` - Button widgets (single point) * - `SIGNATURE_WIDGET` - Signature widgets (single point) * - `DATE_WIDGET` - Date field widgets (single point) * * @default true */ enabled?: boolean; }; /** * @class * Holds information about a specific page inside the document. * * You can receive the page information by using {@link Instance#pageInfoForIndex}. * @hideconstructor * @public * @summary Information about a specific page. */ export declare class PageInfo { /** * The page index of the current page. It is zero-based and has a maximum value of * `totalPageCount - 1`. */ readonly index: number; /** * The label of the current page. Must not be a number and will always be coerced into a string. */ readonly label: string; /** * The default width (at a 100% zoom level) for the current page in pixels. */ readonly height: number; /** * The default width (at a 100% zoom level) for the current page in pixels. */ width: number; /** * The rotation angle of the current page. The value is in degrees and describes a clockwise rotation. The possible values are 0, 90, 180 and 270. */ readonly rotation: number; /** * The raw PDF boxes for current PageInfo. */ rawPdfBoxes: RawPdfBoxes; } declare type PDFAFlags = { conformance?: IConformance; /** * @server */ vectorization?: boolean; /** * @server */ rasterization?: boolean; }; /** * @class * A point describes a 2D vector in space consisting of an `x` and `y` coordinate. * Provided values are defined in same units used by the page, point units. Point units are only * equal to pixels when zoom value is `1`. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `point.set("x", 20)`. * @example * Create and update a point. * ```ts * const point = new NutrientViewer.Geometry.Point({ x: 20, y: 30 }); * point = point.set("y", 20); * point.y; // => 20 * ``` * * @public * @summary A 2D vector that describes a point in space. * @param {object} args - An object used to initialize the Point. If `x` or `y` is omitted, `0` will * be used instead. * @default { x: 0, y: 0 } */ export declare class Point extends Point_base { /** * The `x` coordinate of the point. * * @default 0 */ x: number; /** * The `y` coordinate of the point. * * @default 0 */ y: number; static defaultValues: IObject; constructor(options?: PointCtorProps); /** * Scales `x` and `y` by the given `sx` and `sy` factor. If only `sx` is set and `sy` not defined, * it will scale `x` and `y` by `sx`. * * @example * const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 }); * point.scale(2); // => Point {x: 20, y: 20} * * @param sx - Scale value for the `x` coordinate. If `sy` is not set, this scale will also * be applied to `y`. * @param sy - If empty, it will scale `y` with `sx` as well. * @returns A new `Point`. */ scale(sx: number, sy?: number): this; /** * Translate all values of the point by a given `Point`. * * @example * const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 }); * point.translate(new NutrientViewer.Geometry.Point({ x: 5, y: -5 })); // => Point {x: 15, y: 5} * * @param point - A point that describes the translation distance. * @returns A new `Point`. */ translate({ x: tx, y: ty }: {x: number;y: number;}): this; /** * Translate the `x` value by a given number. * * @example * const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 }); * point.translateX(5); // => Point {x: 15, y: 10} * * @param tx - A number to translate the `x` value. * @returns A new `Point`. */ translateX(tx: number): this; /** * Translate the `y` value by a given number. * * @example * const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 }); * point.translateY(5); // => Point {x: 10, y: 15} * * @param ty - A number to translate the `y` value. * @returns A new `Point`. */ translateY(ty: number): this; /** * Calculates the euclidean distance to another point. * * @example * var point1 = new NutrientViewer.Geometry.Point({ x: 10, y: 10 }); * var point2 = new NutrientViewer.Geometry.Point({ x: 20, y: 10 }); * point1.distance(point2); // => 10 * * @param other - The other point to calculate the distance with. * @returns The distance between the two points. */ distance(other: this): number; /** * Rotates the point at the origin [0, 0]. */ rotate(deg: number): this; /** * Applies a transformation to the point by multiplying the point like * a 2D vector to the matrix. */ apply(matrix: TransformationMatrix): this; } declare const Point_base: Record_2.Factory; /** @inline */ declare interface PointCtorProps { x?: number; y?: number; [k: string]: unknown; } /** * @class * Polygon annotations are used to hand draw polygons on a page. They can contain any number of sides * defined by the polygon vertices. * * Polygon annotations with transparent fill color are only selectable around their visible lines. * This means that you can create a page full of polygon annotations while annotations * behind the polygon annotation are still selectable. * * Right now, polygon annotations are implemented using SVG images. This behavior is subject to change. * *
* *
* @example * Create a polygon annotation that displays a triangle * ```ts * const annotation = new NutrientViewer.Annotations.PolygonAnnotation({ * pageIndex: 0, * points: NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.Point({ x: 25, y: 25 }), * new NutrientViewer.Geometry.Point({ x: 35, y: 30 }), * new NutrientViewer.Geometry.Point({ x: 30, y: 55 }), * ]), * strokeWidth: 10, * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 20, * top: 20, * width: 20, * height: 40, * }), * cloudyBorderIntensity: 2 * }); * ``` * * @summary Display a polygon on a page. */ export declare class PolygonAnnotation extends ShapeAnnotation { /** * A list of points. * * If no points are present, the annotation will not be visible. * * @default NutrientViewer.Immutable.List() Empty list */ points: List; /** * Intensity of the cloudy border. * * If not present or 0, the annotation will use a normal border. * * @default null Normal border. */ cloudyBorderIntensity: null | number; static defaultValues: IObject; static readableName: string; } /** * @deprecated Use {@link Serializers.PolygonAnnotationJSON} instead. * @hidden */ export declare type PolygonAnnotationJSON = Serializers.PolygonAnnotationJSON; declare class PolygonAnnotationSerializer extends ShapeAnnotationSerializer { annotation: PolygonAnnotation; toJSON(): Serializers.PolygonAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: IObject): PolygonAnnotation; } /** * @class * Polyline annotations are used to hand draw polylines on a page. They can contain any number of sides * defined by the polyline vertices. * * Polyline annotations with transparent fill color are only selectable around their visible lines. * This means that you can create a page full of polyline annotations while annotations * behind the polyline annotation are still selectable. * * Right now, polyline annotations are implemented using SVG images. This behavior is subject to change. * *
* *
* @example * Create a polyline annotation that displays a triangle * ```ts * var annotation = new NutrientViewer.Annotations.PolylineAnnotation({ * pageIndex: 0, * points: NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.Point({ x: 25, y: 25 }), * new NutrientViewer.Geometry.Point({ x: 35, y: 30 }), * new NutrientViewer.Geometry.Point({ x: 30, y: 55 }), * ]), * strokeWidth: 10, * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 20, * top: 20, * width: 20, * height: 40, * }), * }); * ``` * * @summary Display a polyline on a page. */ export declare class PolylineAnnotation extends ShapeAnnotation { /** * A list of points. * * If no points are present, the annotation will not be visible. * * @default NutrientViewer.Immutable.List() Empty list */ points: List; /** * An object with start and / or end entries for line caps. * * Line caps can have one of these values: "square", "circle", "diamond", "openArrow", "closedArrow", * "butt", "reverseOpenArrow", "reverseClosedArrow" or "slash". * * If the fillColor field is provided, its value is used as fill color for the line cap interior. */ lineCaps: null | LineCapsType; static defaultValues: IObject; static readableName: string; } /** * @deprecated Use {@link Serializers.PolylineAnnotationJSON} instead. * @hidden */ export declare type PolylineAnnotationJSON = Serializers.PolylineAnnotationJSON; declare class PolylineAnnotationSerializer extends ShapeAnnotationSerializer { annotation: PolylineAnnotation; toJSON(): Serializers.PolylineAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): PolylineAnnotation; } /** * This is used to Populate the document template (Docx format) with corresponding data. * * Returns a {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise} * resolving to an `ArrayBuffer` of a Docx, or rejecting with a {@link NutrientViewer.Error}. * * The resulting `ArrayBuffer` can be converted to PDF with {@link NutrientViewer.convertToPDF | NutrientViewer.convertToPDF()}. * and finally loaded with {@link NutrientViewer.load | NutrientViewer.load()}. * * It requires a {@link Configuration | configuration object} and config object with * data {@link TemplateDataToPopulateDocument} which contains the data to be populated in document * and delimiter marker to know placeholder of the data. If the configuration is * invalid, the promise will be rejected with a {@link NutrientViewer.Error}. * * @example * NutrientViewer.populateDocumentTemplate( * { * document: '/sales-report.docx', * licenseKey: 'YOUR_LICENSE_KEY', * }, * { * config: { * delimiter: { * start: '{{', * end: '}}', * }, * }, * model: { * products: [ * { * title: 'Duk', * name: 'DukSoftware', * reference: 'DS0', * }, * { * title: 'Tingerloo', * name: 'Tingerlee', * reference: 'T00', * }, * ], * }, * }, * ) * .then(arrayBuffer => { * console.log('Successfully populated the template Document with data', arrayBuffer) * }) * .catch(error => { * console.error(error.message) * }) * The `delimiter` object sets the pair of delimiters that encloses a template marker * i.e. placeholder marker that need to be substituted with the data. * * The `model` object associates a template marker with the corresponding substitution in the final, produced document. * * === Supported Template Features === * Placeholders let users substitute a marker with some text, loops generate repetitions * of a given pattern, and image markers insert images into the output DOCX. * * The syntax for loops is `#` for the opening tag, and `/` for the closing one in the docs. * * For instance if the document contains: * * ``` * {#ITEMS} {name} {price} {/ITEMS} * ``` * * Here, `ITEMS` is the name of the loop template marker, and `name` and `price` are regular placeholder * template markers over which the SDK iterates replacing the `name` placeholder with corresponding `name` value * in `model`, and similarly the `price` placeholder is replaced by the corresponding `price` value in `model`. * * ``` * { * model: { * items: [ * { * name: "A", * price: 10 * }, * { * name: "B", * price: 15 * } * ] * } * } * ``` * * === Image markers === * * You can author image markers in DOCX templates using: * * - `{{%name}}` for inline image placement * - `{{%%name}}` for centered image placement * * Supported sources in standalone mode: * * - `source: "base64"` with raw base64 payload (`data`) or data URL payload * - `source: "dataUrl"` as an alias for `base64` (normalized at runtime) * - `source: "url"` for HTTP(S) URLs (fetched and normalized to base64 at runtime) * * Unsupported in public APIs: * * - `source: "file"` (there is no filesystem semantic for public standalone usage) * - `format: "svg"` / `image/svg+xml` payloads * * For `source: "url"`, cross-origin requests require proper CORS headers from the image host. * If CORS is not configured, pass base64/data URL payloads instead. * * Sizing validation rules: * * - `sizing: "original"` requires no dimensions. * - `sizing: "fixed"` and `sizing: "fit-max"` require `width` and `height` (> 0). * - `sizing: "fit-width"` requires `width` (> 0). * - `sizing: "fit-height"` requires `height` (> 0). * * Example image model value: * * ``` * { * _type: "image", * source: "base64", * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP8z8DwHwAF+wJ/lxS6RQAAAABJRU5ErkJggg==", * format: "png", * sizing: "fit-width", * width: 96, * caption: "Company logo", * altText: "Logo" * } * ``` * * Multipage image payloads can use `pageNumber` (1-based index). * * The API rejects the whole request when any image payload fails validation or URL resolution. * * @public * @param configuration - A configuration Object * @param templateData - A template data object * @returns Promise that resolves to an ArrayBuffer of a file converted to PDF */ declare function populateDocumentTemplate(configuration: StandaloneConfiguration, templateData: TemplateDataToPopulateDocument): Promise; /** * Preloads the standalone WASM worker. * * In cases where you don't want to load a PDF right away, the first invocation * of {@link NutrientViewer.load} after allowing this function to resolve will be * significantly faster. * * If {@link NutrientViewer.load} is called while this function has not yet resolved, * then {@link NutrientViewer.load} will simply reuse the request from this function * without adding any overhead. * * @example * // Fetches worker asynchronously * NutrientViewer.preloadWorker(configuration); * document.querySelector("#open-pdf-button").addEventListener(async () => { * await NutrientViewer.load({ ...configuration, document: "my-doc.pdf" }); * }); * * @standalone * @param configuration - A configuration Object * @returns Promise that resolves when preloading is complete */ declare function preloadWorker(configuration: StandaloneConfiguration): Promise; /** * Describes mode used to print a PDF document. * * @enum */ declare const PrintMode: { /** * This method will render all pages of the PDF document in advance before it sends the results to * the printer. This works in all major browsers and will not give your users access to the source * PDF file. However, this method is CPU-bound and memory usage scales with PDF size. * * Because of its reliability and cross browsers support this method is the default. * * Some caveats when using this method: * * - To achieve cross-browser support, we render the resulting images into the main window. We * try to hide already existing HTML by applying `display: none !important`. If the printed * page still contains other HTML elements, make sure to apply an appropriate print stylesheet * to your web app. * - This method will produce incorrect results, when pages of the document have different sizes. * Unfortunately, there's no way to work around this issue since it's a CSS limitation. */ readonly DOM: "DOM"; /** * This method is built to be resource efficient and to avoid having to render all pages in * advance, which might balloon memory usage to multi-GB on PDFs with 100+ pages. * * It supports all common browsers, however some fall back to opening the PDF file in a new tab, * which might give your users unwanted access to the source files. * * Google Chrome and Microsoft Internet Explorer provide the APIs required to use the native * renderer, as a fallback on other browser we generate and open a PDF in a new tab. This allows * users to print the PDF in a native PDF reader which can, as opposed to browser-built * implementations, talk directly to the connected printer. * * When using this print mode, we can not call the {@link RenderPageCallback} when * printing pages. * * Note: If the PDF is password-protected, we always fall back to opening the PDF in a new tab. */ readonly EXPORT_PDF: "EXPORT_PDF"; }; /** * Describes Quality used to print a PDF document. * * Note: With increase in the PDF print Quality speed of printing will decrease. * * @enum */ declare const PrintQuality: { /** Low will print the PDF in original quality. */ readonly LOW: "LOW"; /** Medium quality printing (150 dpi). */ readonly MEDIUM: "MEDIUM"; /** High quality printing (300 dpi). */ readonly HIGH: "HIGH"; }; declare function PrivateAPIMixin>(Base: T): { new (...args: any[]): { }; } & T; /** * Contains information needed to authenticate processing request with Nutrient backend (Document Engine or DWS API). * * **DWS API** * * JSON Web Token (JWT) are used to authorize with the DWS API. See DWS's * {@link https://www.nutrient.io/api/documentation/developer-guides/authentication/|guides} * for more details about the JWT authorization. * * Auth token can be generated via DWS API. For example, you can generate a token that can only access * the `document_Editor_api` operation from the `example.com` origin and expires in 1 hour, without having access to other * operations or origins: * * ```sh * curl -X POST https://api.nutrient.io/tokens \ * -H 'Authorization: Bearer pdf_live_' \ * -H "Content-Type: application/json" \ * -d '{ * "allowedOperations": [ * "document_editor_api", * ], * "allowedOrigins": [ * "example.com" * ], * "expirationTime": 3600 * }' * ``` * * **Document Engine** * * JSON Web Token (JWT) are used to authorize with the Document Engine. See Document Engine's * {@link https://www.nutrient.io/api/reference/document-engine/upstream/#tag/JWT-authorization|API Reference} * for more details about the JWT authorization. * * @property jwt - Authorization token needed to authorize the processing request with the backend. * @property serverUrl - Base server URL to use as the Build API endpoint (`/api/build`). * Optional, since it's possible to encode it in the auth token, DWS API does that by default. */ export declare type ProcessingAuthPayload = { jwt: string; serverUrl?: string; }; /** * ***optional, Standalone only*** * * Document processing can be a time-consuming task, especially when working with large documents. In order to improve the user experience * it is possible to choose between two different processor engines with different optimizations applied: either one with a * smaller bundle size, but slower overall performance, or one with a larger bundle size, but faster processing time (the default). * * Either case it's recommended to enable asset compression on your Server to improve loading time. * * Processor Engine Comparison: * * | Preference | Bundle Size | Document Processing | Recommended Use | * |-----------------------------|-------------|---------------------|-------------------------------| * | smallerSize | Smaller | Slower | Prioritize compact app size | * | fasterProcessing (default) | Larger | Faster | Quick document processing | * * @standalone * @enum */ declare const ProcessorEngine: { /** A smaller processor engine will be used for processing. */ smallerSize: string; /** A faster processor engine will be used for processing (default). */ fasterProcessing: string; }; /** * Defines the product IDs for the different environments the SDK can be used in. * * @example * ```ts * const productId = NutrientViewer.ProductId.SharePoint; * ``` * * @enum * */ declare const ProductId: { /** Enables using the SDK in a SharePoint environment. When used, the document should be loaded from a SharePoint site. */ SharePoint: string; /** Enables using the SDK in a Salesforce environment. When used, the SDK should be loaded from a Salesforce site. */ Salesforce: string; Maui_Android: string; Maui_iOS: string; Maui_MacCatalyst: string; Maui_Windows: string; FlutterForWeb: string; Electron: string; }; /** * @class * A NutrientViewer.Error indicates a problem with NutrientViewer. It is a subclass of and behaves like a * regular JavaScript error. * * @example * try { * NutrientViewer.someFunctionThatFails() * } catch (error) { * error instanceof NutrientViewer.Error // => true * error.message // Useful error message * } * * @summary NutrientViewer related error. */ declare const PSPDFKitError: any; /** * A save error indicates a problem with saving. It is a subclass of {@link NutrientViewer.Error} * that behaves like a regular JavaScript error. * * @example * try { * await instance.save(); * } catch (error) { * (error instanceof NutrientViewer.SaveError); // => true * error.message; // Useful error message * error.reason; // Array of errors for changes that could not be saved. * } * * @class * @summary NutrientViewer related error related to saving. * * @param messageOrError */ declare function PSPDFKitSaveError(messageOrError: string | Error, reason: Array>): Error; declare namespace PSPDFKitSaveError { var prototype: any; } declare const PublicTextSelection_base: Record_2.Factory; /** * @class * * A group of radio buttons. Similar to {@link NutrientViewer.FormFields.CheckBoxFormField}, but there can * only be one value set at the same time. * * To retrieve a list of all form fields, use {@link NutrientViewer.Instance#getFormFields}. * @public * @summary A group of radio buttons. * @hideconstructor */ export declare class RadioButtonFormField extends FormField { /** * If true, exactly one radio button must be selected at all times. Clicking the currently selected * button has no effect. Otherwise, clicking the selected button deselects it, leaving no button * selected. * * @default false */ noToggleToOff: boolean; /** * If true, a group of radio buttons within a radio button field that use the same value for the on * state will turn on and off in unions: If one is checked, they are all checked (the same behavior * as HTML radio buttons). Otherwise, only the checked radio button will be marked checked. * * @default true */ radiosInUnison: boolean; /** * The selected form option value. In order to modify it, {@link NutrientViewer.Instance.setFormFieldValues | instance.setFormFieldValues()} should be used. */ readonly value: string; /** * Similar to the `value` property. The default values are only used when a form needs to be reset. */ readonly defaultValue: string; /** * A list of {@link NutrientViewer.FormOption}s. This is necessary to map the multiple radio button * options to their values. * * See {@link NutrientViewer.FormOption} for more information. */ readonly options: List; /** * Radio buttons and checkboxes can have multiple widgets with the same form value associated, but can be * selected independently. `optionIndexes` contains the value indexes that should be actually set. * * If set, the `value` field doesn't get used, and the widget found at the corresponding indexes in the form field's * `annotationIds` property are checked. * * If set on fields other than radio buttons or checkboxes, setting the form value will fail. */ readonly optionIndexes?: List; static defaultValues: IObject; } /** * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end` * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to * infinity. When `start` is equal to `end`, returns empty range. * * Note: `Range` is a factory function and not a class, and does not use the * `new` keyword during construction. * * ```js * const { Range } = require('immutable') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] * Range(10, 30, 5) // [ 10, 15, 20, 25 ] * Range(30, 10, 5) // [ 30, 25, 20, 15 ] * Range(30, 30, 5) // [] * ``` */ declare function Range_2(start?: number, end?: number, step?: number): Seq.Indexed; /** @inline */ declare type Range_3 = [min: number, max: number]; declare type RawPdfBoxes = { bleedBox: null | IRectJSON; cropBox: null | IRectJSON; mediaBox: null | IRectJSON; trimBox: null | IRectJSON; }; /** * Unlike other types in Immutable.js, the `Record()` function creates a new * Record Factory, which is a function that creates Record instances. * * See above for examples of using `Record()`. * * Note: `Record` is a factory function and not a class, and does not use the * `new` keyword during construction. */ declare function Record_2(defaultValues: TProps, name?: string): Record_2.Factory; /** * A record is similar to a JS object, but enforces a specific set of allowed * string keys, and has default values. * * The `Record()` function produces new Record Factories, which when called * create Record instances. * * ```js * const { Record } = require('immutable') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = ABRecord({ b: 3 }) * ``` * * Records always have a value for the keys they define. `remove`ing a key * from a record simply resets it to the default value for that key. * * ```js * myRecord.size // 2 * myRecord.get('a') // 1 * myRecord.get('b') // 3 * const myRecordWithoutB = myRecord.remove('b') * myRecordWithoutB.get('b') // 2 * myRecordWithoutB.size // 2 * ``` * * Values provided to the constructor not found in the Record type will * be ignored. For example, in this case, ABRecord is provided a key "x" even * though only "a" and "b" have been defined. The value for "x" will be * ignored for this record. * * ```js * const myRecord = ABRecord({ b: 3, x: 10 }) * myRecord.get('x') // undefined * ``` * * Because Records have a known set of string keys, property get access works * as expected, however property sets will throw an Error. * * Note: IE8 does not support property access. Only use `get()` when * supporting IE8. * * ```js * myRecord.b // 3 * myRecord.b = 5 // throws Error * ``` * * Record Types can be extended as well, allowing for custom methods on your * Record. This is not a common pattern in functional environments, but is in * many JS programs. * * However Record Types are more restricted than typical JavaScript classes. * They do not use a class constructor, which also means they cannot use * class properties (since those are technically part of a constructor). * * While Record Types can be syntactically created with the JavaScript `class` * form, the resulting Record function is actually a factory function, not a * class constructor. Even though Record Types are not classes, JavaScript * currently requires the use of `new` when creating new Record instances if * they are defined as a `class`. * * ``` * class ABRecord extends Record({ a: 1, b: 2 }) { * getAB() { * return this.a + this.b; * } * } * * var myRecord = new ABRecord({b: 3}) * myRecord.getAB() // 4 * ``` * * * **Flow Typing Records:** * * Immutable.js exports two Flow types designed to make it easier to use * Records with flow typed code, `RecordOf` and `RecordFactory`. * * When defining a new kind of Record factory function, use a flow type that * describes the values the record contains along with `RecordFactory`. * To type instances of the Record (which the factory function returns), * use `RecordOf`. * * Typically, new Record definitions will export both the Record factory * function as well as the Record instance type for use in other code. * * ```js * import type { RecordFactory, RecordOf } from 'immutable'; * * // Use RecordFactory for defining new Record factory functions. * type Point3DProps = { x: number, y: number, z: number }; * const defaultValues: Point3DProps = { x: 0, y: 0, z: 0 }; * const makePoint3D: RecordFactory = Record(defaultValues); * export makePoint3D; * * // Use RecordOf for defining new instances of that Record. * export type Point3D = RecordOf; * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); * ``` * * **Flow Typing Record Subclasses:** * * Records can be subclassed as a means to add additional methods to Record * instances. This is generally discouraged in favor of a more functional API, * since Subclasses have some minor overhead. However the ability to create * a rich API on Record types can be quite valuable. * * When using Flow to type Subclasses, do not use `RecordFactory`, * instead apply the props type when subclassing: * * ```js * type PersonProps = {name: string, age: number}; * const defaultValues: PersonProps = {name: 'Aristotle', age: 2400}; * const PersonRecord = Record(defaultValues); * class Person extends PersonRecord { * getName(): string { * return this.get('name') * } * * setName(name: string): this { * return this.set('name', name); * } * } * ``` * * **Choosing Records vs plain JavaScript objects** * * Records offer a persistently immutable alternative to plain JavaScript * objects, however they're not required to be used within Immutable.js * collections. In fact, the deep-access and deep-updating functions * like `getIn()` and `setIn()` work with plain JavaScript Objects as well. * * Deciding to use Records or Objects in your application should be informed * by the tradeoffs and relative benefits of each: * * - *Runtime immutability*: plain JS objects may be carefully treated as * immutable, however Record instances will *throw* if attempted to be * mutated directly. Records provide this additional guarantee, however at * some marginal runtime cost. While JS objects are mutable by nature, the * use of type-checking tools like [Flow](https://medium.com/@gcanti/immutability-with-flow-faa050a1aef4) * can help gain confidence in code written to favor immutability. * * - *Value equality*: Records use value equality when compared with `is()` * or `record.equals()`. That is, two Records with the same keys and values * are equal. Plain objects use *reference equality*. Two objects with the * same keys and values are not equal since they are different objects. * This is important to consider when using objects as keys in a `Map` or * values in a `Set`, which use equality when retrieving values. * * - *API methods*: Records have a full featured API, with methods like * `.getIn()`, and `.equals()`. These can make working with these values * easier, but comes at the cost of not allowing keys with those names. * * - *Default values*: Records provide default values for every key, which * can be useful when constructing Records with often unchanging values. * However default values can make using Flow and TypeScript more laborious. * * - *Serialization*: Records use a custom internal representation to * efficiently store and update their values. Converting to and from this * form isn't free. If converting Records to plain objects is common, * consider sticking with plain objects to begin with. */ declare module Record_2 { /** * True if `maybeRecord` is an instance of a Record. */ function isRecord(maybeRecord: any): maybeRecord is Record_2; /** * Records allow passing a second parameter to supply a descriptive name * that appears when converting a Record to a string or in any error * messages. A descriptive name for any record can be accessed by using this * method. If one was not provided, the string "Record" is returned. * * ```js * const { Record } = require('immutable') * const Person = Record({ * name: null * }, 'Person') * * var me = Person({ name: 'My Name' }) * me.toString() // "Person { "name": "My Name" }" * Record.getDescriptiveName(me) // "Person" * ``` */ function getDescriptiveName(record: Record_2): string; /** * A Record.Factory is created by the `Record()` function. Record instances * are created by passing it some of the accepted values for that Record * type: * * * ```js * // makePerson is a Record Factory function * const makePerson = Record({ name: null, favoriteColor: 'unknown' }); * * // alan is a Record instance * const alan = makePerson({ name: 'Alan' }); * ``` * * Note that Record Factories return `Record & Readonly`, * this allows use of both the Record instance API, and direct property * access on the resulting instances: * * * ```js * // Use the Record API * console.log('Record API: ' + alan.get('name')) * * // Or direct property access (Readonly) * console.log('property access: ' + alan.name) * ``` * * **Flow Typing Records:** * * Use the `RecordFactory` Flow type to get high quality type checking of * Records: * * ```js * import type { RecordFactory, RecordOf } from 'immutable'; * * // Use RecordFactory for defining new Record factory functions. * type PersonProps = { name: ?string, favoriteColor: string }; * const makePerson: RecordFactory = Record({ name: null, favoriteColor: 'unknown' }); * * // Use RecordOf for defining new instances of that Record. * type Person = RecordOf; * const alan: Person = makePerson({ name: 'Alan' }); * ``` */ module Factory {} interface Factory { (values?: Partial | Iterable<[string, any]>): Record_2 & Readonly; new (values?: Partial | Iterable<[string, any]>): Record_2 & Readonly; } function Factory(values?: Partial | Iterable<[string, any]>): Record_2 & Readonly; } declare interface Record_2 { // Reading values has(key: string): key is keyof TProps & string; /** * Returns the value associated with the provided key, which may be the * default value defined when creating the Record factory function. * * If the requested key is not defined by this Record type, then * notSetValue will be returned if provided. Note that this scenario would * produce an error when using Flow or TypeScript. */ get(key: K, notSetValue?: any): TProps[K]; get(key: string, notSetValue: T): T; // Reading deep values hasIn(keyPath: Iterable): boolean; getIn(keyPath: Iterable): any; // Value equality equals(other: any): boolean; hashCode(): number; // Persistent changes set(key: K, value: TProps[K]): this; update(key: K, updater: (value: TProps[K]) => TProps[K]): this; merge(...collections: Array | Iterable<[string, any]>>): this; mergeDeep(...collections: Array | Iterable<[string, any]>>): this; mergeWith( merger: (oldVal: any, newVal: any, key: keyof TProps) => any, ...collections: Array | Iterable<[string, any]>>) : this; mergeDeepWith( merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | Iterable<[string, any]>>) : this; /** * Returns a new instance of this Record type with the value for the * specific key set to its default value. * * @alias remove */ delete(key: K): this; remove(key: K): this; /** * Returns a new instance of this Record type with all values set * to their default values. */ clear(): this; // Deep persistent changes setIn(keyPath: Iterable, value: any): this; updateIn(keyPath: Iterable, updater: (value: any) => any): this; mergeIn(keyPath: Iterable, ...collections: Array): this; mergeDeepIn(keyPath: Iterable, ...collections: Array): this; /** * @alias removeIn */ deleteIn(keyPath: Iterable): this; removeIn(keyPath: Iterable): this; // Conversion to JavaScript types /** * Deeply converts this Record to equivalent native JavaScript Object. * * Note: This method may not be overridden. Objects with custom * serialization to plain JS may override toJSON() instead. */ toJS(): { [K in keyof TProps]: any }; /** * Shallowly converts this Record to equivalent native JavaScript Object. */ toJSON(): TProps; /** * Shallowly converts this Record to equivalent JavaScript Object. */ toObject(): TProps; // Transient changes /** * Note: Not all methods can be used on a mutable collection or within * `withMutations`! Only `set` may be used mutatively. * * @see `Map#withMutations` */ withMutations(mutator: (mutable: this) => any): this; /** * @see `Map#asMutable` */ asMutable(): this; /** * @see `Map#wasAltered` */ wasAltered(): boolean; /** * @see `Map#asImmutable` */ asImmutable(): this; // Sequence algorithms toSeq(): Seq.Keyed; [Symbol.iterator](): IterableIterator<[keyof TProps, TProps[keyof TProps]]>; } /** * RecordOf is used in TypeScript to define interfaces expecting an * instance of record with type T. * * This is equivalent to an instance of a record created by a Record Factory. */ declare type RecordOf = Record_2 & Readonly; /** * @class * A rect describes a rectangle in 2D space. It consists of a location (`left` and `top`) and * dimensions (`width` and `height`). Provided values are defined in same units used by the page, * point units. Point units are only equal to pixels when zoom value is `1`. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `rect.set("left", 20)`. * @example * Create and update a rect. * ```ts * const rect = new NutrientViewer.Geometry.Rect({ * left: 10, * top: 20, * width: 30, * height: 40 * }); * rect = rect.set("left", 20); * rect.left; // => 20 * ``` * * @public * @summary A rectangle in 2D space. * @param args - An object used to initialize the Point. If `left`, `top`, `width` or `height` * is omitted, `0` will be used instead. * @default { left: 0, top: 0, width: 0, height: 0 } */ export declare class Rect extends Rect_base { /** * The `left` distance of the rect. This is equivalent to `x` of a * {@link Geometry.Point}. * * @default 0 */ left: number; /** * The `top` distance of the rect. This is equivalent to `y` of a * {@link Geometry.Point}. * * @default 0 */ top: number; /** * The `width` of the rect. This is equivalent to `width` of a {@link Geometry.Size}. * * @default 0 */ width: number; /** * The `height` of the rect. This is equivalent to `height` of a {@link Geometry.Size}. * * @default 0 */ height: number; static defaultValues: IObject; constructor(options?: IRect); /** * Computes the right point in the rect by adding `left` and `width`. */ get right(): number; /** * Computes the bottom point in the rect by adding `top` and `height`. */ get bottom(): number; /** * Creates a new rect from a DOM ClientRect. * * @example * const rect = NutrientViewer.Geometry.Rect.fromClientRect( * element.getBoundingClientRect() * ); * * @param rect - A DOM ClientRect. * @returns A new `Rect`. */ static fromClientRect({ top, left, width, height }: ClientRect): Rect; /** * Creates a new rect from four points. * * @example * const rect = NutrientViewer.Geometry.Rect.fromPoints( * new NutrientViewer.Geometry.Point({ x: 10, y: 10 }), * new NutrientViewer.Geometry.Point({ x: 20, y: 10 }), * new NutrientViewer.Geometry.Point({ x: 20, y: 20 }), * new NutrientViewer.Geometry.Point({ x: 10, y: 20 }) * ); * * @public * @param points - An array of four points. * @returns A new `Rect`. */ static fromPoints(...points: Point[]): Rect; /** * Expand the rect to include the list of points. * * @example * const rect = NutrientViewer.Geometry.Rect({ * left: 10, * top: 10, * width: 10, * height: 10 * }) * * const newRect = rect.expandToIncludePoints(new NutrientViewer.Geometry.Point({ x: 30, y: 30 })); * // => Rect {left: 10, top: 10, width: 30, height: 30} * * @returns A new `Rect`. */ expandToIncludePoints(...points: Point[]): Rect; static areRectsCloserThan(a: Rect, b: Rect, distance: number): boolean; static areVerticallyAligned(a: Rect, b: Rect, thresholdDistance: number): boolean; /** * Creates a rect that surrounds all rects in the supplied {@link NutrientViewer.Immutable.List}. * * This can be used to calculate the bounding box of a list of rects. * * @example * const rects = NutrientViewer.Immutable.List([ * new NutrientViewer.Geometry.Rect({ left: 14, top: 50, width: 50, height: 50 }), * new NutrientViewer.Geometry.Rect({ left: 70, top: 20, width: 98, height: 99 }), * new NutrientViewer.Geometry.Rect({ left: 14, top: 13, width: 15, height: 16 }) * ]); * * const unionRect = NutrientViewer.Geometry.Rect.union(rects); // => Rect {left: 14, top: 13, width: 154, height: 106} * * @param rects - An immutable list of rects. * @returns A new `Rect`. */ static union(rects: List): Rect; static getCenteredRect(inner: Size, outer: Size): Rect; static fromInset(inset: Inset): Rect; /** * Translates the location of the rect by a point. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10 }); * rect.translate(new NutrientViewer.Geometry.Point({ x: 5, y: -5})); // => Rect {left: 15, top: 5, width: 0, height: 0} * * @param point - A point that describes the translation distance. * @returns A new `Rect`. */ translate({ x: tx, y: ty }: Point): Rect; /** * Translates the horizontal location of the rect by a number. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10 }); * rect.translateX(5); // => Rect {left: 15, top: 10, width: 0, height: 0} * * @param tx - A number to translate the `left` value. * @returns A new `Rect`. */ translateX(tx: number): Rect; /** * Translates the vertical location of the rect by a number. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10 }); * point.translateY(5); // => Rect {left: 10, top: 15, width: 0, height: 0} * * @param ty - A number to translate the `top` value. * @returns A new `Rect`. */ translateY(ty: number): Rect; /** * Scales all values by the given `sx` and `sy` factor. If only `sx` is set and `sy` not defined, * it will scale the values by `sx`. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * rect.scale(2); // => Rect {left: 20, top: 20, width: 20, height: 20} * * @param sx - Scale value for the `left` and `width` value. If `sy` is not set, this scale * will also be applied to `top` and `height`. * @param sy - Scale value for the `top` an `height` value. * @returns A new `Rect`. */ scale(sx: number, sy?: number): Rect; /** * Grows the rect by `growth` on every side but keeps the center of the Rect at the same position. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * rect.grow(5); // => Rect {left: 5, top: 5, width: 20, height: 20} * * @param growth - The growth factor. It will be applied on every side, so the new `width` * and `height` will increase by two times this factor. * @returns A new `Rect`. */ grow(growth: number): Rect; /** * Returns the {@link NutrientViewer.Geometry.Point} that is the upper-left corner of this rect. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * rect.getLocation(); // => Point {left: 10, top: 10} * * @returns A point that is on the upper-left corner of this rect. */ getLocation(): Point; /** * Returns the {@link NutrientViewer.Geometry.Size} of the rect. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * rect.getSize(); // => Size {width: 10, height: 10} * * @returns The size of the rect. */ getSize(): Size; /** * Returns the {@link NutrientViewer.Geometry.Point} that is the center of this rect. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * rect.getCenter(); // => Point {left: 15, top: 15} * * @returns A point that is on the center of this rect. */ getCenter(): Point; /** * Updates the location of the rect by modifying `left` and `top`. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * var nextLocation = new NutrientViewer.Geometry.Point({ x: 20, y: 30 }); * * rect.setLocation(nextLocation); // => Rect {left: 20, top: 30, width: 10, height: 10} * * @param location - The new location for the rect. * @returns A new `Rect` with `left` and `top` updated. */ setLocation(location: Point): Rect; /** * Rounds all coordinates to whole numbers. The resulting `Rect` will always overlap the source * `Rect`. * * The location (`left` and `top`) will be rounded to a number which is smaller than or equal * to the current value. * * The size (`width` and `height`) will be rounded to a number which is greater than or equal to * the current value. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10.5, top: 15.5, width: 20.5, height: 25.5 }); * rect.roundOverlap(); // => Rect {left: 10, top: 15, width: 21, height: 26} * * @returns A new `rect`. */ roundOverlap(): Rect; /** * Rounds all coordinates to whole numbers. This implementation uses `Math.round` for all * coordinates. The resulting `Rect` might no longer overlap the source `Rect`. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10.5, top: 15.5, width: 20.5, height: 25.5 }); * rect.round(); // => Rect {left: 11, top: 16, width: 21, height: 26} * * @returns A new `rect`. */ round(): Rect; /** * Test if a point is within the rect. This can be used for hit testing. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * rect.isPointInside(new NutrientViewer.Geometry.Point({ x: 15, y: 15 })); // => true * rect.isPointInside(new NutrientViewer.Geometry.Point({ x: 25, y: 25 })); // => false * * @param point - The point that should be tested. * @returns `true` if the point is inside, `false` otherwise. */ isPointInside(point: Point): boolean; /** * Test if a rect is completely inside this rect. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * * const insideRect = new NutrientViewer.Geometry.Rect({ left: 12, top: 12, width: 5, height: 5 }); * const overlappingRect = new NutrientViewer.Geometry.Rect({ left: 5, top: 5, width: 10, height: 10 }); * const outsideRect = new NutrientViewer.Geometry.Rect({ left: 0, top: 0, width: 5, height: 5 }); * * rect.isRectInside(insideRect); // => true * rect.isRectInside(overlappingRect); // => false * rect.isRectInside(outsideRect); // => false * * @param otherRect - The rect that should be tested. * @returns `true` if the rect is inside, `false` otherwise. */ isRectInside(otherRect: Rect): boolean; /** * Test if the union area of two rects is greater than zero. * * @example * const rect = new NutrientViewer.Geometry.Rect({ left: 10, top: 10, width: 10, height: 10 }); * * const insideRect = new NutrientViewer.Geometry.Rect({ left: 12, top: 12, width: 5, height: 5 }); * const overlappingRect = new NutrientViewer.Geometry.Rect({ left: 5, top: 5, width: 10, height: 10 }); * const outsideRect = new NutrientViewer.Geometry.Rect({ left: 0, top: 0, width: 5, height: 5 }); * * rect.isRectOverlapping(insideRect); // => true * rect.isRectOverlapping(overlappingRect); // => true * rect.isRectOverlapping(outsideRect); // => false * * @param other - The rect that should be tested. * @returns `true` if the rect is overlapping, `false` otherwise. */ isRectOverlapping(other: Rect): boolean; /** * Normalizes the Rect. In case of either a negative width or a negative height, the position will * be updated so that the location is again the top, left point of the rectangle. */ normalize(): Rect; /** * Applies a transformation to the rect. We will translate [top, left] like a 2D * vector but only apply the scaling to the dimension [width, height] */ apply(matrix: TransformationMatrix): Rect; } declare const Rect_base: Record_2.Factory; /** * @class * Rectangle annotations are used to draw rectangles on a page. * * Rectangle annotations with transparent fill color are only selectable around their visible lines. * This means that you can create a page full of rectangle annotations while annotations * behind the rectangle annotation are still selectable. * * Right now, rectangle annotations are implemented using SVG images. This behavior is subject to change. * *
* *
* @example * Create a rectangle annotation * ```ts * const annotation = new NutrientViewer.Annotations.RectangleAnnotation({ * pageIndex: 0, * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 10, * top: 10, * width: 100, * height: 100, * }), * cloudyBorderIntensity: 2, * cloudyBorderInset: new NutrientViewer.Geometry.Inset({ * left: 9, * top: 9, * right: 9, * bottom: 9, * }) * }); * ``` * * @summary Display a rectangle on a page. */ export declare class RectangleAnnotation extends ShapeAnnotation { /** * Intensity of the cloudy border. * * If not present or 0, the annotation will use a normal border. * * @default null Normal border. */ cloudyBorderIntensity: null | number; /** * Cloudy border inset. * * For rectangle annotations with a cloudy border, it contains the values for the distances from * the bounding box to bounding box wrapped by the inner, where the content fits. * * Visual representation of the property: * *
* *
*/ cloudyBorderInset: null | Inset; measurementBBox: null | Rect; static readableName: string; constructor(options?: Partial); } /** * @deprecated Use {@link Serializers.RectangleAnnotationJSON} instead. * @hidden */ export declare type RectangleAnnotationJSON = Serializers.RectangleAnnotationJSON; declare class RectangleAnnotationSerializer extends ShapeAnnotationSerializer { annotation: RectangleAnnotation; toJSON(): Serializers.RectangleAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): RectangleAnnotation; } /** * @class * Redaction annotations are used to mark regions of content or text of the * document to eventually redact (i.e. remove the content from the document * in an irreversible way). * * You can customize how a redaction annotation looks in its marked state, * which is when the redaction hasn't been applied yet, and the redacted * state, that is the final appearance that the redacted region will have. * * The `fillColor`, `overlayText`, `color` and `repeatOverlayText` influence * the redacted appearance, while `outlineColor` influences the marked * appearance. * @summary Mark a region for redaction. */ export declare class RedactionAnnotation extends TextMarkupAnnotation { /** * Background color of the redacted area. * * @default NutrientViewer.Color.BLACK */ fillColor: null | Color; /** * Text to be displayed at the specified region * when a redaction has been applied. */ overlayText: null | string; /** * Whether the overlay text should be repeated * to fill the entire redaction area or just * be drawn once. * * It has no effect if there is no overlay text * specified. * * @default false */ repeatOverlayText: null | boolean; /** * Color used for the redaction's border in its * marked state. * * @default NutrientViewer.Color.RED */ outlineColor: null | Color; /** * The font size of the overlay text. If the value is zero or not present, an * appropriate automatic font size will be chosen. */ fontSize: null | number; /** * Color of the overlay text. * * It has no effect if there is no overlay text * specified. * * @default NutrientViewer.Color.RED */ color: Color; static readableName: string; } /** * @deprecated Use {@link Serializers.RedactionAnnotationJSON} instead. * @hidden */ export declare type RedactionAnnotationJSON = Serializers.RedactionAnnotationJSON; /** * *Redaction Annotation presets are sets of property-value pairs for annotations that can be applied as default *annotations settings for Redaction Annotations. When a property of a Redaction Annotation is changed by the user, *the annotation preset of the redaction annotations gets updated. This means that all the Redaction annotations *created after this action will use that preset unless a different preset is specified. * *For properties not included in the annotation preset, the default values of those properties are used. * * @example * Creating an annotation preset and adding it to the available annotation presets * ```ts * const myAnnotationPresets = instance.annotationPresets * myAnnotationPresets['redaction'] = { * color: NutrientViewer.Color.BLACK, * } * instance.setAnnotationPresets(myAnnotationPresets); * ``` * * @public * @summary Annotation Preset for Redaction Annotations */ export declare type RedactionAnnotationPreset = { /** * Background color of the redacted area. * * @default NutrientViewer.Color.BLACK */ fillColor?: Color; /** * Text to be displayed at the specified region * when a redaction has been applied. */ overlayText?: string; /** * Whether the overlay text should be repeated * to fill the entire redaction area or just * be drawn once. * * It has no effect if there is no overlay text * specified. * * @default false */ repeatOverlayText?: boolean; /** * Color of the overlay text. * * It has no effect if there is no overlay text * specified. * * @default NutrientViewer.Color.RED */ color?: Color; /** * Color used for the redaction's border in its * marked state. * * @default NutrientViewer.Color.RED */ outlineColor?: Color; /** * Name of the creator */ creatorName?: string; }; declare class RedactionAnnotationSerializer extends BaseTextMarkupSerializer { annotation: RedactionAnnotation; constructor(annotation: RedactionAnnotation); toJSON(): Serializers.RedactionAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): RedactionAnnotation; } declare function RedactionsMixin>(Base: T): { new (...args: any[]): { /** * Searches in the PDF document and creates a redaction annotation for each search result. You can search for a text, regex or use one of the patterns we provide. See * {@link NutrientViewer.SearchPattern} for the list of all the patterns we support. * * Regex syntax: * - Standalone: JavaScript (see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions}). * - Server: {@link http://userguide.icu-project.org/strings/regexp|ICU regular expression}, a derivative of Perl regular expressions. * * Notice that matches included when using one of the {@link NutrientViewer.SearchPattern} options might overfit the criteria (i.e. include false positive results). This might happen since * we strive for including all positive results and avoid data loss. Make sure to review the matches found. * * Note for multiline regular expressions that document text lines end with CRLF (`\r\n`). * * Regular expressions that follow the JavaScript syntax are matched in a similar way to the `RegExp.prototype.exec()` method (see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec}), but ignoring capturing groups, that is, this function only returns full string matches. * * @example * ```ts * // Search and add redactions * instance.createRedactionsBySearch(NutrientViewer.SearchPattern.CREDIT_CARD_NUMBER, { * searchType: NutrientViewer.SearchType.PRESET, * searchInAnnotations: true, * annotationPreset: { * overlayText: 'Redacted' * } * }).then(function(ids) { * console.log("The following annotations have been added:", ids); * * return instance.applyRedactions(); * }); * * // We can add an "annotations.create" event listener and add custom logic based on the * // information for each of the newly created redaction annotations * * const {RedactionAnnotation} = NutrientViewer.Annotations * instance.addEventListener("annotations.create", annotations => { * const redactions = annotations.filter(annot => annot instanceof RedactionAnnotation) * if (redactions.size > 0) { * console.log("Redactions: ", redactions.toJS()) * } * }); * ``` * * @public * @param term - The text, regex or pattern you want to search for. * @param options - Search options object. * @returns Promise that resolves when the redaction annotations have been created. Returns a list of new Redaction Annotation IDs. */ createRedactionsBySearch(term: string | ISearchPattern, options?: { /** * Redactions Search Type. * * @default NutrientViewer.SearchType.TEXT */ searchType?: ISearchType; /** * Set to `false` if you don't want to search in annotations. * * @default true */ searchInAnnotations?: boolean; /** * Whether the search will be case-sensitive or not. Default is `false` if `searchType` is `NutrientViewer.SearchType.TEXT` and `true` for other types of searches. */ caseSensitive?: boolean; /** * Redaction annotation preset. */ annotationPreset?: RedactionAnnotationPreset; /** * The page number to start the search from. * * @default 0 */ startPageIndex?: number; /** * Starting from the `start` page, the number of pages to search. Default is to the end of the document. */ pageRange?: number; }): Promise>; /** * Applies redactions to the current document. This will overwrite the document, * removing content irreversibly. * * In the process of redacting the content, all the redaction annotations will * be removed. Any annotation that is either partially or completely covered * by a redaction annotation will be deleted. * * @example * ```ts * // Applies redactions * instance.applyRedactions().then(function() { * console.log("The document has been redacted."); * }); * ``` * * @public * @returns Promise that resolves when the redactions has been applied. */ applyRedactions(): Promise; }; } & T; /** * Returns a copy of the collection with the value at key removed. * * A functional alternative to `collection.remove(key)` which will also work * with plain Objects and Arrays as an alternative for * `delete collectionCopy[key]`. * * * ```js * const { remove } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * remove(originalArray, 1) // [ 'dog', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] * const originalObject = { x: 123, y: 456 } * remove(originalObject, 'x') // { y: 456 } * console.log(originalObject) // { x: 123, y: 456 } * ``` */ declare function remove>(collection: C, key: K): C; declare function remove, K extends keyof TProps>(collection: C, key: K): C; declare function remove>(collection: C, key: number): C; declare function remove(collection: C, key: K): C; declare function remove(collection: C, key: K): C; /** * Returns a copy of the collection with the value at the key path removed. * * A functional alternative to `collection.removeIn(keypath)` which will also * work with plain Objects and Arrays. * * * ```js * const { removeIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} * console.log(original) // { x: { y: { z: 123 }}} * ``` */ declare function removeIn(collection: C, keyPath: Iterable): C; declare type Renderer = (rendererProps: RendererProps) => UIRendererConfiguration; /** * This object defines the properties of a custom annotation renderer. * * It's returned from a {@link CustomRenderers.AnnotationCustomRendererCallback} function. * * Note that when `append=false` (which is the default value for the property), the default appearance * of the annotation is not rendered, including the pointer event listeners. * * This means that, if you want you custom content to select the annotation when clicked, * you'll have to add some logic to support it. * * You can add an event listener to your node in your custom renderer code, * and also supply a callback to the `onDisappear` property to remove the listener: * * ```js * NutrientViewer.load({ * customRenderers: { * Annotation: ({ annotation }) => { * function selectAnnotation(event) { * event.stopImmediatePropagation(); * instance.setSelectedAnnotation(annotation.id); * } * const node = document.createElement("div").appendChild(document.createTextNode("Custom rendered!")); * node.addEventListener("pointerdown", selectAnnotation, { * capture: true * }); * return { * node, * append: false, * onDisappear: () => { * node.removeEventListener("pointerdown", selectAnnotation, { * capture: true * }); * } * }; * } * } * }); * ``` * * The `onDisappear` callback function will be run whenever the returned node reference changes, * and when the custom rendered component unmounts (is removed from the DOM). With this in mind, * and in order to save the browser some unnecessary work, you could rewrite the previous example * as follows: * * ```js * let node * NutrientViewer.load({ * customRenderers: { * Annotation: ({ annotation }) => { * function selectAnnotation(event) { * event.stopImmediatePropagation(); * instance.setSelectedAnnotation(annotation.id); * } * if (!node) { * node = document.createElement("div").appendChild(document.createTextNode("Custom rendered!")); * node.addEventListener("pointerdown", selectAnnotation, { * capture: true * }); * } * return { * node, * append: false, * onDisappear: () => { * node.removeEventListener("pointerdown", selectAnnotation, { * capture: true * }); * } * }; * } * } * }); * ``` * * In this example the `onDisappear()` reference changes on every call, but since the `node` reference * doesn't change, `onDisappear()` will only be called when the component unmounts. * * Note that the component does not only unmount when the page it's included is scrolled some pages out, * but also, for example, when the annotation it's associated with is selected in the UI, in which case * the component is unmounted and mounted again. * * @public */ export declare type RendererConfiguration = { /** DOM node to be rendered. */ node: Node; /** * Whether the DOM node should be appended after the annotation, or replace it. * * @default false */ append?: boolean | null; /** * Whether to automatically zoom the DOM node as the current {@link NutrientViewer.ViewState#zoomLevel} changes. * * @default false */ noZoom?: boolean | null; /** Callback to be called whenever the custom DOM node is unmounted. */ onDisappear?: ((arg0: Node | null) => void) | null; }; /** * This object can contain callback functions ("renderers") used to customize the appearance of different built-in UI elements. * * The UI element to which the callback corresponds is determined by its key or keys. For example, a callback function * used to customize the annotations sidebar should be located under `NutrientViewer.Configuration.customUI[NutrientViewer.UIElement.Sidebar][NutrientViewer.SidebarMode.ANNOTATIONS]`. * * Currently only the Sidebar Element can be customized, using the `NutrientViewer.UIElement.Sidebar` key. * * @public * @summary Configuration settings for customized rendering of built-in UI elements. * @example * * //Fully customized sidebar * * NutrientViewer.load({ * customUI: { * [NutrientViewer.UIElement.Sidebar]: { * [NutrientViewer.SidebarMode.CUSTOM]({ containerNode }) { * // React Portals can be used as well. * // Or Vue portals, or any other framework API that allows appending components * // to arbitrary DOM nodes. * // Using vanilla JS, you can just append a node to parentNode. * const div = document.createElement("div"); * div.append("My custom sidebar"); * containerNode.appendChild(div); * * return { * // By returning the same node that was provided, we opt-out of having the node * // appended. If we return a different node, it will be appended to the provided node. * node: containerNode, * }; * } * } * } * }); * * //Partially customized sidebar * * NutrientViewer.load({ * customUI: { * [NutrientViewer.UIElement.Sidebar]: { * [NutrientViewer.SidebarMode.ANNOTATIONS]({ containerNode }) { * containerNode.style.padding = "0.5rem"; * * if (!containerNode.querySelector(".MyCustomSidebarComponentHeader")) { * const header = document.createElement("div"); * header.classList.add("MyCustomSidebarComponentHeader"); * containerNode.prepend(header); * } * * return { * node: containerNode, * onRenderItem({ itemContainerNode, item: annotation }) { * const footerAuthor = itemContainerNode.querySelector(".PSPDFKit-Sidebar-Annotations-Footer span"); * // Change the format of the footer text by prefixing it with "Creator: " and removing the date * footerAuthor.textContent = `Creator: ${annotation.creatorName}`; * * // Add aria label to the annotation icon * const annotationIcon = itemContainerNode.querySelector(".PSPDFKit-Icon"); * annotationIcon.setAttribute("aria-label", `Icon for an annotation created by ${annotation.creatorName}.`); * } * }; * } * } * } * }); * * @see Configuration#customUI Instance#setCustomUIConfiguration */ /** * Sidebar custom UI configuration. * * @public * @instance * @property {?NutrientViewer.CustomUIRendererCallback} ANNOTATIONS - Custom UI renderer callback for the annotations sidebar. * @property {?NutrientViewer.CustomUIRendererCallback} THUMBNAILS - Custom UI renderer callback for the thumbnails sidebar. * @property {?NutrientViewer.CustomUIRendererCallback} BOOKMARKS - Custom UI renderer callback for the bookmarks sidebar. * @property {?NutrientViewer.CustomUIRendererCallback} DOCUMENT_OUTLINE - Custom UI renderer callback for the document outline sidebar. * @property {?NutrientViewer.CustomUIRendererCallback} SIGNATURES - Custom UI renderer callback for the signatures sidebar. * @property {?NutrientViewer.CustomUIRendererCallback} CUSTOM - Custom UI renderer callback for the custom sidebar. */ /** * This user defined function receives the element's container DOM node and the data it renders as argument. It's * called whenever the element is mounted, each time the data is modified, and whenever {@link NutrientViewer.Instance#setCustomUIConfiguration} is called. * * It must return a {@link NutrientViewer.CustomUIRendererConfiguration} object. * * @public * @callback CustomUIRendererCallback@callback CustomUIRendererCallback * @param {object} payload - UI element data * @param {Node} payload.containerNode - Container DOM element. * @param {NutrientViewer.Immutable.List. | null} payload.items - Data rendered by the element. * @returns {NutrientViewer.CustomUIRendererConfiguration} */ /** * This object is returned by customer's {@link NutrientViewer.CustomUIRendererCallback} functions to enhance the default appearance of a UI element. * * Its main, fundamental property is `node`, which is the DOM node that will be appended to the container node. * * Optionally it can contain an `onRenderItem` event handler, which is called for each item in the list. * * @public * @property {Node} node - DOM node to be appended to the container, if different from `containerNode`. * @property {?NutrientViewer.CustomUIItemRendererCallback} onRenderItem - Callback to be called whenever an item is rendered. */ /** * This user defined function receives the item element's container DOM node and the item data it renders as argument. It's called whenever the item element because of the container element updates. * * @public * @callback CustomUIItemRendererCallback@callback CustomUIItemRendererCallback * @param {object} payload - UI element data * @param {Node} payload.itemContainerNode - Container DOM element. * @param {any} payload.item - Item data rendered by the element. */ declare type RendererProps = { containerNode: Node; items?: List | null; }; /** * This callback is called whenever a page is rendered or printed (only for * {@link NutrientViewer.PrintMode}.DOM). You can use it to render watermarks on the page. * * Make sure that the rendering commands are as efficient as possible as they might be invoked * multiple times per page (once per tile). * * For more information, see {@link Configuration#renderPageCallback}. * * @public * @param context - A 2D `` rendering context. * @param pageIndex - The current page index, starting with `0` for the first page. * @param pageSize - The size of the page that you're drawing at. The canvas is already scaled accordingly. * @example * Register a RenderPageCallback handler at configuration time. * ```ts * NutrientViewer.load({ * renderPageCallback: function(ctx, pageIndex, pageSize) { * ctx.beginPath(); * ctx.moveTo(0, 0); * ctx.lineTo(pageSize.width, pageSize.height); * ctx.stroke(); * * ctx.font = "30px Comic Sans MS"; * ctx.fillStyle = "red"; * ctx.textAlign = "center"; * ctx.fillText( * `This is page ${pageIndex + 1}`, * pageSize.width / 2, * pageSize.height / 2 * ); * } * // ... * }); * ``` * */ export declare type RenderPageCallback = (context: CanvasRenderingContext2D, pageIndex: number, pageSize: Size) => unknown; declare function RenderPageMixin>(Base: T): { new (...args: any[]): { /** * Provided a `dimension` and `pageIndex` renders a page of a document and returns the * result as `ArrayBuffer`. This can be used as thumbnail. * * You can specify a width or height (but not both at the same time) as the first `dimension` * argument, each accepts a value in the interval `(0; 5000]`. The other dimension will be * calculated based on the aspect ratio of the document. * * This method can be used to provide thumbnail images for your document list. You can use it * in a `` tag. The following example will load the cover of the loaded document with a * width of `400px`. We set the width of the `` tag to `200px`, so the image will be * sharp on high DPI screens. * * @example * const pageWidth = instance.pageInfoForIndex(0).width; * const pageHeight = instance.pageInfoForIndex(0).height; * * const width = 400; * const height = Math.round(width * pageHeight / pageWidth); * * instance.renderPageAsArrayBuffer({ width }, 0).then(function(buffer) { * const canvas = document.createElement('canvas'); * canvas.width = width; * canvas.height = height; * * canvas.style.transformOrigin = "0 0"; * canvas.style.transform = "scale(0.5)"; * * const imageView = new Uint8Array(buffer); * const ctx = canvas.getContext("2d"); * const imageData = ctx.createImageData(width, height); * imageData.data.set(imageView); * ctx.putImageData(imageData, 0, 0); * * document.body.appendChild(canvas); * }); * * @standalone * @param dimension - The size of the resulting image. Only accepts either `width` or * `height`, but not both. The other dimension will be calculated accordingly. * @param pageIndex - The index of the page you want to have information about. * @returns The raw image as bitmap. */ renderPageAsArrayBuffer(dimension: { /** The width of the resulting image. */ width: number; } | { /** The height of the resulting image. */ height: number; }, pageIndex: number): Promise; /** * Generates a URL to an image for the first page of a document or the page of the * provided `pageIndex`. This can be used as thumbnail. * * You can specify a width or height (but not both at the same time) as the first `dimension` * argument, each accepts a value in the interval `(0; 5000]`. The other dimension will be * calculated based on the aspect ratio of the document. * * This endpoint can be used to provide thumbnail images for your document list. You can use it * as a `src` for an `img` tag. The following example will load the cover of the loaded document with a * width of `400px`. * * The returned URL is a Blob URL. * * In order to prevent memory leaks, it's recommended to revoke the returned object URL once the image * is no longer needed, as in the example. * * @example * let objectURL * instance.renderPageAsImageURL({ width: 400 }, 0).then(function(src) { * const image = document.createElement('img'); * image.src = src; * objectURL = src; * document.body.appendChild(image); * }); * // Once the image is no longer needed, we revoke the URL so that the associated * // Blob is released. * function callWhenTheImageIsNoLongerNeeded() { * // Is it an object URL? * if (objectURL.split("://")[0] === "blob") { * URL.revokeObjectURL(objectURL); * } * } * * @param dimension - The size of the resulting image. Only accepts either `width` or * `height`, but not both. The other dimension will be calculated accordingly. * @param pageIndex - The index of the page you want to have information about. * @returns The image url. */ renderPageAsImageURL(dimension: { /** The width of the resulting image. */ width: number; } | { /** The height of the resulting image. */ height: number; }, pageIndex: number): Promise; }; } & T; /** * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is * not defined, returns an infinite `Seq` of `value`. * * Note: `Repeat` is a factory function and not a class, and does not use the * `new` keyword during construction. * * ```js * const { Repeat } = require('immutable') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` */ declare function Repeat(value: T, times?: number): Seq.Indexed; /** * @class * PDF action to reset form fields in the current document. * * It is an {@link https://immutable-js.com/docs/v5/Record/ | Immutable.Record} and thus * can be updated using `set(key, value)`, for example: `action.set("includeExclude", false);`. * * A ResetFormAction defines which form fields should be reset, when clicked on it. By default all * form fields will be reset to their default value. The `includeExclude` field defines if the * fields specified by `fields`, which are a {@link NutrientViewer.Immutable.List} of form field names, * should reset all form fields excluding the defined fields or just the defined fields. When * `includeExclude` is set to `true`, all form fields except the fields defined in `fields` will be * reset. If `includeExclude` is set to false, which is the default value for this field, only the * form fields defined in `fields` will be reset. * @example * Create a new ResetFormAction * ```ts * const action = new NutrientViewer.Actions.ResetFormAction({ * fields: List(["exampleField"]) * }); * ``` * * @summary Reset form fields in the current document. */ export declare class ResetFormAction extends Action { /** * A List identifying which fields to reset or which to exclude from resetting, depending on the * setting of the includeExclude flag. Each element of the array shall be a text string * representing the fully qualified name of a field. If this entry is omitted, the includeExclude * flag shall be ignored; all fields in the document’s interactive form are reset. * * @default null */ fields: List | null | undefined; /** * If false, the fields list specifies which fields to reset. * If true, the fields list indicates which fields to exclude from resetting. That is, all fields * in the document’s interactive form shall be reset except those listed in the fields list. * * @default false */ includeExclude: boolean; constructor(args?: IResetFormAction); } declare type ResizeAnchor = 'TOP' | 'BOTTOM' | 'LEFT' | 'RIGHT' | 'TOP_LEFT' | 'TOP_RIGHT' | 'BOTTOM_RIGHT' | 'BOTTOM_LEFT'; /** @inline */ declare type RotatableAnnotation = TextAnnotation | StampAnnotation; /** * Annotation free rotate helper. Rotates a {@link AnnotationsUnion} by the provided angle in degrees, * counter-clockwise. It only works with free rotatable annotations, such as {@link NutrientViewer.Annotations.TextAnnotation}, * {@link NutrientViewer.Annotations.ImageAnnotation} and {@link NutrientViewer.Annotations.StampAnnotation}. * * In order to rotate an annotation it's not enough to just change the rotation property. The annotation's * bounding box need to be resized and repositioned as well so as to fit the rotated content inside. * * This helper facilitates this task by updating both the rotation property and the bounding box. * * @example * Rotate a text annotation to 110 degrees. * ```ts * const annotation = new NutrientViewer.Annotations.TextAnnotation({ * text: `This is a test text for rotating * an annotation to 110 degrees.`, * boundingBox: new NutrientViewer.Geometry.Rect({ * x: 300, * y: 300, * width: 246, * height: 44 * }), * fontSize: 18, * font: "Helvetica" * }); * const rotatedAnnotation = NutrientViewer.Annotations.rotate( * annotation, * 110 * ); * instance.create(rotatedAnnotation.set('pageIndex', 0)); * ``` * * There is an edge case where the original annotation is already rotated by a multiple of 45 degrees. In this case * it's not possible to figure out the dimensions of the content, which will default to a square that fits in the bounding box. * In order to use the correct content dimensions, you can optionally provide a {@link NutrientViewer.Geometry.Size} object * that specifies the content's width and height, which should fit in the annotation's bounding box when using the * annotation rotation. * * For cases when the original annotation is rotated by any other angle, the content dimensions are calculated automatically, * but you can still provide this object if the annotation's bounding box does not correctly bound the content, so as to obtain * an annotation with a correctly bounding box as a result. * * @example * Rotate a 45 degree rotated annotation to 60 degrees. * ```ts * const rotated45Annotation = new NutrientViewer.Annotations.TextAnnotation({ * text: `This is a test text for a 45 * degree rotated text annotation.`, * rotation: 45, * boundingBox: new NutrientViewer.Geometry.Rect({ * x: 300, * y: 300, * width: 348, * height: 348 * }), * fontSize: 18, * font: "Helvetica" * }); * const rotated60Annotation = NutrientViewer.Annotations.rotate( * rotated45Annotation, * 60, * new NutrientViewer.Geometry.Size({ width: 246, height: 44 }) * ); * instance.create(rotated60Annotation.set('pageIndex', 0)); * ``` * This helper does not check if the resulting rotated annotation overflows the page limits. * * @public * @param annotation - The annotation to rotate * @param rotation - Rotation angle in degrees * @param contentSize - Size of the annotation's content for annotations rotated a in multiple of 45 degrees. * @returns */ declare function rotate(annotation: RotatableAnnotation, rotation: number, contentSize?: Size): RotatableAnnotation; /** @inline */ declare type Rotation = 0 | 90 | 180 | 270; /** * Reason for the error that occurred when saving a certain modification. * * @inline */ declare type SaveErrorReason = { /** Reason of the save failure. */ error: Error; /** Object that was being saved. */ object: T; /** modificationType Type of modification that was being saved. */ modificationType: IModificationType; }; /** * Describes mode of page scrolling in the document view - either continuous, per spread * (paginated) or disabled (changing pages through the UI is disabled). * * @enum */ declare const ScrollMode: { /** Render all pages as a list and allow smooth scrolling. This is the default mode. */ readonly CONTINUOUS: "CONTINUOUS"; /** * Makes scrolling only possible within a spread. Whenever this mode is activated, or pages are * changed when this mode is active, the zoom mode will be reset to * {@link NutrientViewer.ZoomMode.FIT_TO_VIEWPORT}. */ readonly PER_SPREAD: "PER_SPREAD"; /** * Makes scrolling only possible within a spread and doesn't allow changing pages. * Whenever this mode is activated the zoom mode will be reset to * {@link NutrientViewer.ZoomMode.FIT_TO_VIEWPORT}. */ readonly DISABLED: "DISABLED"; }; declare function SearchMixin>(Base: T): { new (...args: any[]): { /** * Queries the PDF backend for all search results of a given term. Search is case-insensitive and * accented letters are ignored. The minimum query length for the term query to be performed can * be retrieved from {@link SearchState.minSearchQueryLength}. * * Shorter queries will throw an error. * * @example * Search for all occurrences of `foo` * ```ts * instance.search("foo").then(results => { * console.log(results.size); * }); * ``` * * @example * Search within a page range. * ```ts * instance.search("foo", { startPageIndex: 1, endPageIndex: 4 }).then(results => { * console.log(results.size); * }); * ``` * * @example * Search for a regex. * ```ts * instance.search("Q[a-z]+ck\\sC.*[tT]", { searchType: NutrientViewer.SearchType.REGEX }).then(results => { * console.log(results.size); * }); * ``` * * @example * Search for all date patterns on the pages. * ```ts * instance.search(NutrientViewer.SearchPattern.DATE, { searchType: NutrientViewer.SearchType.PATTERN }).then(results => { * console.log(results.size); * }); * ``` * * @example * Search for a regex in a case-insensitive way. * ```ts * instance.search("he[a-z]+", { searchType: NutrientViewer.SearchType.REGEX, caseSensitive: false }).then(results => { * console.log(results.size); * }); * ``` * * @param term - The search term. * @param options - Parameters used for search operation. * @returns Resolves to an immutable list of search results. */ search(term: ISearchPattern | string, options?: { /** The page index to start searching from. `options.endPageIndex` must be provided if this parameter is given. */ startPageIndex?: number; /** The last page index to search (inclusive). `options.startPageIndex` must be provided if this parameter is given. */ endPageIndex?: number; /** * The search type which describes whether the query is a text, pattern or regex. * * @default NutrientViewer.SearchType.TEXT */ searchType?: ISearchType; /** * Whether you want to search in annotations. * * @default false */ searchInAnnotations?: boolean; /** * Whether you want the search to be case-sensitive. * * @default false */ caseSensitive?: boolean; }): Promise>; /** * Returns the latest search state. This value changes whenever the user interacts with * NutrientViewer or whenever {@link Instance#setSearchState} is called. * * The search state can be used to finely control the current search UI. */ readonly searchState: SearchState; /** * This method is used to update the UI search state of the PDF editor. * * When you pass in a {@link SearchState}, the current state will be immediately * overwritten. Calling this method is also idempotent. * * If you pass in a function, it will be immediately invoked and will receive the current * {@link SearchState} as a property. You can use this to change state based on the * current value. This type of update is guaranteed to be atomic - the value of `currentState` * can't change in between. * * When the supplied {@link SearchState} is invalid, this method will throw an * {@link Error} that contains a detailed error message. * * {@link SearchState#minSearchQueryLength} is a readonly property and cannot be changed. * If the provided {@link SearchState} object includes a modified `minSearchQueryLength` * property, a warning will be shown and only changes to other properties will be applied. * * @example * Update values for the immutable search state object * ```ts * const state = instance.SearchState; * const newState = state.set("isLoading", true); * instance.setSearchState(newState); * ``` * * @public * @throws {NutrientViewer.Error} Will throw an error when the supplied state is not valid. * @param stateOrFunction - Either a new SearchState which would overwrite the existing one, or a callback that will get invoked with the current search state and is expected to return the new state. */ setSearchState(stateOrFunction: SearchState | SetSearchStateFunction): void; /** * Open the search box, fill in the search term, and start loading the search requests. * * This will set the {@link ViewState#interactionMode} to * {@link NutrientViewer.InteractionMode}.SEARCH so that the search box is visible. * * @example * Start a search for the term `foo` in the UI * ```ts * instance.startUISearch("foo"); * ``` * * @param term - The search term. */ startUISearch(term: string): void; }; } & T; /** * Allows you to perform a search by a built-in pattern that matches common strings. * * Note that by design, some of these patterns might overfit the criteria (i.e. include false positive results). This might happen since we strive for * including all positive results and avoid data loss. Make sure to review the matches found. * * @enum * */ declare const SearchPattern: { /** Catches credit card numbers with a number beginning with 1-6, and must be 13 to 19 digits long. Spaces and - are allowed anywhere in the number. */ readonly CREDIT_CARD_NUMBER: "credit_card_number"; /** * Matches date formats such as mm/dd/yyyy, mm/dd/yy, dd/mm/yyyy, and dd/mm/yy. * It will reject any days/months greater than 31 and will match if a * leading zero is or is not used for a single digit day or month. * The delimiter can either be `-`, `.` or `/`. */ readonly DATE: "date"; /** * Matches time formats such as 00:00:00, 00:00, 00:00 PM. 12 and 24 hour formats are allowed. * Seconds and 12 hour AM/PM denotation are both optional. */ readonly TIME: "time"; /** * Matches an email address with the format of xyz@xyz.xyz where xyz can be any alpha numeric character or a . * For more information on the pattern please see http://emailregex.com/. */ readonly EMAIL_ADDRESS: "email_address"; /** Matches International style phone numbers with a prefix of + or 00, containing between 7 - 15 digits with spaces or - occurring anywhere within the number. */ readonly INTERNATIONAL_PHONE_NUMBER: "international_phone_number"; /** Matches an IPV4 address limited to number ranges of 0-255 with an optional mask. */ readonly IP_V4: "ipv4"; /** Matches full and compressed IPv6 addresses as defined in RFC 2373. */ readonly IP_V6: "ipv6"; /** Matches a MAC address with delimiters of either `-` or `:`. */ readonly MAC_ADDRESS: "mac_address"; /** * Matches a NANP (https://en.wikipedia.org/wiki/North_American_Numbering_Plan) style phone number. In general this will match US, Canadian and various other Caribbean countries. * The pattern will also match an optional international prefix of `+1`. */ readonly NORTH_AMERICAN_PHONE_NUMBER: "north_american_phone_number"; /** * Matches a US social security number (SSN). The format of the number should be either XXX-XX-XXXX or XXXXXXXXX with X denoting [0-9]. * We expect the number to have word boundaries on either side, or to be the start/end of the string. */ readonly SOCIAL_SECURITY_NUMBER: "social_security_number"; /** Matches a URL with a prefix of http|https|www with an optional subdomain. */ readonly URL: "url"; /** Matches a USA style Zip Code. The format expected is 00000 or 00000-0000, where the delimiter can either be `-` or `/`. */ readonly US_ZIP_CODE: "us_zip_code"; /** * Matches US and ISO 3779 standard VINs. * The format expects 17 characters with the last 5 characters being numeric. `I`,`O`,`Q`,`_` characters are not allowed in upper or lower case. */ readonly VIN: "vin"; }; /** * @class * A match when searching the PDF. * * You can retrieve search results by using {@link Instance#search} * @public * @summary A match when searching the PDF. * @hideconstructor */ export declare class SearchResult extends SearchResult_base {} declare const SearchResult_base: Record_2.Factory; /** @inline */ declare type SearchResultProps = { /** * The page where the result was found. */ pageIndex: number | null; /** * The text surrounding the search term that can be used to list a preview. */ previewText: string; /** * Location of the search term in the preview text. */ locationInPreview: number | null; /** * Length of the search term in the preview text. */ lengthInPreview: number | null; /** * All rects on the page that should be used to highlight the text. */ rectsOnPage: List; /** * Boolean to indicate whether the matching search result is part of an annotation. */ isAnnotation: boolean | null; /** * The bounding box of the annotation in which the result was found. This property is only available when the result is an annotation. */ annotationRect?: Rect | null; }; /** * @class * The current state of the search indicators inside the web view. * * You can update the search state using {@link Instance#setSearchState}. * @public * @summary Current search UI state. * @hideconstructor */ export declare class SearchState extends SearchState_base {} declare const SearchState_base: Record_2.Factory; /** @inline */ declare type SearchStateProps = { /** * Indicates that the search input has focus. */ isFocused: boolean; /** * Indicates that we're currently loading search requests. */ isLoading: boolean; /** * The current search term. Changing this term will not start a search. Please use * {@link NutrientViewer.Instance#startUISearch} for that purpose. */ term: string; /** * The currently focused result. -1 if no item is focused yet. * * @default -1 */ focusedResultIndex: number; /** * The latest search results. These will be rendered as highlights in the page view. */ results: List; /** * Current minimum search query length. When using the UI or the API function * {@link NutrientViewer.Instance#search}, any query shorter than this number will not be performed. * * In Server mode, this value is retrieved from the server at load time. * * The default value is `1` (not configurable) in Standalone mode, * and `3` in Server mode (configurable in the server). */ readonly minSearchQueryLength: number; }; /** * Defines the search type used for text search operations or when creating redaction annotations based on text search. * * @enum */ declare const SearchType: { /** This is the default search type. This is used when you want to search for strings/text. */ readonly TEXT: "text"; /** The search type when you want to use the patterns provided by us. see {@link NutrientViewer.SearchPattern} for the list of all the patterns. */ readonly PRESET: "preset"; /** * The search type when you want to search using regex. * Regex syntax: * - Standalone: JavaScript (see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions}). * - Server: {@link http://userguide.icu-project.org/strings/regexp|ICU regular expression}, a derivative of Perl regular expressions. * Regular expressions that follow the JavaScript syntax are matched in a similar way to the `RegExp.prototype.exec()` method (see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec}), but ignoring capturing groups, that is, the function only returns full string matches. */ readonly REGEX: "regex"; }; /** * Creates a Seq. * * Returns a particular kind of `Seq` based on the input. * * * If a `Seq`, that same `Seq`. * * If an `Collection`, a `Seq` of the same kind (Keyed, Indexed, or Set). * * If an Array-like, an `Seq.Indexed`. * * If an Iterable Object, an `Seq.Indexed`. * * If an Object, a `Seq.Keyed`. * * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, * which is usually not what you want. You should turn your Iterator Object into * an iterable object by defining a Symbol.iterator (or @@iterator) method which * returns `this`. * * Note: `Seq` is a conversion function and not a class, and does not use the * `new` keyword during construction. */ declare function Seq>(seq: S): S; declare function Seq(collection: Collection.Keyed): Seq.Keyed; declare function Seq(collection: Collection.Indexed): Seq.Indexed; declare function Seq(collection: Collection.Set): Seq.Set; declare function Seq(collection: Iterable): Seq.Indexed; declare function Seq(obj: {[key: string]: V;}): Seq.Keyed; declare function Seq(): Seq; /** * `Seq` describes a lazy operation, allowing them to efficiently chain * use of all the higher-order collection methods (such as `map` and `filter`) * by not creating intermediate collections. * * **Seq is immutable** — Once a Seq is created, it cannot be * changed, appended to, rearranged or otherwise modified. Instead, any * mutative method called on a `Seq` will return a new `Seq`. * * **Seq is lazy** — `Seq` does as little work as necessary to respond to any * method call. Values are often created during iteration, including implicit * iteration when reducing or converting to a concrete data structure such as * a `List` or JavaScript `Array`. * * For example, the following performs no work, because the resulting * `Seq`'s values are never iterated: * * ```js * const { Seq } = require('immutable') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) * ``` * * Once the `Seq` is used, it performs only the work necessary. In this * example, no intermediate arrays are ever created, filter is called three * times, and map is only called once: * * ```js * oddSquares.get(1); // 9 * ``` * * Any collection can be converted to a lazy Seq with `Seq()`. * * * ```js * const { Map } = require('immutable') * const map = Map({ a: 1, b: 2, c: 3 } * const lazySeq = Seq(map) * ``` * * `Seq` allows for the efficient chaining of operations, allowing for the * expression of logic that can otherwise be very tedious: * * ```js * lazySeq * .flip() * .map(key => key.toUpperCase()) * .flip() * // Seq { A: 1, B: 1, C: 1 } * ``` * * As well as expressing logic that would otherwise seem memory or time * limited, for example `Range` is a special kind of Lazy sequence. * * * ```js * const { Range } = require('immutable') * Range(1, Infinity) * .skip(1000) * .map(n => -n) * .filter(n => n % 2 === 0) * .take(2) * .reduce((r, n) => r * n, 1) * // 1006008 * ``` * * Seq is often used to provide a rich collection API to JavaScript Object. * * ```js * Seq({ x: 0, y: 1, z: 2 }).map(v => v * 2).toObject(); * // { x: 0, y: 2, z: 4 } * ``` */ declare module Seq { /** * True if `maybeSeq` is a Seq, it is not backed by a concrete * structure such as Map, List, or Set. */ function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed | Seq.Keyed | Seq.Set; /** * `Seq` which represents key-value pairs. */ module Keyed {} /** * Always returns a Seq.Keyed, if input is not keyed, expects an * collection of [K, V] tuples. * * Note: `Seq.Keyed` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; function Keyed(obj: {[key: string]: V;}): Seq.Keyed; function Keyed(): Seq.Keyed; function Keyed(): Seq.Keyed; interface Keyed extends Seq, Collection.Keyed { /** * Deeply converts this Keyed Seq to equivalent native JavaScript Object. * * Converts keys to Strings. */ toJS(): Object; /** * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. * * Converts keys to Strings. */ toJSON(): {[key: string]: V;}; /** * Shallowly converts this collection to an Array. */ toArray(): Array<[K, V]>; /** * Returns itself */ toSeq(): this; /** * Returns a new Seq with other collections concatenated to this one. * * All entries will be present in the resulting Seq, even if they * have the same key. */ concat(...collections: Array>): Seq.Keyed; concat(...collections: Array<{[key: string]: C;}>): Seq.Keyed; /** * Returns a new Seq.Keyed with values passed through a * `mapper` function. * * ```js * const { Seq } = require('immutable') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` * * Note: `map()` always returns a new instance, even if it produced the * same value at every step. */ map( mapper: (value: V, key: K, iter: this) => M, context?: any) : Seq.Keyed; /** * @see Collection.Keyed.mapKeys */ mapKeys( mapper: (key: K, value: V, iter: this) => M, context?: any) : Seq.Keyed; /** * @see Collection.Keyed.mapEntries */ mapEntries( mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any) : Seq.Keyed; /** * Flat-maps the Seq, returning a Seq of the same type. * * Similar to `seq.map(...).flatten(true)`. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, context?: any) : Seq.Keyed; /** * Returns a new Seq with only the entries for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: V, key: K, iter: this) => value is F, context?: any) : Seq.Keyed; filter( predicate: (value: V, key: K, iter: this) => any, context?: any) : this; /** * @see Collection.Keyed.flip */ flip(): Seq.Keyed; } /** * `Seq` which represents an ordered indexed list of values. */ module Indexed { /** * Provides an Seq.Indexed of the values provided. */ function of(...values: Array): Seq.Indexed; } /** * Always returns Seq.Indexed, discarding associated keys and * supplying incrementing indices. * * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ function Indexed(): Seq.Indexed; function Indexed(): Seq.Indexed; function Indexed(collection: Iterable): Seq.Indexed; interface Indexed extends Seq, Collection.Indexed { /** * Deeply converts this Indexed Seq to equivalent native JavaScript Array. */ toJS(): Array; /** * Shallowly converts this Indexed Seq to equivalent native JavaScript Array. */ toJSON(): Array; /** * Shallowly converts this collection to an Array. */ toArray(): Array; /** * Returns itself */ toSeq(): this; /** * Returns a new Seq with other collections concatenated to this one. */ concat(...valuesOrCollections: Array | C>): Seq.Indexed; /** * Returns a new Seq.Indexed with values passed through a * `mapper` function. * * ```js * const { Seq } = require('immutable') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` * * Note: `map()` always returns a new instance, even if it produced the * same value at every step. */ map( mapper: (value: T, key: number, iter: this) => M, context?: any) : Seq.Indexed; /** * Flat-maps the Seq, returning a a Seq of the same type. * * Similar to `seq.map(...).flatten(true)`. */ flatMap( mapper: (value: T, key: number, iter: this) => Iterable, context?: any) : Seq.Indexed; /** * Returns a new Seq with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: T, index: number, iter: this) => value is F, context?: any) : Seq.Indexed; filter( predicate: (value: T, index: number, iter: this) => any, context?: any) : this; /** * Returns a Seq "zipped" with the provided collections. * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * ```js * const a = Seq([ 1, 2, 3 ]); * const b = Seq([ 4, 5, 6 ]); * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ zip(other: Collection): Seq.Indexed<[T, U]>; zip(other: Collection, other2: Collection): Seq.Indexed<[T, U, V]>; zip(...collections: Array>): Seq.Indexed; /** * Returns a Seq "zipped" with the provided collections. * * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * * ```js * const a = Seq([ 1, 2 ]); * const b = Seq([ 3, 4, 5 ]); * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ zipAll(other: Collection): Seq.Indexed<[T, U]>; zipAll(other: Collection, other2: Collection): Seq.Indexed<[T, U, V]>; zipAll(...collections: Array>): Seq.Indexed; /** * Returns a Seq "zipped" with the provided collections by using a * custom `zipper` function. * * ```js * const a = Seq([ 1, 2, 3 ]); * const b = Seq([ 4, 5, 6 ]); * const c = a.zipWith((a, b) => a + b, b); * // Seq [ 5, 7, 9 ] * ``` */ zipWith( zipper: (value: T, otherValue: U) => Z, otherCollection: Collection) : Seq.Indexed; zipWith( zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection, thirdCollection: Collection) : Seq.Indexed; zipWith( zipper: (...any: Array) => Z, ...collections: Array>) : Seq.Indexed; } /** * `Seq` which represents a set of values. * * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee * of value uniqueness as the concrete `Set`. */ module Set { /** * Returns a Seq.Set of the provided values */ function of(...values: Array): Seq.Set; } /** * Always returns a Seq.Set, discarding associated indices or keys. * * Note: `Seq.Set` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ function Set(): Seq.Set; function Set(): Seq.Set; function Set(collection: Iterable): Seq.Set; interface Set extends Seq, Collection.Set { /** * Deeply converts this Set Seq to equivalent native JavaScript Array. */ toJS(): Array; /** * Shallowly converts this Set Seq to equivalent native JavaScript Array. */ toJSON(): Array; /** * Shallowly converts this collection to an Array. */ toArray(): Array; /** * Returns itself */ toSeq(): this; /** * Returns a new Seq with other collections concatenated to this one. * * All entries will be present in the resulting Seq, even if they * are duplicates. */ concat(...collections: Array>): Seq.Set; /** * Returns a new Seq.Set with values passed through a * `mapper` function. * * ```js * Seq.Set([ 1, 2 ]).map(x => 10 * x) * // Seq { 10, 20 } * ``` * * Note: `map()` always returns a new instance, even if it produced the * same value at every step. */ map( mapper: (value: T, key: T, iter: this) => M, context?: any) : Seq.Set; /** * Flat-maps the Seq, returning a Seq of the same type. * * Similar to `seq.map(...).flatten(true)`. */ flatMap( mapper: (value: T, key: T, iter: this) => Iterable, context?: any) : Seq.Set; /** * Returns a new Seq with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: T, key: T, iter: this) => value is F, context?: any) : Seq.Set; filter( predicate: (value: T, key: T, iter: this) => any, context?: any) : this; } } declare interface Seq extends Collection { /** * Some Seqs can describe their size lazily. When this is the case, * size will be an integer. Otherwise it will be undefined. * * For example, Seqs returned from `map()` or `reverse()` * preserve the size of the original `Seq` while `filter()` does not. * * Note: `Range`, `Repeat` and `Seq`s made from `Array`s and `Object`s will * always have a size. */ readonly size: number | undefined; // Force evaluation /** * Because Sequences are lazy and designed to be chained together, they do * not cache their results. For example, this map function is called a total * of 6 times, as each `join` iterates the Seq of three values. * * var squares = Seq([ 1, 2, 3 ]).map(x => x * x) * squares.join() + squares.join() * * If you know a `Seq` will be used multiple times, it may be more * efficient to first cache it in memory. Here, the map function is called * only 3 times. * * var squares = Seq([ 1, 2, 3 ]).map(x => x * x).cacheResult() * squares.join() + squares.join() * * Use this method judiciously, as it must fully evaluate a Seq which can be * a burden on memory and possibly performance. * * Note: after calling `cacheResult`, a Seq will always have a `size`. */ cacheResult(): this; // Sequence algorithms /** * Returns a new Seq with values passed through a * `mapper` function. * * ```js * const { Seq } = require('immutable') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` * * Note: `map()` always returns a new instance, even if it produced the same * value at every step. */ map( mapper: (value: V, key: K, iter: this) => M, context?: any) : Seq; /** * Returns a new Seq with values passed through a * `mapper` function. * * ```js * const { Seq } = require('immutable') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` * * Note: `map()` always returns a new instance, even if it produced the same * value at every step. * Note: used only for sets. */ map( mapper: (value: V, key: K, iter: this) => M, context?: any) : Seq; /** * Flat-maps the Seq, returning a Seq of the same type. * * Similar to `seq.map(...).flatten(true)`. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable, context?: any) : Seq; /** * Flat-maps the Seq, returning a Seq of the same type. * * Similar to `seq.map(...).flatten(true)`. * Note: Used only for sets. */ flatMap( mapper: (value: V, key: K, iter: this) => Iterable, context?: any) : Seq; /** * Returns a new Seq with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: V, key: K, iter: this) => value is F, context?: any) : Seq; filter( predicate: (value: V, key: K, iter: this) => any, context?: any) : this; } declare function serializeAnnotation(annotation: InkAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: LineAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: RectangleAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: EllipseAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: PolygonAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: PolylineAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: TextAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: NoteAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: StampAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: ImageAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: MediaAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: LinkAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: WidgetAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: TextMarkupAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: RedactionAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: CommentMarkerAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: UnknownAnnotation): AnnotationBackendJSON; declare function serializeAnnotation(annotation: AnnotationsUnion): AnnotationsBackendJSONUnion; /** @inline */ declare type SerializedAdditionalActionsType = { [key in ActionTriggerEventType | FormFieldEventTriggerType | FormFieldInputEventTriggerType | WidgetActionTriggerEventType as string]?: { type: string; [key: string]: unknown; } }; declare type SerializedJSON = { skippedPdfObjectIds?: number[]; annotations?: Serializers.AnnotationJSONUnion[]; formFields?: Serializers.FormFieldJSON[]; skippedPdfFormFieldIds?: number[]; formFieldValues?: Record[]; comments?: Record[]; skippedComments?: number[]; attachments?: Record; skippedPdfBookmarkIds?: string[]; bookmarks?: Serializers.BookmarkJSON[]; }; /** * Form field serializer. Converts one of the supported {@link NutrientViewer.FormFields} to InstantJSON compliant objects. * * @returns The serialized form field. */ declare function serializeFormField(formField: FormField): Serializers.FormFieldJSON; /** * Annotation preset serializer. Converts a {@link AnnotationPreset} to an object. * * @param preset - Annotation preset to serialize. */ declare function serializePreset(preset: AnnotationPreset): Record; /** * This namespace contains types and interfaces for serializing and deserializing * PDF annotations, form fields, comments, bookmarks, and related data * to and from JSON representations compatible with the Nutrient Web SDK. These serialised objects * can be used in {@link InstantJSON} * * #### Serialising an annotation * You can use {@link NutrientViewer.Annotations.toSerializableObject} to create serialised object from an annotation. * ```ts * const annotation = new NutrientViewer.Annotations.TextAnnotation({ * pageIndex: 0, * text: { format: "plain", value : "Welcome to\nNutrientViewer" }, * font: "Helvetica", * boundingBox: new NutrientViewer.Geometry.Rect({ left: 10, top: 20, width: 30, height: 40 }), * }); * * const serialisedAnnotation = NutrientViewer.toSerializableObject(annotation); * ``` * * #### Serialising a form field * You can use {@link NutrientViewer.FormFields.toSerializableObject} to create serialised object from a form field. * ```ts * const formField = new NutrientViewer.FormFields.TextFormField({ * pageIndex: 0, * value: "Hello, world!", * }); * * const serialisedFormField = NutrientViewer.FormFields.toSerializableObject(formField); * ``` * * #### Serialising a bookmark * You can use {@link NutrientViewer.Bookmark.toSerializableObject} to create serialised object from a bookmark. * ```ts * const bookmark = new NutrientViewer.Bookmarks.Bookmark({ * pageIndex: 0, * name: "Bookmark 1", * action: new NutrientViewer.Actions.GoToAction({ pageIndex: 0 }), * }); * * const serialisedBookmark = NutrientViewer.Bookmark.toSerializableObject(bookmark); * ``` * * #### Serialising a comment * You can use {@link NutrientViewer.Comment.toSerializableObject} to create a serialised object from a comment. * ```ts * const comment = new NutrientViewer.Comments.Comment({ * pageIndex: 0, * text: { format: "plain", value : "Welcome to\nNutrientViewer" }, * }); * * const serialisedComment = NutrientViewer.Comment.toSerializableObject(comment); * ``` * * @see {@link NutrientViewer.Annotations.toSerializableObject} | {@link NutrientViewer.Annotations.fromSerializableObject} * @see {@link NutrientViewer.FormFields.toSerializableObject} | {@link NutrientViewer.FormFields.fromSerializableObject} * @see {@link NutrientViewer.Bookmark.toSerializableObject} | {@link NutrientViewer.Bookmark.fromSerializableObject} * @see {@link NutrientViewer.Comment.toSerializableObject} | {@link NutrientViewer.Comment.fromSerializableObject} */ export declare namespace Serializers { /** * @group FormField */ export interface ChoiceFormFieldJSON extends BaseFormFieldJSON { type: 'pspdfkit/form-field/listbox' | 'pspdfkit/form-field/combobox'; options: Array; multiSelect: boolean; commitOnChange: boolean; defaultValues: Array; } /** * @group FormField */ export interface ListBoxFormFieldJSON extends ChoiceFormFieldJSON { type: 'pspdfkit/form-field/listbox'; } /** * @group FormField */ export type ComboBoxFormFieldJSON = ChoiceFormFieldJSON & DoNotSpellCheckPropertyPair & { type: 'pspdfkit/form-field/combobox'; edit: boolean; }; /** * @group FormField */ export interface CheckBoxFormFieldJSON extends BaseFormFieldJSON { type: 'pspdfkit/form-field/checkbox'; options: Array; defaultValues: Array; } /** * @group FormField */ export interface RadioButtonFormFieldJSON extends BaseFormFieldJSON { type: 'pspdfkit/form-field/radio'; options: Array; noToggleToOff: boolean; radiosInUnison: boolean; defaultValue: string; } /** * @group FormField */ export type TextFormFieldJSON = BaseFormFieldJSON & { type: 'pspdfkit/form-field/text'; password: boolean; maxLength?: number | null; doNotScroll: boolean; multiLine: boolean; defaultValue: string; comb: boolean; } & DoNotSpellCheckPropertyPair; /** * @group FormField */ export interface ButtonFormFieldJSON extends BaseFormFieldJSON { type: 'pspdfkit/form-field/button'; buttonLabel: string | null; } /** * @group FormField */ export interface SignatureFormFieldJSON extends BaseFormFieldJSON { type: 'pspdfkit/form-field/signature'; } /** * @group FormField */ export interface UnknownFormFieldJSON extends BaseFormFieldJSON { type: 'pspdfkit/form-field/unknown'; } /** * @group FormField */ export type FormFieldJSON = ListBoxFormFieldJSON | ComboBoxFormFieldJSON | RadioButtonFormFieldJSON | CheckBoxFormFieldJSON | TextFormFieldJSON | ButtonFormFieldJSON | SignatureFormFieldJSON | UnknownFormFieldJSON; /** * @group FormFieldValue */ export interface FormFieldValueJSON { type: 'pspdfkit/form-field-value'; v: 1; name: string; value?: string | string[] | null; optionIndexes?: Array; isFitting?: boolean; pdfObjectId?: number; } /** * Used to represent options in ChoiceFormFields. * * @group FormOption */ export interface FormOptionJSON { label: string; value: string; } /** * @group Annotation */ export interface ImageAnnotationJSON extends Omit { type: 'pspdfkit/image'; description?: string | null; fileName?: string | null; contentType: string; imageAttachmentId: string; rotation: number; isSignature?: boolean; xfdfAppearanceStream?: string; xfdfAppearanceStreamOriginalPageRotation?: number; } /** * @group Annotation */ export interface ShapeAnnotationJSON extends Omit { strokeWidth: number; strokeColor: string | null; fillColor: string | null; strokeDashArray?: [number, number] | null; measurementPrecision?: IMeasurementPrecision | null; measurementScale?: MeasurementScaleJSON | null; lineWidth?: number | null; } /** * @group Annotation */ export interface EllipseAnnotationJSON extends ShapeAnnotationJSON { type: 'pspdfkit/shape/ellipse'; cloudyBorderIntensity: number | null; cloudyBorderInset: InsetJSON | null; measurementBBox: IRectJSON | null; } /** * @group Annotation */ export interface LineAnnotationJSON extends ShapeAnnotationJSON { type: 'pspdfkit/shape/line'; startPoint: [number, number]; endPoint: [number, number]; lineCaps?: LineCapsType | null; lines?: { points: [number, number][][]; intensities: number[][]; }; } /** * @group Annotation */ export interface PolygonAnnotationJSON extends ShapeAnnotationJSON { type: 'pspdfkit/shape/polygon'; points: [number, number][]; cloudyBorderIntensity: number | null; lines?: { points: [number, number][][]; intensities: number[][]; }; } /** * @group Annotation */ export interface PolylineAnnotationJSON extends ShapeAnnotationJSON { type: 'pspdfkit/shape/polyline'; points: [number, number][]; lineCaps?: LineCapsType | null; lines?: { points: [number, number][][]; intensities: number[][]; }; } /** * @group Annotation */ export interface RectangleAnnotationJSON extends ShapeAnnotationJSON { type: 'pspdfkit/shape/rectangle'; cloudyBorderIntensity: number | null; cloudyBorderInset?: InsetJSON | null; measurementBBox: IRectJSON | null; } /** * @group Annotation */ export interface InkAnnotationJSON extends BaseAnnotationJSON { type: 'pspdfkit/ink'; lines: { points: [number, number][][]; intensities: number[][]; }; lineWidth: number; strokeColor: string | null; backgroundColor: string | null; isDrawnNaturally: boolean; isSignature: boolean; } /** * @group Annotation */ export interface LinkAnnotationJSON extends BaseAnnotationJSON { type: 'pspdfkit/link'; borderColor?: string | null; borderWidth?: number | null; borderStyle?: IBorderStyle | null; } /** * @group Annotation */ export interface NoteAnnotationJSON extends Omit { type: 'pspdfkit/note'; text?: { format: 'plain'; value: string; }; icon?: string; color?: string; } /** * @group Annotation */ export interface MediaAnnotationJSON extends Omit { type: 'pspdfkit/media'; description: string | null; fileName: string | null; contentType: string | null; mediaAttachmentId: string | null; } /** * @group Annotation */ export interface TextMarkupAnnotationJSON extends BaseTextMarkupAnnotationJSON { type: 'pspdfkit/markup/highlight' | 'pspdfkit/markup/squiggly' | 'pspdfkit/markup/strikeout' | 'pspdfkit/markup/underline' | 'pspdfkit/markup/redaction'; color: string | null; } /** * @group Annotation */ export interface RedactionAnnotationJSON extends BaseTextMarkupAnnotationJSON { type: 'pspdfkit/markup/redaction'; fillColor?: string | null; outlineColor?: string | null; overlayText?: string | null; repeatOverlayText?: boolean | null; rotation?: number; color?: string | null; fontSize?: number | null; } /** * @group Annotation */ export interface StampAnnotationJSON extends Omit { type: 'pspdfkit/stamp'; stampType: StampKind; title: string | null; color?: string | null; subTitle?: string | null; subtitle: string | null; rotation: number | null; multiline?: boolean | null; font?: string | null; fontSize?: number | null; fontColor?: string | null; fontStyle?: string[] | null; imageAttachmentId?: string | null; imageContentType?: string | null; imagePosition?: { row: number; align: 'left' | 'center' | 'right'; } | null; xfdfAppearanceStream?: string; xfdfAppearanceStreamOriginalPageRotation?: number; /** * @deprecated */ kind?: StampKind; } /** * @group Annotation */ export interface TextAnnotationJSON extends Omit { type: 'pspdfkit/text'; text: { format: 'xhtml' | 'plain'; value: string; }; fontColor?: string | null; backgroundColor?: string | null; font?: string | null; rotation?: number | null; fontSize?: number | null; fontStyle?: string[] | null; horizontalAlign?: 'left' | 'center' | 'right'; verticalAlign?: 'top' | 'center' | 'bottom'; callout?: { start: [number, number]; knee?: [number, number] | null; end: [number, number]; cap?: ILineCap | null; innerRectInset?: InsetJSON | null; } | null; borderStyle?: IBorderStyle | null; borderWidth?: number | null; borderColor?: string | null; isFitting?: boolean; lineHeightFactor?: number | null; } /** * @group Annotation */ export interface UnknownAnnotationJSON extends Omit { type: 'pspdfkit/unknown'; } /** * @group Annotation */ export interface WidgetAnnotationJSON extends Omit { type: 'pspdfkit/widget'; formFieldName: string; borderColor?: string | null; borderStyle?: IBorderStyle | null; borderDashArray?: number[] | null; borderWidth?: number | null; font?: string | null; fontSize?: 'auto' | number | null; fontColor?: string | null; backgroundColor?: string | null; horizontalAlign?: 'left' | 'center' | 'right' | null; verticalAlign?: 'top' | 'center' | 'bottom' | null; fontStyle?: string[] | null | undefined; rotation?: number; additionalActions?: SerializedAdditionalActionsType | null; lineHeightFactor?: number | null; widgetAttachmentId?: string | null; contentType?: string | null; buttonIconUpdatedAt?: number | null; } /** * @group Annotation */ export interface CommentMarkerAnnotationJSON extends Omit { type: 'pspdfkit/comment-marker'; } /** * @group Annotation */ export type AnnotationJSONUnion = TextMarkupAnnotationJSON | TextAnnotationJSON | WidgetAnnotationJSON | RedactionAnnotationJSON | StampAnnotationJSON | NoteAnnotationJSON | LinkAnnotationJSON | InkAnnotationJSON | RectangleAnnotationJSON | PolylineAnnotationJSON | PolygonAnnotationJSON | LineAnnotationJSON | EllipseAnnotationJSON | ImageAnnotationJSON | UnknownAnnotationJSON | MediaAnnotationJSON | CommentMarkerAnnotationJSON; /** * @group Comment */ export interface CommentJSON extends ICollaboratorPermissionsOptions { id?: string | null; type: 'pspdfkit/comment'; v: 2; rootId: string | number | null; pageIndex: number | null; pdfObjectId?: number | null; creatorName?: string | null; name?: string | null; createdAt: string | Date; updatedAt: string | Date; text: { value: string | null; format: 'xhtml' | 'plain'; }; customData?: { [key: string]: unknown; } | null; isAnonymous?: boolean | null; } /** * @group Bookmark */ export type BookmarkJSON = { v: 1; type: 'pspdfkit/bookmark'; id: string; name: string | null; sortKey: number | null; action: CoreActionJSON; pdfBookmarkId: string | null; }; /** * @group Action * */ export type ActionJSON = CoreActionJSON; } declare function ServerAuthMixin>(Base: T): { new (...args: any[]): { /** * Updates the JWT (session token) and triggers re-authentication. Call this from * {@link NutrientViewer.Configuration#onAuthFailed|onAuthFailed} when tokens expire, * or proactively before expiry to avoid auth failures. * * @public * @param session - The new JWT token. */ setSession(session: string): void; }; } & T; declare interface ServerConfiguration extends SharedConfiguration { /** * ***required, Server only*** * * The `authPayload` is the configuration for the JSON Web Token. * * Please refer to {@link https://www.nutrient.io/guides/document-engine/viewer/client-authentication/ | this guide article} for information how to create valid JWTs. * * @example * NutrientViewer.load({ * authPayload: { jwt: 'xxx.xxx.xxx' } * // Other configuration options * }); * * @server */ authPayload?: { jwt: string; }; /** * ***Server only*** * * The `session` token used to authenticate Web Viewer session with DWS Viewer API or Document Engine. * * @example * NutrientViewer.load({ session: 'xxx.xxx.xxx' }); * * @server */ session?: string; /** * ***optional, Server only*** * * Callback invoked when JWT tokens expire and soft refresh fails. Implement this to fetch a new JWT * and call {@link NutrientViewer.Instance#setSession|setSession(newJwt)} within 30 seconds. * If not called in time, the SDK throws and does not recover. * * @example * NutrientViewer.load({ * documentId: 'doc', * authPayload: { jwt: initialJwt }, * onAuthFailed: async () => { * const newJwt = await fetchNewJwtFromBackend(); * instance.setSession(newJwt); * }, * }); * * @server */ onAuthFailed?: () => void | Promise; /** * ***required, Server only*** * * Nutrient Instant is a real-time collaboration platform that enables your users to annotate documents * using NutrientViewer across iOS, Android and their browser simultaneously. Annotations synchronized * using Nutrient Instant are pushed in real-time to every connected device. * * All document editing features, such as text annotations, ink drawing or text highlighting, are instantly saved and propagated across all connected devices. * * When this flag is set to `true`, different parts of the API will also be enabled, for example: * {@link NutrientViewer.Instance#connectedClients}. * * This value does not have a default. You either need to define `instant: true` or * `instant: false` in your NutrientViewer configuration. * * @example * NutrientViewer.load({ * instant: true * // Other configuration options * }); * * @server * @default false */ instant: Instant[keyof Instant]; /** * ***optional, Server only*** * * A list of users that can be mentioned in comments. * * @example * NutrientViewer.load({ mentionableUsers: [ * { id: "1", name: "John Doe", displayName: "John", avatar: "https://example.com/avatar.png", description: "john.doe@gmail.com" }, * { id: "2", name: "Jane Doe", displayName: "Jane", avatar: "https://example.com/avatar.png", description: "jane.doe@gmail.com" }, * { id: "3", name: "John Smith", displayName: "John", avatar: "https://example.com/avatar.png", description: "john.smith@gmail.com" }, * ] }); * * @server */ mentionableUsers?: Array; /** * ***optional, Server only*** * * The maximum number of users that will be shown in the suggestion dropdown * when mentioning a user in a comment. * * @example * NutrientViewer.load({ maxMentionSuggestions: 5 }); * * @default 5 * @server */ maxMentionSuggestions?: number; /** * ***required, Server only*** * * The document ID for the document that should be displayed. You can create a document via the * Nutrient Document Engine API. * * Please refer to the Server API documentation for a guide on how to create valid documents. * * @example * NutrientViewer.load({ * documentId: '85203' * // Other configuration options * }); * * @server */ documentId?: string; } /** * Returns a copy of the collection with the value at key set to the provided * value. * * A functional alternative to `collection.set(key, value)` which will also * work with plain Objects and Arrays as an alternative for * `collectionCopy[key] = value`. * * * ```js * const { set } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] * const originalObject = { x: 123, y: 456 } * set(originalObject, 'x', 789) // { x: 789, y: 456 } * console.log(originalObject) // { x: 123, y: 456 } * ``` */ declare function set>(collection: C, key: K, value: V): C; declare function set, K extends keyof TProps>(record: C, key: K, value: TProps[K]): C; declare function set>(collection: C, key: number, value: V): C; declare function set(object: C, key: K, value: C[K]): C; declare function set(collection: C, key: string, value: V): C; /** * Create a new immutable Set containing the values of the provided * collection-like. * * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ declare function Set_2(): Set_2; declare function Set_2(): Set_2; declare function Set_2(collection: Iterable): Set_2; /** * A Collection of unique values with `O(log32 N)` adds and has. * * When iterating a Set, the entries will be (value, value) pairs. Iteration * order of a Set is undefined, however is stable. Multiple iterations of the * same Set will iterate in the same order. * * Set values, like Map keys, may be of any type. Equality is determined using * `Immutable.is`, enabling Sets to uniquely include other Immutable * collections, custom value types, and NaN. */ declare module Set_2 { /** * True if the provided value is a Set */ function isSet(maybeSet: any): maybeSet is Set_2; /** * Creates a new Set containing `values`. */ function of(...values: Array): Set_2; /** * `Set.fromKeys()` creates a new immutable Set containing the keys from * this Collection or JavaScript Object. */ function fromKeys(iter: Collection): Set_2; function fromKeys(obj: {[key: string]: any;}): Set_2; /** * `Set.intersect()` creates a new immutable Set that is the intersection of * a collection of other sets. * * ```js * const { Set } = require('immutable') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) * ]) * // Set [ "a", "c"" ] * ``` */ function intersect(sets: Iterable>): Set_2; /** * `Set.union()` creates a new immutable Set that is the union of a * collection of other sets. * * ```js * const { Set } = require('immutable') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) * ]) * // Set [ "a", "b", "c", "t"" ] * ``` */ function union(sets: Iterable>): Set_2; } declare interface Set_2 extends Collection.Set { /** * The number of items in this Set. */ readonly size: number; // Persistent changes /** * Returns a new Set which also includes this value. * * Note: `add` can be used in `withMutations`. */ add(value: T): this; /** * Returns a new Set which excludes this value. * * Note: `delete` can be used in `withMutations`. * * Note: `delete` **cannot** be safely used in IE8, use `remove` if * supporting old browsers. * * @alias remove */ delete(value: T): this; remove(value: T): this; /** * Returns a new Set containing no values. * * Note: `clear` can be used in `withMutations`. */ clear(): this; /** * Returns a Set including any value from `collections` that does not already * exist in this Set. * * Note: `union` can be used in `withMutations`. * @alias merge * @alias concat */ union(...collections: Array>): Set_2; merge(...collections: Array>): Set_2; concat(...collections: Array>): Set_2; /** * Returns a Set which has removed any values not also contained * within `collections`. * * Note: `intersect` can be used in `withMutations`. */ intersect(...collections: Array>): this; /** * Returns a Set excluding any values contained within `collections`. * * * ```js * const { OrderedSet } = require('immutable') * OrderedSet([ 1, 2, 3 ]).subtract([1, 3]) * // OrderedSet [2] * ``` * * Note: `subtract` can be used in `withMutations`. */ subtract(...collections: Array>): this; // Transient changes /** * Note: Not all methods can be used on a mutable collection or within * `withMutations`! Check the documentation for each method to see if it * mentions being safe to use in `withMutations`. * * @see `Map#withMutations` */ withMutations(mutator: (mutable: this) => any): this; /** * Note: Not all methods can be used on a mutable collection or within * `withMutations`! Check the documentation for each method to see if it * mentions being safe to use in `withMutations`. * * @see `Map#asMutable` */ asMutable(): this; /** * @see `Map#wasAltered` */ wasAltered(): boolean; /** * @see `Map#asImmutable` */ asImmutable(): this; // Sequence algorithms /** * Returns a new Set with values passed through a * `mapper` function. * * Set([1,2]).map(x => 10 * x) * // Set [10,20] */ map( mapper: (value: T, key: T, iter: this) => M, context?: any) : Set_2; /** * Flat-maps the Set, returning a new Set. * * Similar to `set.map(...).flatten(true)`. */ flatMap( mapper: (value: T, key: T, iter: this) => Iterable, context?: any) : Set_2; /** * Returns a new Set with only the values for which the `predicate` * function returns true. * * Note: `filter()` always returns a new instance, even if it results in * not filtering out any values. */ filter( predicate: (value: T, key: T, iter: this) => value is F, context?: any) : Set_2; filter( predicate: (value: T, key: T, iter: this) => any, context?: any) : this; } export { Set_2 as Set }; /** * This callback can be used in the {@link NutrientViewer.Instance#setDocumentEditorFooterItems|setDocumentEditorFooterItems()} * method to do atomic updates to the document editor footer items. * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setDocumentEditorFooterItems(items => { * const button = instance.contentDocument.createElement('div'); * button.innerText = "Custom Save" * items.push({ * type: "custom", * node: button, * onPress(){ * alert("save"); * } * }); * return items; * }); * ``` * * @public * @param currentState - The current document editor footer items. * @returns The new document editor footer items. * @inline */ declare type SetDocumentEditorFooterFunction = (currentState: DocumentEditorFooterItem[]) => DocumentEditorFooterItem[]; /** * This callback can be used in the {@link NutrientViewer.Instance#setDocumentEditorToolbarItems | setDocumentEditorToolbarItems()} * method to do atomic updates to the document editor toolbar items. * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setDocumentEditorToolbarItems(items => { * const button = instance.contentDocument.createElement('div'); * button.innerText = "Do something" * items.push({ * type: "custom", * node: button, * onPress(){ * alert("Do Something"); * } * }); * return items; * }); * ``` * * @public * @param currentState - The current document editor toolbar items. * @returns The new document editor toolbar items. * @inline */ export declare type SetDocumentEditorToolbarFunction = (currentState: DocumentEditorToolbarItem[]) => DocumentEditorToolbarItem[]; /** * Returns a copy of the collection with the value at the key path set to the * provided value. * * A functional alternative to `collection.setIn(keypath)` which will also * work with plain Objects and Arrays. * * * ```js * const { setIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} * console.log(original) // { x: { y: { z: 123 }}} * ``` */ declare function setIn(collection: C, keyPath: Iterable, value: any): C; /** * Callback function to modify the current stack of document operations to be applied to the open document. * This function is invoked with the current stack of document operations as the first argument, and must return the new stack of document operations. * The new stack of document operations can be the same as the current one, or a new one. * * @param callback - Callback that receives the current operations committed and returns a new list of operations. * @param clearPagesSelection - Whether to clear the current selection of pages after returning the new operations or not. * @returns The new stack of document operations. * @inline */ declare type SetOperationsCallback = (callback: StagedDocumentOperationsCallback, clearPagesSelection?: boolean) => void | Promise; /** * This callback can be used in the {@link Instance#setSearchState | setSearchState()} * method to do atomic updates to the current search state. * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setSearchState(state => state.set("isFocused", true)); * ``` * * @param currentState - The current search state. * @returns The new search state. * @inline */ declare type SetSearchStateFunction = (currentState: SearchState) => SearchState; /** * This callback can be used in the {@link NutrientViewer.Instance#setStampAnnotationTemplates | setStampAnnotationTemplates()} * method to do atomic updates to the current stamp annotation templates. * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setStampAnnotationTemplates(stamps => { * stamps.pop(); // removes the last template of the stamps array * return stamps; * }); * ``` * * @param currentStampAnnotationTemplates - The current stamp and image annotation templates. * @returns The new stamp and image annotation templates. * * @inline */ declare type SetStampAnnotationTemplatesFunction = (currentStampAnnotationTemplates: Array) => Array; /** * This callback can be used in the {@link Instance#setToolbarItems | setToolbarItems()} * method to do atomic updates to the current toolbar items. * * @example * Use ES2015 arrow functions and the update callback to reduce boilerplate * ```ts * instance.setToolbarItems(items => { * items.push({ * type: "custom", * title: "My Custom Button", * onPress(){ * alert("hello"); * } * }); * return items; * }); * ``` * * @param currentToolbarItems - The current toolbar items. * @returns The new toolbar items. * @inline */ declare type SetToolbarFunction = (currentToolbarItems: ToolbarItem_2[]) => ToolbarItem_2[]; /** @inline */ declare type SetToolbarItemsFunction = (currentState: TextComparisonToolbarItem[]) => TextComparisonToolbarItem[]; /** * @class * Base annotation type from which all shape annotations inherit. You can not directly instantiate * from this type. * * Shape annotations are used to draw different shapes on a page: lines, rectangles, ellipses, * polylines and polygons. * * Shapes which have start and ending points such as lines and polylines can have optional line * start and line ending markers which can be filled with an optional fill color. * * Shapes which define a closed area such as rectangles, ellipses and polygons, can have an optional * fill color for the enclosed area. * * Shapes lines can be solid or dashed with a dash pattern chosen from a predefined list. * * Shape annotations without a fill color or with transparent fill color are only selectable * around their visible lines or colored areas. This means that you can create a page full of * these annotations while annotations behind them are still selectable. * * Right now, shape annotations are implemented using SVG images. This behavior is subject to change. * * For interacting with a shape annotation, please look at the subtypes: * * - {@link NutrientViewer.Annotations.LineAnnotation} * - {@link NutrientViewer.Annotations.RectangleAnnotation} * - {@link NutrientViewer.Annotations.EllipseAnnotation} * - {@link NutrientViewer.Annotations.PolylineAnnotation} * - {@link NutrientViewer.Annotations.PolygonAnnotation} * @example Create a shape annotation (line) that displays a line * const annotation = new NutrientViewer.Annotations.LineAnnotation({ * pageIndex: 0, * startPoint: new NutrientViewer.Geometry.Point({ x: 95, y: 5 }), * endPoint: new NutrientViewer.Geometry.Point({ x: 5, y: 95}), * strokeWidth: 4 * }); * * @summary Base annotation type for all shape annotations. */ export declare abstract class ShapeAnnotation extends Annotation { /** * Optional dash pattern used to draw the shape lines for dashed line style. */ strokeDashArray: null | [number, number]; /** * The width of the line in page size pixels. By default, we use values between 1 and 40 in * the UI. * * The stroke width will scale when you zoom in. * * @default 5 */ strokeWidth: number; /** * A {@link NutrientViewer.Color} for the shape lines * * @default Color.BLUE */ strokeColor: null | Color; /** * A {@link NutrientViewer.Color} to fill the interior of closed shapes (ellipses, rectangles and polygons) * or start and / or end line caps of open shapes (lines and polylines). * * @default null */ fillColor: null | Color; /** * The {@link NutrientViewer.MeasurementPrecision} used to set the precision for the annotation. * * @default NutrientViewer.MeasurementPrecision.TWO */ measurementPrecision: null | IMeasurementPrecision; /** * The {@link NutrientViewer.MeasurementScale} used to set the scale for the annotation. */ measurementScale: null | MeasurementScale; static readableName: string; static defaultValues: IObject; /** * A method that tels whether the annotation is a measurement annotation. */ isMeasurement(): boolean; /** * A method the returns the measurement value and label of the annotation. * * @example * const { value, label } = annotation.getMeasurementDetails(); * * console.log(value, label); */ getMeasurementDetails: () => { value: number; label: string; }; } declare abstract class ShapeAnnotationSerializer extends AnnotationSerializer { annotation: ShapeAnnotationsUnion; toJSON(): Serializers.ShapeAnnotationJSON; static fromJSON(id: ID | null, json: Omit, options?: ICollaboratorPermissionsOptions): { strokeWidth: number | null; strokeColor: Color | null; fillColor: Color | null; strokeDashArray: [number, number] | null | undefined; measurementPrecision: IMeasurementPrecision | null | undefined; measurementScale: MeasurementScale | null; group?: string | null | undefined; canSetGroup?: boolean; isEditable?: boolean; isDeletable?: boolean; blendMode?: IBlendMode | undefined; id: string | null; name: string | null; subject: string | null; pdfObjectId: number | null; pageIndex: number; opacity: number; boundingBox: Rect; noPrint: boolean; noZoom: boolean; noRotate: boolean; noView: boolean; hidden: boolean; locked: boolean; lockedContents: boolean; readOnly: boolean; action: Action | null | undefined; note: string | null; createdAt: Date; updatedAt: Date; creatorName: string | null; customData: Record | null; isCommentThreadRoot: boolean; isAnonymous: boolean; }; _pointsToJSON(): Array<[number, number]>; static _JSONToPoints(pointsJSON: Array<[number, number]>): List; static _JSONLinesToPoints(linesJSON: { points: Array>; intensities: Array>; }): List; } export declare type ShapeAnnotationsUnion = PolylineAnnotation | PolygonAnnotation | LineAnnotation | RectangleAnnotation | EllipseAnnotation; /** @inline */ declare interface Shared extends Omit { /** * Callback to invoke when the item is clicked or tapped (on touch devices). It gets the `event` as * first argument, the `id` of the tool item as the second for `custom` items. * * @param event - The event that is fired on press. `onPress` is also fired when pressing enter. * @param id - The toolbar item id. */ onPress?: (event: MouseEvent | KeyboardEvent, id?: string | undefined) => void; iconClassName?: string; onIconPress?: (event: MouseEvent, id?: string) => void; } /** * This describes the properties of a {@link NutrientViewer.load} configuration. */ declare interface SharedConfiguration { /** * Selector or element where Nutrient Web SDK will be mounted. * * Required unless `headless: true` is set. * * The element must have a `width` and `height` that's greater than zero. Nutrient Web SDK adapts to the dimensions * of this element. This way, applying responsive rules will work as expected. * * The element can be styled using relative values as you would expect it to (CSS media queries * are encouraged). * * @example * // In your HTML *
* * // In your JavaScript * NutrientViewer.load({ * container: '.foo', * // Other configuration options * }); * // or * const element = document.getElementsByClassName('foo')[0] * NutrientViewer.load({ * container: element, * // Other configuration options * }); */ container?: string | HTMLElement; /** * This property allows you to set an initial viewing state for the NutrientViewer instance. * * This can be used to customize behavior before the application mounts (e.g Scroll to a specific * page or use the SINGLE_PAGE mode) * * It will default to a view state with its default properties (see {@link ViewState}). * * If the initial view state is invalid (for example, when you define a page index that does not * exist), the method will fall back to the default value for the invalid property. This means when * you set the initial `currentPageIndex` to 5 but the document only has three pages, NutrientViewer will * start on the first page but will still apply other rules defined in this initial view state. * * @example * const initialViewState = new NutrientViewer.ViewState({ currentPageIndex: 2 }); * NutrientViewer.load({ * initialViewState, * // Other configuration options * }); * * @default {@link ViewState} */ initialViewState?: ViewState; /** * This allows you to overwrite the auto-detected URL for all NutrientViewer assets. This setting is * necessary when you load Nutrient Web SDK JavaScript from a different URL. * * If your assets are served from a different origin, you have to include proper CORS headers: * {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS} * * @example * NutrientViewer.load({ baseUrl: 'https://public-server.pspdfkit.com/' }); * * @default Auto-detected based on the currently executed `<script>` tag. * * Note: auto-detection behavior is deprecated as of 1.9.0. Not providing baseUrl will currently * trigger a warning and in future releases will lead to loading assets from CDN. */ baseUrl?: string; /** * This property is a temporary flag to explicitly enable loading assets from the CDN when * `baseUrl` is not provided. This flag will be removed in future releases once loading * from CDN is the default behavior when `baseUrl` is not set. * * Has no effect when `baseUrl` is provided. * * @default false */ useCDN?: boolean; /** * This allows you to overwrite the auto-detected Nutrient Document Engine URL. This setting is necessary * when your Nutrient Document Engine is located under a different URL. * * @example * NutrientViewer.load({ serverUrl: 'https://public-server.pspdfkit.com/' }) * * @default Auto-detected based on the currently executed `<script>` tag. */ serverUrl?: string; /** * This property allows you to change the size of the tiles used to render the document, in pixels. The bigger the tile, the fewer requests is made, but each tile will take longer to render. * * This is useful for situations where you want to reduce the number of requests made to the server. * * By default, the tile size is set to 512px in Nutrient Document Engine (server-backed) deployment, and 1536px in Standalone deployment. * * @example * NutrientViewer.load({ * tileSize: 1024 * }) * * @default 512 in Nutrient Document Engine (server-backed), 1536 in Standalone */ tileSize?: number; /** * This will load your custom CSS as a `` inside the NutrientViewer component. This * is necessary to isolate styling of the viewer from the outside application and avoid external * stylesheets overwriting important viewer attributes. * * An array is allowed to load multiple stylesheets. The order in the array will also be the * order in which the stylesheets get loaded. * * The array will be copied by us on start up time, which means that you can not mutate it * after the viewer has started. * * More information on how to style Nutrient Web SDK can be found in our guides. * * @example * NutrientViewer.load({ * styleSheets: [ * 'https://example.com/my-stylesheet.css', * 'https://example.com/other-stylesheet.css' * ] * }) * * @default [] */ styleSheets?: Array; /** * This property allows you to set an initial list of toolbar items for the NutrientViewer instance. * This can be used to customize the main toolbar before the application mounts. * * When omitted, it will default to {@link NutrientViewer.defaultToolbarItems}. * * @example * const toolbarItems = NutrientViewer.defaultToolbarItems; * toolbarItems.reverse(); * NutrientViewer.load({ * toolbarItems, * // Other configuration options * }); * * @default Default {@link NutrientViewer.defaultToolbarItems} */ toolbarItems?: Array; /** * This property allows you to change a default list of annotation presets for the NutrientViewer instance. * This can be used to customize the main toolbar buttons' behaviour before the application mounts. * * When omitted, it will default to {@link NutrientViewer.defaultAnnotationPresets}. * * @example * const annotationPresets = NutrientViewer.defaultAnnotationPresets * annotationPresets.mypreset = { * strokeWidth: 10, * }; * NutrientViewer.load({ * ...baseOptions, * annotationPresets, * }); * * @default Default {@link NutrientViewer.defaultAnnotationPresets} */ annotationPresets?: Record; /** * This property allows you to set an initial list of stamp and image annotation templates for the NutrientViewer instance. * This can be used to customize the list of available stamp and image annotation templates that will be available in the stamps picker UI before the application mounts. * * When omitted, it will default to {@link NutrientViewer.defaultStampAnnotationTemplates}. * * @example * const stampAnnotationTemplates = NutrientViewer.defaultStampAnnotationTemplates * stampAnnotationTemplates.push(new NutrientViewer.Annotations.StampAnnotation({ * stampType: "Custom", * title: "My custom text", * boundingBox: new NutrientViewer.Geometry.Rect({ * left: 0, * top: 0, * width: 300, * height: 100 * }) * })); * NutrientViewer.load({ * stampAnnotationTemplates, * // Other configuration options * }); * * @default Default {@link NutrientViewer.defaultStampAnnotationTemplates} */ stampAnnotationTemplates?: Array; /** * This property allows you to set the auto save mode, which controls when annotations or form field * values get saved. * * When using `instant: true`, the default auto save mode is IMMEDIATE, otherwise it's * INTELLIGENT. * * @example * NutrientViewer.load({ autoSaveMode: NutrientViewer.AutoSaveMode.INTELLIGENT }) */ autoSaveMode?: IAutoSaveMode; /** * This property allows you to disable high quality printing, which will print the document in a higher * resolution (300dpi) than the default (150dpi). When not explicitly set, high quality printing is disabled * for iOS and Android devices on standalone deployments to improve performances. * * @example * NutrientViewer.load({ disableHighQualityPrinting: true }) * * @default false */ disableHighQualityPrinting?: boolean; /** * This property allows you to set the {@link NutrientViewer.PrintMode} to use. * * @example * NutrientViewer.load({ printMode: NutrientViewer.PrintMode.DOM }) * * @default NutrientViewer.PrintMode.DOM * @deprecated */ printMode?: IPrintMode; /** * Allows to set different printing options like mode and printing quality. * * @default { mode: NutrientViewer.PrintMode.DOM, quality: NutrientViewer.PrintQuality.LOW } */ printOptions?: { /** {@link NutrientViewer.PrintMode} mode to use for printing. */ mode?: IPrintMode; /** {@link NutrientViewer.PrintQuality} The option to control the quality of the printing. */ quality?: IPrintQuality; }; /** * When this property is set to true, text in the document can not be highlighted. * * @example * NutrientViewer.load({ disableTextSelection: true }) */ disableTextSelection?: boolean; /** * This property is used to force the disabling of form rendering and parsing, even if your license * would permit it. * * @example * NutrientViewer.load({ disableForms: true }) * * @default false */ disableForms?: boolean; /** * Loads Nutrient Web SDK in Headless mode i.e. without a UI. * Some UI-specific APIs, like the Toolbars API, are not available in this mode * and, when used, will throw an error. * * @example * NutrientViewer.load({ * headless: true, * // ... * }); */ headless?: boolean; /** * The initial `locale` (language) for the application. * All the available locales are defined in {@link NutrientViewer.I18n.locales}. * When a locale is not provided Nutrient Web SDK tries to autodetect the locale using `window.navigator.language`. * If the detected locale is not supported then the `en` locale is used instead. * * @example * NutrientViewer.load({ * locale: 'de', * // ... * }); */ locale?: string; /** * Loads Ink Signatures when the UI displays them for the first time. * * Ink Signatures are special Ink Annotations whose `pageIndex` and `boundingBox` are defined at creation time. * They can be converted to serializable objects with {@link NutrientViewer.Annotations.toSerializableObject} and stored as JSON using their InstantJSON format. * Serialized JSON annotations can be deserialized with `JSON.parse` and then converted to annotations with {@link NutrientViewer.Annotations.fromSerializableObject}. * * @example * Populate Ink Signatures on demand. * ```ts * NutrientViewer.load({ * populateInkSignatures: () => { * return fetch('/signatures') * .then(r => r.json()) * .then(a => ( * NutrientViewer.Immutable.List( * a.map(NutrientViewer.Annotations.fromSerializableObject)) * ) * ); * }, * // ... * }); * ``` * * @default () => Promise.resolve(NutrientViewer.Immutable.List()) * @returns A Promise that resolves to a {@link NutrientViewer.Immutable.List} of {@link NutrientViewer.Annotations.InkAnnotation InkAnnotation} that describe signatures. * @deprecated */ populateInkSignatures?: () => Promise>; /** * Loads signatures when the UI displays them for the first time. * * Signatures can be added as special Ink Annotations or Image Annotations whose `pageIndex` and `boundingBox` are defined at creation time. * They can be converted to serializable objects with {@link NutrientViewer.Annotations.toSerializableObject} and stored as JSON using their InstantJSON format. * Serialized JSON annotations can be deserialized with `JSON.parse` and then converted to annotations with {@link NutrientViewer.Annotations.fromSerializableObject}. * * @example * Populate Signatures on demand. * ```ts * NutrientViewer.load({ * populateStoredSignatures: () => { * return fetch('/signatures') * .then(r => r.json()) * .then(a => ( * NutrientViewer.Immutable.List( * a.map(NutrientViewer.Annotations.fromSerializableObject)) * ) * ); * }, * // ... * }); * ``` * * @default () => Promise.resolve(NutrientViewer.Immutable.List()) * @returns {Promise.>} A Promise that resolves to a {@link NutrientViewer.Immutable.List} of {@link NutrientViewer.Annotations.InkAnnotation InkAnnotation} or {@link NutrientViewer.Annotations.ImageAnnotation ImageAnnotation} that describe signatures. */ populateStoredSignatures?: () => Promise>; /** * List of signature form fields names that are not allowed to store Ink Signatures. * * When a signature form field name is on this list, any new ink signature for this field that is created via the UI won't be stored. * * @example * NutrientViewer.load({ * formFieldsNotSavingSignatures: ['signatureField1'], * // ... * }); * * @default [] */ formFieldsNotSavingSignatures?: Array; /** * If set, it will try to unlock the PDF with the provided password when loading it. PDFs which do * not require a password won't open if this property is set. * * @example * NutrientViewer.load({ * password: 'secr3t', * // ... * }); */ password?: string; /** * By default, Nutrient Web SDK will initialize using [PDF Open Parameters](https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDFOpenParameters.pdf) * that are supported by our viewer. This option can be used if you want to opt-out from this * behavior. * * Setting a custom {@link ViewState} will overwrite these defaults. You can use * {@link NutrientViewer.viewStateFromOpenParameters} to manually extract those values. * * Currently, we only support the `page` parameter. * * @example * NutrientViewer.load({ * disableOpenParameters: true, * }); */ disableOpenParameters?: boolean; /** * Defines how often the password modal is presented after a wrong password has been entered. By * default, there won't be a limit for a regular Nutrient Web SDK installation. * * When running in the headless mode, this option is ignored as we don't have an interface where * we could request a password (This is the same as setting `maxPasswordRetries` to `0`). * * @example * NutrientViewer.load({ * maxPasswordRetries: 3, * // ... * }); */ maxPasswordRetries?: number; /** * When you're using a ServiceWorker, set this flag to `true` to be able to use Nutrient Web SDK * offline. Due to a browser bug, loading CSS files would bypass service workers and we therefore * load all CSS files via XHR and embed the content. Instead of loading files like SVGs by using * `url` in your CSS, please add them as base64, otherwise these requests would bypass the service * worker as well. * * @example * NutrientViewer.load({ * enableServiceWorkerSupport: true, * // ... * }); */ enableServiceWorkerSupport?: boolean; /** * A CSP nonce to apply to dynamically created `