Table of Contents

Class PdfFormEventsNotifier

Namespace
nebulae.dotPDFium.Forms
Assembly
dotPDFium.dll

Dispatches user-driven events to the PDFium form environment. These methods mirror PDFium's FORM_* notification APIs (see fpdf_formfill.h).

public static class PdfFormEventsNotifier
Inheritance
PdfFormEventsNotifier
Inherited Members

Methods

CanRedo(PdfForm, PdfPage)

Determines whether the specified PDF form can redo the last undone action on the given page.

public static bool CanRedo(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PDF form to check for redo capability.

page PdfPage

The page within the PDF form to check for redo capability.

Returns

bool

true if the last undone action on the specified page can be redone; otherwise, false.

CanUndo(PdfForm, PdfPage)

Determines whether the specified form and page have an undoable action available.

public static bool CanUndo(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PDF form to check for undoable actions. Cannot be null.

page PdfPage

The PDF page associated with the form. Cannot be null.

Returns

bool

true if there is an undoable action available for the specified form and page; otherwise, false.

DoDocumentAAction(PdfForm, PdfPageAActionType)

Executes a document-level action on the specified PDF form.

public static void DoDocumentAAction(PdfForm form, PdfPageAActionType action)

Parameters

form PdfForm

The PdfForm instance representing the PDF form on which the action will be performed. Cannot be null.

action PdfPageAActionType

The document-level action to execute, specified as a PdfPageAActionType value.

Remarks

Document-level actions are predefined actions in a PDF document that are triggered by specific events, such as opening or closing the document. Use this method to programmatically invoke such actions on a PDF form.

DoDocumentJSAction(PdfForm)

Executes the JavaScript action associated with the document in the specified PDF form.

public static void DoDocumentJSAction(PdfForm form)

Parameters

form PdfForm

The PdfForm object representing the PDF form on which the JavaScript action will be executed. Cannot be null.

Remarks

This method triggers the document-level JavaScript action defined in the PDF form. Ensure that the PdfForm instance is properly initialized before calling this method.

DoDocumentOpenAction(PdfForm)

Executes the document's open action, if defined, for the specified PDF form.

public static void DoDocumentOpenAction(PdfForm form)

Parameters

form PdfForm

The PdfForm representing the PDF document. This parameter cannot be null.

Remarks

This method triggers any actions associated with the document's open event, such as scripts or other predefined behaviors. Ensure that the form is properly initialized before calling this method.

DoPageAAction(PdfForm, PdfPage, PdfPageAActionType)

Executes a specific page-level additional action on a PDF page within a form.

public static void DoPageAAction(PdfForm form, PdfPage page, PdfPageAActionType action)

Parameters

form PdfForm

The PdfForm instance representing the form containing the page.

page PdfPage

The PdfPage instance representing the page on which the action will be performed.

action PdfPageAActionType

The type of additional action to execute, specified as a PdfPageAActionType value.

Remarks

This method triggers a predefined additional action associated with the specified page in the context of the provided form. The action type is determined by the action parameter, which must be a valid member of the PdfPageAActionType enumeration.

ForceKillFocus(PdfForm)

Forces the specified PDF form to lose focus.

public static void ForceKillFocus(PdfForm form)

Parameters

form PdfForm

The PdfForm instance whose focus will be forcibly removed. Cannot be null.

Remarks

This method is typically used to ensure that no form field within the specified PDF form retains focus. It may be useful in scenarios where focus-related behavior needs to be reset or overridden.

GetFocusedAnnot(PdfForm, out int, out PdfAnnotation?)

Retrieves the currently focused annotation within the specified PDF form, if any.

public static bool GetFocusedAnnot(PdfForm form, out int pageIndex, out PdfAnnotation? annotation)

Parameters

form PdfForm

The PdfForm instance representing the form to query.

pageIndex int

When this method returns, contains the zero-based index of the page containing the focused annotation, or -1 if no annotation is focused.

annotation PdfAnnotation

When this method returns, contains the PdfAnnotation object representing the focused annotation, or null if no annotation is focused.

Returns

bool

true if a focused annotation is found; otherwise, false.

Remarks

This method queries the PDF form to determine if an annotation currently has focus. If an annotation is focused, its associated page index and annotation object are returned. If no annotation is focused, pageIndex is set to -1 and annotation is set to null.

GetFocusedText(PdfForm, PdfPage)

Retrieves the text from the currently focused field in a PDF form on the specified page.

public static string? GetFocusedText(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PdfForm instance representing the PDF form.

page PdfPage

The PdfPage instance representing the page containing the focused field.

Returns

string

A string containing the text of the focused field, or null if no field is focused or the field is empty.

Remarks

The returned text is encoded in UTF-8. If the focused field is empty, this method returns null.

GetSelectedText(PdfForm, PdfPage)

Retrieves the text currently selected within the specified PDF form and page.

public static string? GetSelectedText(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PdfForm instance representing the form containing the selection.

page PdfPage

The PdfPage instance representing the page containing the selection.

Returns

string

A string containing the selected text, or null if no text is selected.

Remarks

The returned string is encoded in UTF-8. If no text is selected, the method returns null.

IsIndexSelected(PdfForm, PdfPage, int)

Determines whether the specified index is selected in the given PDF form on the specified page.

public static bool IsIndexSelected(PdfForm form, PdfPage page, int index)

Parameters

form PdfForm

The PDF form containing the selection state.

page PdfPage

The page of the PDF form to check.

index int

The index to check for selection.

Returns

bool

true if the specified index is selected; otherwise, false.

Remarks

This method checks the selection state of an index within a PDF form field on a specific page. Ensure that the form and page are valid and properly initialized.

OnAfterLoadPage(PdfForm, PdfPage)

Performs post-processing actions on a PDF page after it has been loaded into a form.

public static void OnAfterLoadPage(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PdfForm instance associated with the PDF document.

page PdfPage

The PdfPage instance representing the loaded page.

Remarks

This method should be called after a page is loaded to ensure that any necessary form-related adjustments or initializations are applied to the page. It is typically used in workflows involving interactive forms or annotations.

OnBeforeClosePage(PdfForm, PdfPage)

Performs necessary operations before a PDF page is closed.

public static void OnBeforeClosePage(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PdfForm associated with the PDF document. Cannot be null.

page PdfPage

The PdfPage that is about to be closed. Cannot be null.

Remarks

This method ensures that any required cleanup or finalization tasks are performed for the specified page before it is closed. Both form and page must be valid and initialized.

OnChar(PdfForm, PdfPage, int, int)

Handles a character input event for a PDF form on a specific page.

public static void OnChar(PdfForm form, PdfPage page, int charCode, int modifier)

Parameters

form PdfForm

The PdfForm instance representing the form to which the character input is applied.

page PdfPage

The PdfPage instance representing the page containing the form.

charCode int

The Unicode character code of the input character.

modifier int

An integer representing any modifier keys (e.g., Shift, Ctrl) that were active during the input event.

Remarks

This method processes character input events, such as typing into a form field, and applies the input to the specified form and page. Ensure that both form and page are valid and properly initialized before calling this method.

OnFocus(PdfForm, PdfPage, int, double, double)

Handles the focus event for a PDF form field.

public static void OnFocus(PdfForm form, PdfPage page, int modifier, double x, double y)

Parameters

form PdfForm

The PdfForm instance representing the form containing the field.

page PdfPage

The PdfPage instance representing the page where the form field is located.

modifier int

An integer representing the modifier keys pressed during the focus event. This value is typically a bitmask of key states (e.g., Shift, Ctrl, Alt).

x double

The x-coordinate, in points, of the focus event relative to the page.

y double

The y-coordinate, in points, of the focus event relative to the page.

OnKeyDown(PdfForm, PdfPage, int, int)

Handles a key-down event for a PDF form on a specified page.

public static void OnKeyDown(PdfForm form, PdfPage page, int keyCode, int modifier)

Parameters

form PdfForm

The PdfForm instance representing the form to process the key event for.

page PdfPage

The PdfPage instance representing the page containing the form.

keyCode int

The key code of the key that was pressed.

modifier int

The modifier key state (e.g., Shift, Ctrl, Alt) at the time of the key press.

OnKeyUp(PdfForm, PdfPage, int, int)

Handles the key-up event for a PDF form on a specified page.

public static void OnKeyUp(PdfForm form, PdfPage page, int keyCode, int modifier)

Parameters

form PdfForm

The PdfForm instance representing the form where the event occurred.

page PdfPage

The PdfPage instance representing the page containing the form.

keyCode int

The code of the key that was released.

modifier int

The modifier key state at the time of the key release, such as Shift, Ctrl, or Alt.

OnLButtonDoubleClick(PdfForm, PdfPage, int, double, double)

Handles a left mouse button double-click event on a PDF form.

public static void OnLButtonDoubleClick(PdfForm form, PdfPage page, int modifier, double x, double y)

Parameters

form PdfForm

The PdfForm instance representing the form where the event occurred.

page PdfPage

The PdfPage instance representing the page containing the form.

modifier int

An integer representing the state of modifier keys (e.g., Shift, Ctrl, Alt) during the event.

x double

The x-coordinate, in page space, where the double-click occurred.

y double

The y-coordinate, in page space, where the double-click occurred.

OnLButtonDown(PdfForm, PdfPage, int, double, double)

Handles a left mouse button down event on a PDF form at the specified location.

public static void OnLButtonDown(PdfForm form, PdfPage page, int modifier, double x, double y)

Parameters

form PdfForm

The PdfForm instance representing the form being interacted with.

page PdfPage

The PdfPage instance representing the page containing the form.

modifier int

An integer representing any modifier keys pressed during the event (e.g., Shift, Ctrl).

x double

The x-coordinate of the mouse pointer, in the page's coordinate system.

y double

The y-coordinate of the mouse pointer, in the page's coordinate system.

OnLButtonUp(PdfForm, PdfPage, int, double, double)

Handles the left mouse button release event for a PDF form on a specified page.

public static void OnLButtonUp(PdfForm form, PdfPage page, int modifier, double x, double y)

Parameters

form PdfForm

The PdfForm instance representing the form to interact with.

page PdfPage

The PdfPage instance representing the page where the event occurred.

modifier int

An integer representing the state of modifier keys (e.g., Shift, Ctrl) at the time of the event.

x double

The x-coordinate of the mouse pointer, in page coordinates, at the time of the event.

y double

The y-coordinate of the mouse pointer, in page coordinates, at the time of the event.

OnMouseMove(PdfForm, PdfPage, int, double, double)

Handles the mouse move event for a PDF form on a specific page.

public static void OnMouseMove(PdfForm form, PdfPage page, int modifier, double x, double y)

Parameters

form PdfForm

The PdfForm instance representing the form to interact with.

page PdfPage

The PdfPage instance representing the page where the mouse event occurred.

modifier int

An integer representing the state of modifier keys (e.g., Shift, Ctrl, Alt) during the mouse event.

x double

The x-coordinate of the mouse pointer, in page coordinates.

y double

The y-coordinate of the mouse pointer, in page coordinates.

OnMouseWheel(PdfForm, PdfPage, int, FsPointF, int, int)

Handles mouse wheel events for a PDF form on a specific page.

public static void OnMouseWheel(PdfForm form, PdfPage page, int modifier, FsPointF coord, int deltaX, int deltaY)

Parameters

form PdfForm

The PdfForm instance associated with the PDF document.

page PdfPage

The PdfPage instance representing the page where the event occurred.

modifier int

An integer representing the state of modifier keys (e.g., Ctrl, Alt, Shift) during the event.

coord FsPointF

The coordinates, in points, where the mouse wheel event occurred.

deltaX int

The horizontal scroll delta, in points, caused by the mouse wheel.

deltaY int

The vertical scroll delta, in points, caused by the mouse wheel.

OnRButtonDown(PdfForm, PdfPage, int, double, double)

Handles a right mouse button down event on a PDF form at the specified location.

public static void OnRButtonDown(PdfForm form, PdfPage page, int modifier, double x, double y)

Parameters

form PdfForm

The PdfForm instance representing the form being interacted with.

page PdfPage

The PdfPage instance representing the page where the event occurred.

modifier int

An integer representing the state of modifier keys (e.g., Ctrl, Alt, Shift) during the event.

x double

The x-coordinate, in page space, where the event occurred.

y double

The y-coordinate, in page space, where the event occurred.

OnRButtonUp(PdfForm, PdfPage, int, double, double)

Handles the right mouse button release event for a PDF form on a specified page.

public static void OnRButtonUp(PdfForm form, PdfPage page, int modifier, double x, double y)

Parameters

form PdfForm

The PdfForm instance representing the form being interacted with.

page PdfPage

The PdfPage instance representing the page where the event occurred.

modifier int

An integer representing the state of modifier keys (e.g., Ctrl, Alt, Shift) at the time of the event.

x double

The x-coordinate, in page space, where the right mouse button was released.

y double

The y-coordinate, in page space, where the right mouse button was released.

Redo(PdfForm, PdfPage)

Reapplies the most recently undone action on the specified PDF form and page.

public static bool Redo(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PdfForm instance representing the form to which the redo operation applies.

page PdfPage

The PdfPage instance representing the page on which the redo operation is performed.

Returns

bool

true if the redo operation is successful; otherwise, false.

ReplaceAndKeepSelection(PdfForm, PdfPage, string)

Replaces the current text in the specified PDF form field while preserving the user's selection.

public static void ReplaceAndKeepSelection(PdfForm form, PdfPage page, string text)

Parameters

form PdfForm

The PdfForm object representing the form containing the field to update. Cannot be null.

page PdfPage

The PdfPage object representing the page containing the form field. Cannot be null.

text string

The new text to replace the current content of the form field. Cannot be null or empty.

Remarks

This method ensures that the user's current selection within the form field is preserved after the text is replaced.

ReplaceSelection(PdfForm, PdfPage, string)

Replaces the current text selection on the specified PDF page with the provided text.

public static void ReplaceSelection(PdfForm form, PdfPage page, string text)

Parameters

form PdfForm

The PdfForm object representing the form associated with the PDF document. Cannot be null.

page PdfPage

The PdfPage object representing the page where the text selection will be replaced. Cannot be null.

text string

The text to replace the current selection with. If null or empty, the selection will be cleared.

Remarks

This method modifies the content of the specified PDF page by replacing the currently selected text with the provided string. Ensure that the form and page objects are valid and properly initialized before calling this method.

SelectAllText(PdfForm, PdfPage)

Selects all text within the specified PDF form and page.

public static bool SelectAllText(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PdfForm object representing the form containing the text to select. Cannot be null.

page PdfPage

The PdfPage object representing the page within the form. Cannot be null.

Returns

bool

true if the text was successfully selected; otherwise, false.

Remarks

This method is typically used to programmatically select all text on a specific page of a PDF form. The selection state may depend on the underlying PDF library's implementation.

SetFocusedAnnot(PdfForm, PdfAnnotation)

Sets the specified annotation as the focused annotation within the given PDF form.

public static bool SetFocusedAnnot(PdfForm form, PdfAnnotation annotation)

Parameters

form PdfForm

The PDF form containing the annotation to be focused. Cannot be null.

annotation PdfAnnotation

The annotation to set as focused. Cannot be null.

Returns

bool

true if the annotation was successfully set as focused; otherwise, false.

SetIndexSelected(PdfForm, PdfPage, int, bool)

Sets the selection state of a specific index within a form on a given PDF page.

public static bool SetIndexSelected(PdfForm form, PdfPage page, int index, bool selected)

Parameters

form PdfForm

The PdfForm instance representing the form to modify.

page PdfPage

The PdfPage instance representing the page containing the form.

index int

The zero-based index of the item to update within the form.

selected bool

true to mark the item at the specified index as selected; otherwise, false to deselect it.

Returns

bool

true if the selection state was successfully updated; otherwise, false.

Remarks

This method modifies the selection state of an item within a form field on a specific PDF page. Ensure that the provided form and page are valid and correspond to the same document.

Undo(PdfForm, PdfPage)

Reverts the most recent change made to the specified PDF form on the given page.

public static bool Undo(PdfForm form, PdfPage page)

Parameters

form PdfForm

The PDF form to undo the last change for. Cannot be null.

page PdfPage

The page of the PDF form where the undo operation is performed. Cannot be null.

Returns

bool

true if the undo operation was successful; otherwise, false.