interface AppType {
    close: (options?: CloseOptions) => Promise<boolean>;
    createBlankDoc: (width: number, height: number) => Promise<null | DocType>;
    getActiveDoc: () => Promise<null | DocType>;
    getActiveTool: () => Promise<null | ToolType>;
    getAppDataPath: () => Promise<string>;
    getAppTitle: () => Promise<string>;
    getDoc: (index: number) => Promise<null | DocType>;
    getDocsCount: () => Promise<number>;
    getName: () => Promise<string>;
    getRibbonBar: (parentWnd: LPVOIDType) => Promise<null | RibbonBarType>;
    getToolByName: (toolName: string) => Promise<null | ToolType>;
    getVersion: () => Promise<string>;
    isTaskPanelShow: () => Promise<boolean>;
    loadGraphicObjectAddon: () => Promise<boolean>;
    openFileFromUrl: (
        __namedParameters: {
            fileTransferCallbacks: FileTransferCallbacksType;
            headers?: Options;
            password?: string;
            url: string;
        },
    ) => Promise<void>;
    openFromFile: (options: OpenFromFileOptions) => Promise<null | DocType>;
    options: AppOptions;
    pluginInfo: PluginInfoType;
    registerDocHandlerOfPDDoc: (
        docEventCallbacks: DocEventCallbacksType,
    ) => Promise<boolean>;
    registerForContextMenuAddition: (
        name: string,
        menus: MenusType,
    ) => Promise<boolean>;
    registerPageObjectSelectionHandler: (
        callbacks: PageObjectSelectionCallbacksType,
    ) => Promise<null | LPVOIDType>;
    registerRectangleHandler: (
        callbacks: ToolJsCallbacksType,
    ) => Promise<null | LPVOIDType>;
    registerSelectionHandler: (
        callbacks: SelectionJsCallbacksType,
    ) => Promise<null | LPVOIDType>;
    selectOpenFile: (filter: string, multi: boolean) => Promise<string[]>;
    setActiveDoc: (doc: DocType) => Promise<boolean>;
    setActiveDocByIndex: (index: number) => Promise<boolean>;
    setActiveTool: (tool: ToolType, persistent: boolean) => Promise<boolean>;
    showTaskPanel: (show: boolean) => Promise<void>;
    unRegisterPageObjectSelectionHandler: (
        selectionHandler: LPVOIDType,
    ) => Promise<boolean>;
    unRegisterRectangleHandler: (toolHandler: LPVOIDType) => Promise<boolean>;
    unRegisterSelectionHandler: (
        selectionHandler: LPVOIDType,
    ) => Promise<boolean>;
}

Implemented by

Properties

close: (options?: CloseOptions) => Promise<boolean>

Close the current active document.

Type declaration

    • (options?: CloseOptions): Promise<boolean>
    • Parameters

      • Optionaloptions: CloseOptions

        Close options, the defalut value is {promptToSave: true, showCancel: true}

      Returns Promise<boolean>

      If close the document successfully, return true, otherwise return false.

createBlankDoc: (width: number, height: number) => Promise<null | DocType>

Creates a blank document.

Type declaration

    • (width: number, height: number): Promise<null | DocType>
    • Parameters

      • width: number

        The width of the page in the blank document.

      • height: number

        The height of the page in the blank document.

      Returns Promise<null | DocType>

      The blank document.

getActiveDoc: () => Promise<null | DocType>

Gets the top-most document which for displaying PDF file type.

Type declaration

    • (): Promise<null | DocType>
    • Returns Promise<null | DocType>

      Returns the document that is currently active.

getActiveTool: () => Promise<null | ToolType>

Get the active tool.

Type declaration

    • (): Promise<null | ToolType>
    • Returns Promise<null | ToolType>

      Returns the active tool instance.

getAppDataPath: () => Promise<string>

Get the path of the current application.

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

      The path of the current application.

getAppTitle: () => Promise<string>

Get the title of the current application.

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

      The title of the current application.

getDoc: (index: number) => Promise<null | DocType>

Gets the document by specified index.

Type declaration

    • (index: number): Promise<null | DocType>
    • Parameters

      • index: number

        The index of the document. This value can be iterated through from getDocsCount.

      Returns Promise<null | DocType>

      Get the document by specified index.

getDocsCount: () => Promise<number>

The number of documents currently open.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

      Returns the currently open document number.

getName: () => Promise<string>

Get the name of the current application.

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

      Get the name of the application. It will be "Foxit PhantomPDF" or "Foxit Reader".

getRibbonBar: (parentWnd: LPVOIDType) => Promise<null | RibbonBarType>

Get the ribbon bar of the application.

Type declaration

getToolByName: (toolName: string) => Promise<null | ToolType>

Get a tool by name.

Type declaration

    • (toolName: string): Promise<null | ToolType>
    • Parameters

      • toolName: string

        The name of the tool.

      Returns Promise<null | ToolType>

      Returns the tool instance.

getVersion: () => Promise<string>

Get the version of the current application.

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

      Get the version of the application.

isTaskPanelShow: () => Promise<boolean>

Get the task pane show status.

Type declaration

    • (): Promise<boolean>
    • Returns Promise<boolean>

loadGraphicObjectAddon: () => Promise<boolean>

Load the graphic object addon.

Type declaration

    • (): Promise<boolean>
    • Returns Promise<boolean>

openFileFromUrl: (
    __namedParameters: {
        fileTransferCallbacks: FileTransferCallbacksType;
        headers?: Options;
        password?: string;
        url: string;
    },
) => Promise<void>

Open a PDF document from a URL.

Type declaration

    • (
          __namedParameters: {
              fileTransferCallbacks: FileTransferCallbacksType;
              headers?: Options;
              password?: string;
              url: string;
          },
      ): Promise<void>
    • Parameters

      • __namedParameters: {
            fileTransferCallbacks: FileTransferCallbacksType;
            headers?: Options;
            password?: string;
            url: string;
        }

      Returns Promise<void>

await app.openFileFromUrl({
url: 'https://www.example.com/test.pdf',
password: '123456',
headers: {
'Authorization': 'Bearer 1234567890',
'cookie': 'name=value; name2=value2'
},
fileTransferCallbacks: {
onProgress: (clientData, progress) => {
console.log(`onProgress: ${progress}`);
},
onResult: (clientData, result, message) => {
console.log(`onResult: ${result}, ${message}`);
}
}
});
openFromFile: (options: OpenFromFileOptions) => Promise<null | DocType>

Open a PDF document by OpenFromFileOptions.

Type declaration

await app.openFromFile({
'fileSrc': './InsertText.pdf',
'password': '',
'makeVisible': true,
'addToMRU': true,
})
options: AppOptions
pluginInfo: PluginInfoType
registerDocHandlerOfPDDoc: (
    docEventCallbacks: DocEventCallbacksType,
) => Promise<boolean>

Registers a user-supplied event handler to document window.

Type declaration

    • (docEventCallbacks: DocEventCallbacksType): Promise<boolean>
    • Parameters

      • docEventCallbacks: DocEventCallbacksType

        The callback set. Reader will call a corresponding callback when the doc event occurs

      Returns Promise<boolean>

      TRUE means successful, otherwise not.

registerForContextMenuAddition: (
    name: string,
    menus: MenusType,
) => Promise<boolean>

Register the context menu.

Type declaration

    • (name: string, menus: MenusType): Promise<boolean>
    • Parameters

      • name: string

        Appends the type name of the right-click menu. Like: "Page","Annot","Select"

      • menus: MenusType

        The menu items of the context menu.

      Returns Promise<boolean>

      If register the context menu successfully, return true, otherwise return false.

const contextMenuAdditionJs = {
menuItems: [
{
index: 0,
icon: '',
title: 'menu1',
name: 'menu1',
tooltip: 'menu1',
describeText: 'menu1',
isSeparator: false,
executeProc: () => {
console.log('Execute proc');
},
isEnable: true
}
]}
await app.registerForContextMenuAddition('Page', contextMenuAdditionJs);
registerPageObjectSelectionHandler: (
    callbacks: PageObjectSelectionCallbacksType,
) => Promise<null | LPVOIDType>

register a page object selection handler.

Type declaration

const callbacks = {
onPageObjectSelectionKeyDown: (clientData, doc, curSelectData, keyinfoData) => {
console.log('onPageObjectSelectionKeyDown', clientData, doc, curSelectData, keyinfoData);
}
};
const pageObjectSelectionHandler = await app.registerPageObjectSelectionHandlerJs(callbacks);
registerRectangleHandler: (
    callbacks: ToolJsCallbacksType,
) => Promise<null | LPVOIDType>

Register the rectangle handler.

Type declaration

    • (callbacks: ToolJsCallbacksType): Promise<null | LPVOIDType>
    • Parameters

      • callbacks: ToolJsCallbacksType

        The callback set. Reader will call a corresponding callback when the rectangle is drawn.

      Returns Promise<null | LPVOIDType>

      Returns the rectangle handler object, which can be used to unregister the rectangle handler.

const callbacks = {
onToolLButtonDown: (clientData, pageview, flags, point) => {
console.log('onToolLButtonDown', clientData, pageview, flags, point);
},
onToolLButtonUp: (clientData, pageview, flags, point) => {
console.log('onToolLButtonUp', clientData, pageview, flags, point);
}
};
const toolHandler = await app.registerRectangleHandler(callbacks);
registerSelectionHandler: (
    callbacks: SelectionJsCallbacksType,
) => Promise<null | LPVOIDType>

register a selection handler.

Type declaration

const callbacks = {
onToolLButtonDown: (clientData, pageview, flags, point) => {
console.log('onToolLButtonDown', clientData, pageview, flags, point);
},
onToolLButtonUp: (clientData, pageview, flags, point) => {
console.log('onToolLButtonUp', clientData, pageview, flags, point);
}
};
const toolHandler = await app.registerSelectionHandler(callbacks);
selectOpenFile: (filter: string, multi: boolean) => Promise<string[]>

The selectOpenFile method is used to open a file selection dialog, allowing the user to select one or more files.

Type declaration

    • (filter: string, multi: boolean): Promise<string[]>
    • Parameters

      • filter: string

        A file filter string used to specify the visible file types.

      • multi: boolean

        Indicates whether multiple file selection is allowed.

      Returns Promise<string[]>

      Returns a promise that resolves to an array of strings, indicating the paths of the selected files.

setActiveDoc: (doc: DocType) => Promise<boolean>

Set the active document.It will be showed top-most.

Type declaration

    • (doc: DocType): Promise<boolean>
    • Parameters

      • doc: DocType

        The document that you want to set active.

      Returns Promise<boolean>

      If set the document active successfully, return true, otherwise return false.

setActiveDocByIndex: (index: number) => Promise<boolean>

Set the active document by index.

Type declaration

    • (index: number): Promise<boolean>
    • Parameters

      • index: number

        The index of the document. This value can be iterated through from getDocsCount.

      Returns Promise<boolean>

      If set the document active successfully, return true, otherwise return false.

setActiveTool: (tool: ToolType, persistent: boolean) => Promise<boolean>

Set the active tool.

Type declaration

    • (tool: ToolType, persistent: boolean): Promise<boolean>
    • Parameters

      • tool: ToolType

        The tool to be set as active.

      • persistent: boolean

        Whether to persist the tool. Default is false.

      Returns Promise<boolean>

      Returns true if the tool is set successfully, otherwise returns false.

showTaskPanel: (show: boolean) => Promise<void>

Show or hide the task pane.

Type declaration

    • (show: boolean): Promise<void>
    • Parameters

      • show: boolean

        Whether to show the task pane. Default is true.

      Returns Promise<void>

unRegisterPageObjectSelectionHandler: (
    selectionHandler: LPVOIDType,
) => Promise<boolean>

Unregister the page object selection event handler

Type declaration

    • (selectionHandler: LPVOIDType): Promise<boolean>
    • Parameters

      • selectionHandler: LPVOIDType

        The page object selection event handler, usually the object returned by registerPageObjectSelectionHandler

      Returns Promise<boolean>

      Returns the unregistration result

unRegisterRectangleHandler: (toolHandler: LPVOIDType) => Promise<boolean>

Unregister the rectangle handler.

Type declaration

    • (toolHandler: LPVOIDType): Promise<boolean>
    • Parameters

      • toolHandler: LPVOIDType

        The rectangle handler to be unregistered, generally the object returned by registerRectangleHandler.

      Returns Promise<boolean>

      Returns true if the rectangle handler is unregistered successfully, otherwise returns false.

unRegisterSelectionHandler: (selectionHandler: LPVOIDType) => Promise<boolean>

Unregister the selection event handler

Type declaration

    • (selectionHandler: LPVOIDType): Promise<boolean>
    • Parameters

      • selectionHandler: LPVOIDType

        The selection event handler, usually the object returned by registerSelectionHandlerJs

      Returns Promise<boolean>

      Returns the unregistration result