ceTe Software Help Library for Java August - 2020
DynamicPDF Generator for Java / Programming with Generator for Java / Advanced Topics / Events
In This Topic
    Events
    In This Topic

    The following events can be used to trigger any valid Actions.

    Page Reader Events

    The following events can be triggered for each page in a PDF.

    • Open - This event will be fired when opening a specific page.
    • Close - This event will be fired when closing a specific page.

    The example below demonstrates how to trigger a JavaScript alert window when a specific page is opened.

    [Java]
    Page page = new Page();
    JavaScriptAction action = new JavaScriptAction("app.alert(\"Welcome !!\")");
    page.getReaderEvents().setOpen(action);
    

    Document Reader Events

    The following events can be triggered at the document level.

    • WillSave - This event will be fired when saving a document.
    • DidSave - This event will be fired after saving a document.
    • WillClose - This event will be fired while closing a document.
    • WillPrint - This event will be fired when printing a document.
    • DidPrint - This event will be fired after printing a document.

    The example below demonstrates how to trigger a JavaScript alert window when saving a PDF.

    [Java]
    Document document = new Document();
    JavaScriptAction action = new JavaScriptAction("app.alert(\"Hello your text Saved!!\")");
    document.ReaderEvents.WillSave = action;
    

    Form Field Reader Events

    The following events can be triggered for each form field.

    • MouseUp- This event is fired when the mouse button is released after a click.
    • MouseDown - This event is fired when the mouse button is clicked and not released.
    • MouseEnter - This event is fired when the mouse pointer enters the field.
    • MouseExit - This event is fired when the pointer exits the form field.
    • OnBlur - This event is fired when the form field loses focus.
    • OnFocus - This event is fired when the form field receives focus, either through a mouse action or by tabbing.

    The example below demonstrates how to trigger a JavaScript alert window when a text field receives focus.

    [Java]
    TextField textField = new TextField("Text1", 0, 0, 100, 15); 
    JavaScriptAction action = new JavaScriptAction("app.alert(\"Welcome !!\")");
    textField.getReaderEvents().setOnFocus(action);