Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents the Foxit PDF Editor application.

This class offers functions to interact with the Foxit PDF Editor application.
To get the app, please use

Foxit.ReaderApp

Hierarchy

  • PhantomApp

Index

Properties

storage

storage: Storage

The app storage

Methods

addAppListener

  • addAppListener<T>(event: T, listener: AppEventMap[T]): Promise<void>
  • Add an event listner of given event for the app.

    see

    AppEventMap

    Type parameters

    Parameters

    • event: T

      A string representing the event type to listen for.

    • listener: AppEventMap[T]

      The event listner to be add to the event target.

    Returns Promise<void>

addDiscovery

  • Add a discovery card in home page

    Parameters

    • options: DiscoverOptions

      Options is used in creating a new discovery card. example:

      {
         title: "test",
         icon: "http://test-color.svg",
         description: "this is a test card",
         url: "https://localhost:8080/panel.html",
         buttonText: "hello",
         index: 1
      }
      

    Returns Promise<void>

addDriver

  • addDriver(title: string, icon: any): Promise<void>
  • addDriver

    Parameters

    • title: string

      driver Title

    • icon: any

      icon.
      example:

      let title = 'testDriver';
      let icon = {
             selected: 'http://driver-color.svg',
             normal: 'http://driver-gray.svg'
      };
      

    Returns Promise<void>

addFontMaps

  • addFontMaps(fontMaps: FontMap[]): Promise<void>
  • Sets a custom font in the app for editing PDF text.
    Before using this function, you should call setJRFontMaps() to map the available fonts.
    example:

     function example (pdfViewer) {
    pdfViewer.addFontMaps([
    {
    "name": "SimSun",
    "style": 34,
    "charset": 134
    }
    ])
    }
    
    see

    FontMap

    Parameters

    Returns Promise<void>

addMenuItem

  • Add a menu item in home page

    Parameters

    • options: MenuItemOptions

      Options is used in creating a new menu item example:

      {
        label:"test",
        icon:"http://test-color.svg",
        url:"http://localhost:8080/index1.html",
      }
      

    Returns Promise<void>

addTooltip

  • Add a Tooltip in page

    Parameters

    • options: TooltipOptions

      Options is used in creating a tooltip example:

      {
        title: "title",
        content: "content",
        el: ".class-name" // or position:{x:100, y:100}
      }
      

    Returns Promise<any>

alert

  • alert(text: string): Promise<void>
  • Instruct the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.

    Parameters

    • text: string

      A string you want to display in the alert dialog

    Returns Promise<void>

checkIfContextMenuExist

  • checkIfContextMenuExist(pluginId: string, contextMenu: ContextMenuType, menuName: string): Promise<boolean>
  • Check if Context Menu Exists

    Parameters

    • pluginId: string

      The plugin id.

    • contextMenu: ContextMenuType

      the context menu.

    • menuName: string

      menu Name.

    Returns Promise<boolean>

closeDialog

  • closeDialog(pluginId: string, dlgId: string): Promise<void>
  • closeDialog

    Parameters

    • pluginId: string
    • dlgId: string

    Returns Promise<void>

    void

dispatch

  • dispatch(event: LoadFinish): Promise<void>
  • Send event to the app.

    Parameters

    • event: LoadFinish

      The event to be sent.

    Returns Promise<void>

doLogin

  • doLogin(): Promise<any>
  • To log in with your account

    Returns Promise<any>

driverDownloadFile

  • driverDownloadFile(driverId: string, url: string, headers: any, method: string, data: any): Promise<void>
  • Driver download file

    Parameters

    • driverId: string
    • url: string

      The file url.

    • headers: any
    • method: string

      The http Method. the value is 'POST' or 'GET'

    • data: any

      The http params, user defined. example:

      headers= {
      'Content-type': 'application/json'
      }
      data = {} // user defined.
      

    Returns Promise<void>

driverSetFileList

  • driverSetFileList(driverId: string, result: any): Promise<void>
  • driverSetFileList

    Parameters

    • driverId: string

      The driver Plugin id.

    • result: any

      The file list. example:

      success:
      let filelst = [{
        "id": "id:ABCDEFG",
        "isFolder": true,
      }, {
        name: 'test.pdf',
        id: 'file id',
        modifiedTime: '2022-05-30T10:36:41Z',
        size: 6438,
      } ];
      let result = {
         "fileList":filelst
        }
      
      error:
      let result = {
      "error":{"errorMsg":"user define errorMsg"}
      }
      

    Returns Promise<void>

driverSetUploadFileResult

  • driverSetUploadFileResult(driverId: string, result: any): Promise<void>
  • upload file result

    Parameters

    • driverId: string

      The driverId

    • result: any

      The upload result. example:

      let result = {}
      let result = {
      "error":{"errorMsg":"errorMsg"}
      }
      

    Returns Promise<void>

driverSetUserInfo

  • driverSetUserInfo(driverId: string, result: any): Promise<void>
  • driverSetUserInfo set UserInfo

    Parameters

    • driverId: string

      The driver Plugin id

    • result: any

      The user info. example:

       let result = {
         userInfo: {'id':"driverId",'title':userAccount},
       };
      
       let result = {
           {"error":{"errorMsg":"errmsg"}}
       }
      

    Returns Promise<void>

getActiveDoc

  • getActiveDoc(): Promise<null | Doc>
  • Get the active pdf document of this app.

    see

    Doc

    Returns Promise<null | Doc>

    The active pdf document.

getAnnotDefaultProperty

  • getAnnotDefaultProperty(type: String, intent?: String): Promise<any>
  • Get default style of annot

    Parameters

    • type: String
    • Optional intent: String

    Returns Promise<any>

getAnnotManager

  • getAnnotManager(): Promise<AnnotManager>
  • Get the AnnotManager

    see

    [[AnnotManager]]

    Returns Promise<AnnotManager>

getAppColors

  • getAppColors(): Promise<any>
  • Get Editor colors

    Returns Promise<any>

getAppTitle

  • getAppTitle(): Promise<string>
  • Get the title of the app.

    Returns Promise<string>

    The title of the app.

getCharBBox

  • getCharBBox(fontId: Number, unicode: Number): Promise<{ bottom: Number; height: Number; left: Number; right: Number; top: Number; width: Number }>
  • Get character size

    brief

    Standard font: Courier. e_StdIDCourier: 0,

    brief

    Standard font: Courier-Bold. e_StdIDCourierB: 1,

    brief

    Standard font: Courier-BoldOblique, Bold italic. e_StdIDCourierBI: 2,

    brief

    Standard font: Courier-Oblique, Italic. e_StdIDCourierI: 3,

    brief

    Standard font: Helvetica. e_StdIDHelvetica: 4,

    brief

    Standard font: Helvetica-Bold. e_StdIDHelveticaB: 5,

    brief

    Standard font: Helvetica-BoldOblique, Bold italic. e_StdIDHelveticaBI: 6,

    brief

    Standard font: Helvetica-Oblique, Italic. e_StdIDHelveticaI: 7,

    brief

    Standard font: Times-Roman. e_StdIDTimes: 8,

    brief

    Standard font: Times-Bold. e_StdIDTimesB: 9,

    brief

    Standard font: Times-BoldItalic. e_StdIDTimesBI:10,

    brief

    Standard font: Times-Italic. e_StdIDTimesI:11,

    brief

    Standard font: Symbol. e_StdIDSymbol:12,

    brief

    Standard font: ZapfDingbats. e_StdIDZapfDingbats:13,

    Parameters

    • fontId: Number
    • unicode: Number

      unicode of character

    Returns Promise<{ bottom: Number; height: Number; left: Number; right: Number; top: Number; width: Number }>

    let str = "hello";
    let ret = await window.Foxit.ReaderApp.getCharBBox(1,str.charCodeAt(0));
    

getCharWidthByFontID

  • getCharWidthByFontID(fontId: Number, unicode: Number): Promise<Number>
  • Get character width in PDF by specific font

    Parameters

    • fontId: Number

      same with getCharBBox fontId @see getCharBBox

    • unicode: Number

      unicode of character

    Returns Promise<Number>

getContextMenuCount

  • get the menu count.

    Parameters

    Returns Promise<number>

getCurToolHandler

  • getCurToolHandler(): Promise<string>
  • Get the name of current active tool.

    Returns Promise<string>

getDialogRect

  • getDialogRect(pluginId: string, dlgId: string): Promise<{ height: number; left: number; top: number; width: number }>
  • Get the Position and size of dialog according to Parameters: "pluginId" and "dlgId"

    Parameters

    • pluginId: string
    • dlgId: string

    Returns Promise<{ height: number; left: number; top: number; width: number }>

    If the dialog corresponding to "dlgId" does not exist, it will return undefined

getFontToneByFontID

  • getFontToneByFontID(fontId: Number): Promise<{ ascent: Number; descent: Number }>
  • Get Ascent Descent

    Parameters

    • fontId: Number

      same with getCharBBox fontId @see getCharBBox

    Returns Promise<{ ascent: Number; descent: Number }>

getFormatSymbolString

  • getFormatSymbolString(number: Number, lang: String): Promise<String>
  • Used to specify numeric formatting based on language Settings.

    Parameters

    • number: Number

      the input number.

    • lang: String

      string - The language code, The built-in supported languages are these: 'en-US', 'zh-CN', 'de-DE', 'zh-TW', 'es-419', 'fr-FR', 'it-IT', 'ja-JP', 'nl-NL', 'ko-KR'.

    Returns Promise<String>

getFormatTool

  • Get the FormatTool of the app.

    see

    FormatTool

    Returns Promise<FormatTool>

    The FormatTool instance.

getInfo

  • Get basic information of the app.

    Returns Promise<AppInfo>

getJsEnabled

  • getJsEnabled(): Promise<boolean>
  • Checks if PDF js can be executed.

    Returns Promise<boolean>

    True means JavaScript can be executed, and false means the opposite.

getMeasurementUnits

  • getMeasurementUnits(): Promise<string>
  • get current Mesurement Units

    Returns Promise<string>

getPageEditor

  • getPageEditor(): Promise<PageEditor>
  • Get the PageEditor of the app.

    Returns Promise<PageEditor>

getPortfolioLayoutMode

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

getRibbonBar

  • Get the RibbonBar of the app.

    see

    RibbonBar

    Returns Promise<RibbonBar>

    The RibbonBar instance.

getUserInfo

  • getUserInfo(): Promise<any>
  • get userinfo

    Returns Promise<any>

getViewport

  • getViewport(): Promise<any>
  • Get the width and height of Editer online's viewport.

    Returns Promise<any>

isAutoScroll

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

isLoggedIn

  • isLoggedIn(): Promise<Boolean>
  • To check if the user is logged in

    Returns Promise<Boolean>

openDocByBlob

  • Open doc by blob.

    Parameters

    • blob: Blob

      Specify PDF file's stream.

    • Optional options: OpenFileOptions

      The open file options.

    Returns Promise<void>

openDocbyUrl

  • Open doc by url.

    Parameters

    • url: string

      The pdf url.

    • Optional options: OpenFileOptions

      The open file options.

    Returns Promise<void>

registerForContextMenuByIndex

  • registerForContextMenuByIndex(pluginId: string, contextMenu: ContextMenuType, index: number, menuName: string, showFlag: string[]): Promise<void>
  • register For contenxt menu by index

    Parameters

    • pluginId: string

      The plugin id.

    • contextMenu: ContextMenuType

      the context menu.

    • index: number

      the position.

    • menuName: string

      true: menu Name.

    • showFlag: string[]

    Returns Promise<void>

registerForContextMenuByName

  • registerForContextMenuByName(pluginId: string, contextMenu: ContextMenuType, targetMenu: string, menuName: string, showFlag: string[]): Promise<void>
  • register For contenxt menu by name

    Parameters

    • pluginId: string

      The plugin id.

    • contextMenu: ContextMenuType

      the context menu.

    • targetMenu: string

      the target menuName.

    • menuName: string

      menu Name.

    • showFlag: string[]

      : the customer directory value.

    Returns Promise<void>

registerSecurityHandler

  • registerSecurityHandler(pluginId: String, filter: String, securityCallback: SecurityCallback): Promise<boolean>
  • registerSecurityHandler Register the security handler to implement encryption and decryption functions.

    see

    SecurityCallback

     let ret = Foxit.ReaderApp.registerSecurityHandler("pluginid", "filter",
    {
    "JSUseStandardCryptoMethod": "http://127.0.0.1:18888/v1/JSUseStandardCryptoMethod",
    "JSCreateContext": "http://127.0.0.1:18888/v1/JSCreateContext",
    "JSReleaseContext": "http://127.0.0.1:18888/v1/JSReleaseContext",
    "JSGetUserPermissions": "http://127.0.0.1:18888/v1/JSGetUserPermissions",
    "JSIsOwner": "http://127.0.0.1:18888/v1/JSIsOwner",
    "JSGetCipher": "http://127.0.0.1:18888/v1/JSGetCipher",
    "JSGetEncryptKey": "http://127.0.0.1:18888/v1/JSGetEncryptKey",
    "JSGetDecryptedSize": "http://127.0.0.1:18888/v1/JSGetDecryptedSize",
    "JSStartDecryptor": "http://127.0.0.1:18888/v1/JSStartDecryptor",
    "JSDecryptData": "http://127.0.0.1:18888/v1/enryptoDecryptStream",
    "JSFinishDecryptor": "http://127.0.0.1:18888/v1/JSFinishDecryptor",
    "JSGetEncryptedSize": "http://127.0.0.1:18888/v1/JSGetEncryptedSize",
    "JSEncryptData": "http://127.0.0.1:18888/v1/enryptoEncryptContent"
    });
    

    Parameters

    • pluginId: String

      The plugin id.

    • filter: String

      Indicates an encrypted dictionary.

    • securityCallback: SecurityCallback

    Returns Promise<boolean>

    true: success false: fail

registerToolHandler

  • registerToolHandler(toolHandler: ToolHandler): Promise<void>
  • Regiter a ToolHandler to the app.

    Parameters

    • toolHandler: ToolHandler

      The ToolHandler to be registered to the app.

    Returns Promise<void>

setCurToolHandler

  • setCurToolHandler(toolName: string): Promise<boolean>
  • Let the app to switch to specific tool.

    Parameters

    • toolName: string

      The name of the tool to be switched to.

    Returns Promise<boolean>

setDefaultPrintSetting

  • setDefaultPrintSetting(printSetting: PrintSetting): Promise<void>
  • Configure printing settings.

    Parameters

    Returns Promise<void>

setDialogRect

  • setDialogRect(pluginId: string, dlgId: string, rect: Rect): Promise<void>
  • Set the Position and size of dialog according to Parameters: "pluginId" and "dlgId"

    Parameters

    • pluginId: string
    • dlgId: string
    • rect: Rect

      Position and size of dialog

    Returns Promise<void>

setDriverSignInResult

  • setDriverSignInResult(driverId: string, result: any): Promise<void>
  • setDriverSignInResult

    Parameters

    • driverId: string
    • result: any

      The sign in result,

    Returns Promise<void>

setJRFontMaps

  • setJRFontMaps(JRFontMaps: JRFontMap[]): Promise<void>
  • Set app custom fonts.
    example:

     function example (pdfViewer) {
    pdfViewer.setJRFontMap([{
    nameMatches: [
    // A string or regular expression that matches a literal name. Can be an empty array or unset.
    /(helvetica)|(helveticabold)|(helveticaoblique)/,
    ],
    glyphs: [
    {
    bold: 0x1f0, // 0b111110000 match 500,600,700,800,900 weight font
    flags: 0x80000, // Font Descriptor Flags
    url: 'NotoSans-Bold.ttf.brotli',
    isBrotli: true,
    },
    {
    bold: -1, // Matches any word width
    flags: 0x80000,
    url: 'NotoSans-Regular.ttf'
    },
    ],
    charsets:[0], //The charsets of the font.
    }])
    }
    

    Parameters

    • JRFontMaps: JRFontMap[]

      Custom fonts. The Settings are valid before opening the document.

    Returns Promise<void>

setJsEnable

  • setJsEnable(enable: boolean): Promise<void>
  • Set whether JavaScript is allowed to be executed or not.

    Parameters

    • enable: boolean

    Returns Promise<void>

showDialog

  • showDialog(pluginId: string, dlgId: string, title: string, url: string, rect: object, mode?: ShowDialogModes, style?: ShowDialogStyle): Promise<void>
  • ShowDialog

    Parameters

    • pluginId: string
    • dlgId: string
    • title: string

      The dialog title.

    • url: string

      The iframe url.

    • rect: object

      The dialog rect. eg: { width: 790, height: 800, x: 0, y: 0 }

    • Optional mode: ShowDialogModes

      If dialog contains the header. default value: Frame

    • Optional style: ShowDialogStyle

      Customize dialog style. Only support padding and margin at present. The default value is empty object

    Returns Promise<void>

    void example:

     window.Foxit.ReaderApp.showDialog(
        'dlgId',
        '12345',
        'title',
        'http://localhost:10001/demo.html',
        { width: 790, height: 800 },
        'Frame',
        {
          padding: '0',
          margin: '0',
        }
      );
    

showWarningMessage

  • Show A MessageBox

    Parameters

    • data: ShowWarningMessageParams

      ShowWarningMessageParams example:

        let ret = Foxit.ReaderApp.showWarningMessage({
          message: 'hello world',
          iconType: 'warning',
          title: '12345',
          ok: 'ok',
          cancel: 'cancel'
        });
      

    Returns Promise<[Boolean, { checked?: Boolean }]>

switchTo

  • switchTo(name: string, params: Object): Promise<any>
  • brief

    Switch to state handler, Switch the top button status. Currently, the supported names are shown below and are generally not used directly. They are commonly used in conjunction with other interfaces, such as triggering real-time signature drawing

    note

    If encounter error, it will switch to HandStateHandler.

    code
    // params is undefined, As a reserved field, parameters do not need to be passed
    await Foxit.ReaderApp.switchTo('CreateSignStateHandler');
    
    endcode

    Parameters

    • name: string

      string - Specifies the state handler's name. Currently, only the following types are supported. If you have any requirements, please contact us CreateSignStateHandler CreateTextStateHandler CreateDateStateHandler

    • params: Object

      undefined, At present, it is only used for signature purposes. Switch to real-time drawing status and do not pass this parameter. Please take a place and supplement it if needed in the future

    Returns Promise<any>

unRegisterForContextMenuByName

  • unRegisterForContextMenuByName(pluginId: string, contextMenu: ContextMenuType, targetMenu: string, menuName: string, showFlag: string[]): Promise<void>
  • unregister For contenxt menu by name

    Parameters

    • pluginId: string

      The plugin id.

    • contextMenu: ContextMenuType

      the context menu.

    • targetMenu: string

      the target menuName.

    • menuName: string

      menu Name.

    • showFlag: string[]

      : the customer directory value.

    Returns Promise<void>

unRegisterSecurityHandler

  • unRegisterSecurityHandler(pluginId: String, filter: String): Promise<boolean>
  • unRegisterSecurityHandler UnRegister the security handler.

    Parameters

    • pluginId: String

      The plugin id.

    • filter: String

      Indicates an encrypted dictionary.

    Returns Promise<boolean>

    true: success false: fail