Foxit PDF SDK for Web

How to use ActionCallback

How to trigger JavaScript

//JsActionCallback is the implementation class of ActionCallback.
JsActionCallback* action_handler = new JsActionCallback();
Library::SetActionCallback(action_handler);
Form form(pdf_doc);
PDFPage pdf_page = pdf_doc.GetPage(0);
//Set JavaScript for the button.
Control control = form.GetControl(pdf_page, 0);
Widget widget_annot = control.GetWidget();
AdditionalAction widget_aa(widget_annot);
Action action = Action::Create(pdf_doc, Action::e_TypeJavaScript);
JavaScriptAction javascipt_action(action);
javascipt_action.SetScript(L"JavaScript code");
widget_aa.SetAction(AdditionalAction::e_TriggerAnnotMouseButtonPressed, javascipt_action);
//Trigger JavaScript Script.
widget_aa.DoJSAction(AdditionalAction::e_TriggerAnnotMouseButtonPressed)

How to implement ActionCallback

InvalidateRect

After the document content is updated, GSDK will call InvalidateRect.

//JavaScript code, add annotation to the document. 
var annot3 = this.addAnnot({
type: "Circle",
page: 1,
rect: [0,500,50,680],
popupOpen: false,
popupRect: [467,570,647,690], 
rect: [110.315002,545.960022,129.565002,574.835022],
});
virtual bool InvalidateRect(const PDFDoc& document, int page_index, const RectF& pdf_rect) {
    //Refresh the area specified by "pdf_rect" on page of "page_index" of the document
}

GetCurrentPage

//JavaScript code,obtaining the current page index
app.alert(this.pageNum);
virtual int GetCurrentPage(const pdf::PDFDoc& document){
  //Returns the index of the currently displayed page in the document
}

SetCurrentPage

//JavaScript code,skip to page three. 
this.pageNum = 2;
virtual void SetCurrentPage(const pdf::PDFDoc& document, int page_index){
  //Skip to page of "page_index" of document.
}

SetDocChangeMark GetDocChangeMark

//Javascript code
this.dirty = false;// or true
var dir = this.dirty;
virtual bool SetDocChangeMark(const pdf::PDFDoc& document, bool change_mark){
  if(change_mark == true){
    //Set the document update label to true and need to save before closing the document.
  }
  if(change_mark == false){
    //The document update label is set to false, no need to save before closing the document.
  }
}
virtual bool GetDocChangeMark(const pdf::PDFDoc& document){
   //return document update label;
}

GetCurrentDoc

virtual pdf::PDFDoc GetCurrentDoc(){
  //The document currently being viewed by the application
  return current_doc_
}

CreateBlankDoc

//JavaScript code
app.newDoc();
virtual pdf::PDFDoc CreateBlankDoc(){
  //Create new docment.
  PDFDoc new_doc = PDFDoc();
  new_doc.InsertPage(0, 612, 791);
  //open_doc_list +1
  //Set the new_doc to be current document
  current_doc_ = new_doc;
  return new_doc;
}

CloseDoc

this.closeDoc();
virtual void CloseDoc(const pdf::PDFDoc& document, bool is_prompt_to_save){
  if(is_prompt_to_save== true && document update label is true){
    //Prompt to save.
  }
  if(is_prompt_to_save== false){
    //Close the document without saving it.
  } 
}

OpenDoc

app.openDoc("C:/myDoc.pdf");
virtual bool OpenDoc(const WString& file_path, const WString& password){
  PDFDoc new_doc = PDFDoc(file_path);
   new_doc.Load(password);
  //open_doc_list +1
  //Set the new_doc to be current document
  current_doc_ = new_doc;
  return true;
}

Beep

app.beep(0);//0-4
virtual bool Beep(int type){
   //Windows Environment Example
   switch(type)
		{
		case 0:
			MessageBeep(MB_ICONEXCLAMATION);
			break;
		case 1:
			MessageBeep(MB_ICONHAND);
			break;
		case 2:
			MessageBeep(MB_ICONQUESTION);
			break;
		case 3:
			MessageBeep(MB_ICONASTERISK);
			break;
		case 4:
			MessageBeep(MB_OK);
			break;
		default:
			MessageBeep(-1);
			break;
		}
 }

Response

var cResponse = app.response({
cQuestion: "How are you today?",
cTitle: "Your Health Status",
cDefault: "Fine",
cLabel: "Response:"
});
virtual WString Response(CONSTCWSTR question, CONSTCWSTR title, CONSTCWSTR default_value,
                                CONSTCWSTR label, bool is_password){
  //Display a dialog.
  //DlgTitle = "Your Health Status"
  //Add static_label1 = "How are you today?"
  //Add static_label2 = "Response:"
  //Add edit "edit_response", default value:"Fine"
  return the value of "edit_response";
}

GetFilePath,IsLocalFile

var filepath = this.path;
virtual WString GetFilePath(const pdf::PDFDoc& document){
  return document path;
}
virtual bool IsLocalFile(const pdf::PDFDoc& document){
   if("document" is local document){
     return true;
   }else
     return false;
}

GetAttachmentsFilePath

this.importDataObject("MyData");//Attach a data file to the current document.
virtual WString GetAttachmentsFilePath(const pdf::PDFDoc& pdf_doc, CONSTCWSTR name){
  //name == L"MyData"
  //return the path of the data file to be attached to pdf_doc, GSDK will use name as the key to attach the data file to pdf_doc
}

GetAttachmentsFilePath

this.exportDataObject("MyData");//Export the data file corresponding to MyData
virtual WString GetExtractedEmbeddedFilePath(const pdf::PDFDoc& pdf_doc, CONSTCWSTR name){
  //return the exported path, GSDK will export the data file corresponding to name to this path
}

Print

function Doc_print()
{
this.print({bUI: true,
            bSilent:false,
	        bPrintAsImage:false,
	        bReverse:false,
	        bAnnotations:true,
	        } );
}
Doc_print();
virtual bool Print(const pdf::PDFDoc& document, const PrintParams& print_params){
 //Enable printing function to print "document" according to the printing settings indicated by "print_params"
}

LaunchURL

app.launchURL("http://www.example.com/");
virtual bool LaunchURL(CONSTCSTR url){
  //Open URL in browser   
  ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); 
}

BrowseFile

var oRetn = app.browseForDoc({
bSave: true,
cFilenameInit: "appbrowseForDoctest1.pdf",
cFSInit: "",
});
virtual WString BrowseFile(){
//Open the file dialog and return the selected file path
  CFileDialog fileDlg(FALSE, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("(*.pdf)|*.pdf"), NULL);
	if(fileDlg.DoModal() != IDOK) return L"";

	CString pdfpath = fileDlg.GetPathName();
    return pdfpath;
}
virtual WString BrowseFile(bool is_open_dialog, CONSTCWSTR file_format, CONSTCWSTR file_filter){
  //Open the file dialog and return the selected file path
   CFileDialog fileDlg(is_open_dialog, file_format, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, file_filter, NULL);
	if(fileDlg.DoModal() != IDOK) return L"";

	CString pdfpath = fileDlg.GetPathName();
    return pdfpath;
}

GetLanguage

app.language
virtual Language GetLanguage(){
  //Returns the language used by the application
  return ActionCallback::e_LanguageCHS;
}

Alert

app.alert("Hello world!")
virtual int Alert(CONSTCWSTR msg, CONSTCWSTR title, int type, int icon){
  UINT nType = 0;
   switch (type) {
      case 0:
        nType = MB_OK;
        break;
      case 1:
        nType = MB_OKCANCEL;
        break;
      case 2:
        nType = MB_YESNO;
        break;
      case 3:
        nType = MB_YESNOCANCEL;
        break;
     }
     switch (icon) {
      case 0:
        nType |= MB_ICONERROR;
        break;
      case 1:
        nType |= MB_ICONWARNING;
        break;
      case 2:
        nType |= MB_ICONQUESTION;
        break;
      case 3:
        nType |= MB_ICONINFORMATION;
        break;
     }
    int ret = MessageBox(msg, title, nType);​
    return ret;
}

GetIdentityProperties, SetIdentityProperties

//Call the function GetIdentityProperties
app.alert("Your name is " + identity.name);
app.alert("Your e-mail is " + identity.email);
//Call the function SetIdentityProperties
identity.email = "[email protected]"
virtual IdentityProperties GetIdentityProperties(){
  const wchar_t* sCorporation = L"Blanc&Eclare";
   const wchar_t* sEmail = L"[email protected]";
   const wchar_t* sLoginName = L"Sy_jessica";
   const wchar_t* sName = L"Jessica";
   const wchar_t* sFirstName = L"Sun";
   const wchar_t* sLastName = L"Yanzi";
   const wchar_t* sDepartment = L"AAA";
   const wchar_t* sTitle = L"CCC";
   IdentityProperties idProp(sCorporation, sEmail, sLoginName, sName, sFirstName, sLastName, sTitle, sDepartment);
   return idProp;
}

virtual bool SetIdentityProperties(const IdentityProperties& identity_properties){
   //adjust Identity Properties
}

PopupMenu

var cChoice = app.popUpMenu("item", "-", "Chapter 1",[ "Chapter 2", "Chapter 2 Start", "Chapter 2 Middle",["Chapter 2 End"," ", "The End"]]);

app.alert("You chose the " + cChoice + " menu item");
void AppendMenuWithArray(const foxit::MenuListArray& menus, pop_menu) {
  for (size_t i = 0; i < menus.GetSize(); i++) {
    foxit::MenuList menuItem = menus.GetAt(i);
    if (menuItem.name == L"-") {
      //Add split lines to pop_menu
    } else {
      if (menuItem.sub_menu_list_array.GetSize() > 0) {
        //Create a new pop-up menu sub_menu
        //Add sub_menu to pop_menu
        //Continue parsing submenus
        AppendMenuWithArray(menuItem.sub_menu_list_array, &sub_menu);
      }else {
        //Add menu "menuItem.name" to menu "pop_menu".
      }
    }
  }
}
virtual WString PopupMenu(const MenuListArray& menus, bool& is_selected_item){
    //Create a new pop-up menu"pop_menu".
    //parse menus
   AppendMenuWithArray(menus, pop_menu)
    //Get the current position "point"of mouse.
    //Display "pop_menu" in coordinate "point".
    //Determine whether the mouse clicks on a menu item or clicks on a blank space
    if(Mouse click on a menu item){
       is_selected_item = true;
        return the name of menu item clicked on.
    }else{
      is_selected_item = false;
        return L"";
    }
}

PopupMenuEx

var cChoice = app.popUpMenuEx
(
{cName: "Item 1", bMarked:true, bEnabled:false},
{cName: "-"},
{cName: "Item 2", oSubMenu:
[ {cName: "Item 2, Submenu 1"},
{
cName: "Item 2, Submenu 2",
oSubMenu: {cName:"Item 2, Submenu 2, Subsubmenu 1", cReturn: "0"}
}
]
},
{cName: "Item 3"},
{cName: "Item 4", bMarked:true, cReturn: "1"}
)
app.alert("You chose the \"" + cChoice + "\" menu item");
void AppendMenuWithArrayEx(const foxit::MenuItemExArray& menus, pop_menu) {
  for (size_t i = 0; i < menus.GetSize(); i++) {
    foxit::MenuItemEx menuItem = menus.GetAt(i);
    if (menuItem.item_name == L"-") {
      //Add a splitter line to the menu "pop_menu"
    } else {
      if (menuItem.sub_menu_item_array.GetSize() > 0) {
     //Create a new menu "sub_menu".
        UINT uFlags = MF_POPUP;
        if (menuItem.is_checked) 
        {
          uFlags |= MF_CHECKED;//Add a check mark to the menu
        }
        if (!menuItem.is_enabled)
        {
          uFlags |= MF_DISABLED;//Make the menu unselectable
        }
        //Add "sub_menu" to "pop_menu", and set "uFlags".
      //continue to parse sub menu.
        AppendMenuWithArrayEx(menuItem.sub_menu_item_array, &sub_menu);
      }else {
      UINT uFlags = MF_STRING;
        if (menuItem.is_checked) 
        {
          uFlags |= MF_CHECKED;
        }
        if (!menuItem.is_enabled)
        {
          uFlags |= MF_DISABLED;
        }
      //Add "menuItem.name" to "pop_menu", and set "uFlags".
      }
    }
  }
}
virtual MenuItemEx PopupMenuEx(const MenuItemExArray& menus, bool& is_selected_item){
   //Create a new pop-up menu"pop_menu".
    //parse menus
   AppendMenuWithArrayEx(menus, pop_menu)
   //Get the current position "point"of mouse.
    //Display "pop_menu" in coordinate "point".
    //Determine whether the mouse clicks on a menu item or clicks on a blank space
    if(Mouse click on a menu item){
       is_selected_item = true;
        return the name of menu item clicked on.
    }else{
      is_selected_item = false;
        return MenuItemEx();
    }
}

GetAppInfo

app.alert(app.appVersion)
virtual WString GetAppInfo(AppInfoType type){
  WString info = L"";
  switch(type)
  {
  case foxit::ActionCallback::e_AppInfoTypeFormsVersion:
    info = L"7.3";
    break;
  case foxit::ActionCallback::e_AppInfoTypeViewerType:
    info = L"Exchange-Pro";
    break;
  case foxit::ActionCallback::e_AppInfoTypeViewerVariation:
    info = L"full expired";
    break;
  case foxit::ActionCallback::e_AppInfoTypeViewerVersion:
    info = L"11.007";
    break;
  case foxit::ActionCallback::e_AppInfoTypeAppVersion:
    info = L"5.6";
    break;
  }

  return info;
}

MailData

app.mailMsg(false, "[email protected]; [email protected]", "", "",
"This is the subject", "This is the body of the mail.");
virtual bool MailData(void* data, MailType data_type, bool is_ui, CONSTCWSTR to,
                        CONSTCWSTR subject, CONSTCWSTR cc, CONSTCWSTR bcc, CONSTCWSTR message){
    //data_type = ActionCallback::e_MailTypeMsg
    //Send Email:[email protected]; [email protected]
    //Title:This is the subject
    //Text:This is the body of the mail.
    if(successfully sent)
      return true;
    else
      return false;
}

VerifySignature

var f = this.getField("Signature");
f.signatureValidate();
var Info = f.signatureInfo();
app.alert(Info.dateTrusted);
virtual uint32 VerifySignature(const pdf::PDFDoc& document, const pdf::Signature& pdf_signature){
  // Here's a simple sample about verifying a signature by LTVVerifier.
  LTVVerifier ltv_verifier(document, true, true, false, LTVVerifier::e_SignatureCreationTime);
  ltv_verifier.SetVerifyMode(LTVVerifier::e_VerifyModeAcrobat);
  SignatureVerifyResultArray sig_verify_result_array = ltv_verifier.VerifySignature(pdf_signature);
  size_t size = sig_verify_result_array.GetSize();
  if (size == 0) return 0;
  return sig_verify_result_array[0].GetSignatureState();
}

GetUntitledBookmarkName

this.bookmarkRoot.createChild("", "this.pageNum++");//New bookmark not named
virtual WString GetUntitledBookmarkName(){
   return "Untitled";//Use it as the name of the new bookmark  
}

GetPrinterNameList

var l = app.printerNames.length;
for ( var i = 0; i < l; i++)
app.alert("(" + (i+1) + ") " + app.printerNames[i]);
virtual WStringArray GetPrinterNameList(){
   //return list of printer names
   WString printer_name[] = { L"Adobe PDF", L"Fax", L"Foxit PDF Editor Printer" ,L"Microsoft Print to PDF" };
    WStringArray printer_names;
    for (int i = 0; i < sizeof(printer_name) / sizeof(printer_name[0]); i++) {
      printer_names.Add(printer_name[i]);
    }
    return printer_names;
}

AddToolButton,RemoveToolButtom

app.addToolButton({ cName:  "newBotton", cExec: "app.alert('!')" })
app.removeToolButton({ cName:  "newBotton"})
virtual bool AddToolButton(const ButtonItem& button_item){
    //Add a button to the program toolbar
    //button name = button_item.name
    //add "button_item.exec" as action to button 
}
virtual bool RemoveToolButtom(CONSTCWSTR button_name){
    // remove the button which name is "button_name"
}

GetMenuItemNameList

var menuItems = app.listMenuItems();
for( var i in menuItems)
app.alert(menuItems[i].cName + "\n")
virtual MenuListArray GetMenuItemNameList(){
    //Return to the main menu of the program and its submenus
   WString name_array[] = { L"File", L"Home", L"Convert", L"Edit", L"Form" };
    WString name_array_home[] = { L"Home_Tools_HandMenuItem",
                             L"Home_Tools_Select"};
    WString name_array_home_select[] = { L"Home_Tools_TextSelection",
      L"Home_Tools_AnnotSelection" };
    MenuListArray home_sel_menu_list_array;
    for (int i = 0; i < sizeof(name_array_home_select) / sizeof(name_array_home_select[0]); i++) {
      MenuList menu_list = MenuList(0, name_array_home_select[i], MenuListArray());
      home_sel_menu_list_array.Add(menu_list);
    }
    MenuListArray home_menu_list_array;
    for (int i = 0; i < sizeof(name_array_home) / sizeof(name_array_home[0]); i++) {
      MenuList menu_list = MenuList(0, name_array_home[i], home_sel_menu_list_array);
      home_menu_list_array.Add(menu_list);
    }
    MenuListArray menu_list_array;
    for (int i = 0; i < sizeof(name_array) / sizeof(name_array[0]); i++) {
      MenuList menu_list = MenuList(0,name_array[i], home_menu_list_array);
      menu_list_array.Add(menu_list);
    }
    return menu_list_array;
}

AddMenuItem

app.addMenuItem({
    cName: "1", 
	cParent: "Convert",	
    cExec:"app.alert('My Menu!');",
	nPos: "Home_Tools_HandMenuItem",
	bPrepend: false });
virtual bool AddMenuItem(const MenuItemConfig& menu_item_config, bool is_prepend){
    //Add a menu to menu "Convert",menu name is "1",添加位置在Home_Tools_HandMenuItem(menu_item_config.pos_str)之后,点击菜单会运行app.alert('My Menu!')
}

AddSubMenu

app.addSubMenu({	
    cName: "2", 
	cParent: "Convert",	
	nPos: "Home_Tools_HandMenuItem" });
virtual bool AddSubMenu(const MenuItemConfig& menu_item_config){
    //Add menu items with submenus to the application,the above JavaScript code just use "name","user","parent","pos/pos_str"of"menu_item_config".
    //Add a dropdown menu under the menu "Convert",menu name is 2. Add location: under "Home_Tools_HandMenuItem"(menu_item_config.pos_str)
}

ShowDialog

var dialog0 = {
    description: {
        name: "JavaScript",
       //first_tab:,
        width: 600,  
       height: 500,
        char_width: 0,
        //Test Value: 0
        char_height: 0,
        //align_children:"align_center",
        elements: [		
       { //ok_cancel Button
            type: "ok_cancel",
            ok_name: "Ok",
            cancel_name: "Cancel",
            alignment: "align_right" 
       }]
    }
};
app.execDialog(dialog0);
virtual bool ShowDialog(const DialogDescriptionConfig& dlg_config){
 //Create a dialog box, 'dlg_config' used to transfer the content of 'description' in the JavaScript script
}

Dialog example

GetFullScreen,SetFullScreen

var f = app.fullscreen;
app.fullscreen = true;
virtual bool GetFullScreen(){
    if(Currently in full screen mode)
         return true;
    else
         return false;
}
virtual void SetFullScreen(bool is_full_screen){
    if(is_full_screen)
        //Enter full screen mode.
    else
        //Set to Normal Mode.
}

OnFieldValueChanged

Triggered when the value of the form changes, used to notify users, allowing them to freely play.

virtual void OnFieldValueChanged(CONSTCWSTR field_name, JSFieldValueChangeType type, const WStringArray &value_before_changed, const WStringArray &value_after_changed){}

MailDoc

this.mailDoc({
bUI: false,
cTo: "[email protected]",
cCC: "[email protected]",
cSubject: "The Latest News",
cMsg: "A.P., attached is my latest news story in PDF."
});
virtual JsMailResult MailDoc(const pdf::PDFDoc& document,
    CONSTCWSTR to_address, CONSTCWSTR cc_address, CONSTCWSTR bcc_address,
    CONSTCWSTR subject, CONSTCWSTR message, bool is_ui){
    //Send the email with 'document' as an attachment, and refer to 'MailData' for other parameters.
}

GetTemporaryFileName

this.mailForm(false, "[email protected]; [email protected]", "", "",
"This is the subject", "This is the body of the mail.");//Export the form and send the generated FDF file as an attachment to the email.
virtual WString GetTemporaryFileName(const pdf::PDFDoc& document, CONSTCWSTR file_suffix_name){
    //"mailForm"needs a temporary path to save the form data exported from 'document'
    return "D:/temp.fdf";
}

OpenMediaPlayer

var myURLClip = "https://tntfiles.com/download/e04b7283fadece2d806222a70adebf6713fcbc7817e5428eb011b3ab27a4fede/DJ%E5%B0%8F%E5%85%AE%20-%20%E7%88%B1%E4%BD%A0%E4%B8%8D%E9%9C%80%E8%A6%81%E4%BB%BB%E4%BD%95%E7%9A%84%E7%90%86%E7%94%B1%20-%20DJ%E5%8A%A0%E5%BF%AB%E7%89%88.mp3";
var args1 = {
URL: myURLClip,
mimeType: "audio/mp3",
doc: this,
settings: {
players: app.media.getPlayers("audio/mp3"),
windowType: app.media.windowType.floating,
data: app.media.getURLData(myURLClip,"audio/mp3"),
floating: { height: 500, width: 700 }
}
}
var player = app.media.openPlayer(args1);
var p = player.isPlaying;
player.stop();
var settings = player.settings;

class MediaPlayerHandler: public MediaPlayerCallback {
public:

  virtual void Release(){}

  virtual bool Play() {
      //Play video.
      if(Played successfully)
        return true;
      else
        return false;
  }

  virtual void Close() {
      //Turn off player.
  }

  virtual bool Stop() {
     //Stop playing
  }

  virtual bool Seek(int current_pos){
     //Set the progress bar value to "current_pos".
  }

  virtual JSMediaPlayerState GetState() {
     switch(player status){
     case playing:
       return e_JSMediaPlayerStatePlaying;
     case closed:
       return e_JSMediaPlayerStateClose;
     case open:
       return e_JSMediaPlayerStateOpen;
     case stop:
       return e_JSMediaPlayerStateStop;
     case suspend:
       return e_JSMediaPlayerStateSuspend;
     }
  }

  virtual MediaSettings GetPlayerSettings(){
      //return player's setting.
  }
}
 virtual MediaPlayerCallback* OpenMediaPlayer(const PlayerArgs& player_args){
   //'player_args' is used to transfer the data of' args1 'in the script
   //Create a video playback window,
   return the corresponding 'MediaPlayerHandler' object in the playback window.
}

GetTemporaryDirectory

//Extract page to generate a new document, no save path specified.
var re=this.extractPages(0,1);
virtual WString GetTemporaryDirectory(){
 //return directory used to save temporary files.
 return "D:/Temp/"
}

Scroll

this.scroll(400,800);
virtual void Scroll(const PointF& point){
  //Scroll the view until 'point' is in the middle of the view
}

SelectPageNthWord

var cWord = this.getPageNthWord(1, 0);
app.alert(cWord)
virtual void SelectPageNthWord(int page_index, int start_offset, int end_offset, bool is_show_selection){
    //Select the characters in the index page with an offset from "start_offset" to "end_offset".
    if(is_show_selection == true){//Show Selected}
    else{ //Do not display}
}

GetMousePosition

var x = this.mouseX;
var y = this.mouseY;
virtual PointF GetMousePosition(){
    //Returns the device coordinates of the mouse.
}

GetPageWindowRect

//pageWindowRect
app.alert("pageWindowRect: " + this.pageWindowRect);
virtual RectF GetPageWindowRect(){
    //Returns the 'rect' of the current document view (window displaying the document)
}

GetLayoutMode,SetLayoutMode

this.layout="OneColumn";
app.alert(this.layout);
virtual LayoutMode GetLayoutMode(){
    //Returns the browsing mode of the current reader
    switch (browse mode) {
      case single page browsing:
        return ActionCallback::e_LayoutModeSinglePage;
        break;
      case Continuous single page browsing:
        return ActionCallback::e_LayoutModeContinuous;
        break;
      case Double page browsing:
        return ActionCallback::e_LayoutModeFacing;
        break;
      case Continuous dual page browsing:
        return ActionCallback::e_LayoutModeContinuousFacing;
        break;
     }
}
virtual void SetLayoutMode(LayoutMode layout_mode, bool is_cover_mode){
    switch (layout_mode) {
      case ActionCallback::e_LayoutModeSinglePage:
        browse mode = single page browsing;
        break;
      case ActionCallback::e_LayoutModeContinuous:
        browse mode = Continuous single page browsing;
        break;
      case ActionCallback::e_LayoutModeFacing:
        browse mode = Double page browsing;
        break;
      case ActionCallback::e_LayoutModeContinuousFacing:
        browse mode = Continuous dual page browsing;
        break;
     }
     if(is_cover_mode == true) 
       The cover is not affected by browsing mode and is always displayed separately.
}

GetPageScale

//Read
var zoom = this.zoom;
virtual float GetPageScale(){ 
    //Returns the current view page zoom value.
}

SetPageScale

//Write
this.zoom = 200;

//FitHeight
this.zoomType = zoomtype.fitH;
virtual void SetPageScale(foxit::pdf::Destination::ZoomMode zoom_mode, const foxit::pdf::Destination& dest){
    switch (zoom_mode) {
    case foxit::pdf::Destination::e_ZoomXYZ:
      //Set Zoom Mode
      break;
    case foxit::pdf::Destination::e_ZoomFitPage:
      //Set Zoom Mode
      break;
    case foxit::pdf::Destination::e_ZoomFitHorz:
      //Set Zoom Mode
      break;
    case foxit::pdf::Destination::e_ZoomFitVert:
      //Set Zoom Mode
      break;
    case foxit::pdf::Destination::e_ZoomFitRect:
      //Set Zoom Mode
      break;
    default:
      break;
   }
   objects::PDFArray* arr = dest.GetDestArray();//The third value of 'arr' is the scaling value
}

GetPageZoomMode

var type = this.zoomType;
virtual foxit::pdf::Destination::ZoomMode GetPageZoomMode(){
  foxit::pdf::Destination::ZoomMode zoom_mode;
 switch (Current View Adaptation Mode) {
    case PDFZOOM_XYZ:
      zoom_mode = foxit::pdf::Destination::e_ZoomXYZ;
      break;
    case PDFZOOM_FITPAGE:
      zoom_mode = foxit::pdf::Destination::e_ZoomFitPage;
      break;
    case PDFZOOM_FITHORZ:
      zoom_mode = foxit::pdf::Destination::e_ZoomFitHorz;
      break;
    case PDFZOOM_FITVERT:
      zoom_mode = foxit::pdf::Destination::e_ZoomFitVert;
      break;
    case PDFZOOM_FITRECT:
      zoom_mode = foxit::pdf::Destination::e_ZoomFitRect;
      break;
    default:
      break;
    }
    return zoom_mode;
}

Query

search.query("Foxit","Folder","F:/DingDing");
virtual void Query(CONSTCWSTR keywords, SearchScope search_scope, const SearchOption& search_option, CONSTCWSTR di_path){
    //Create Search
   switch (search_scope) {
    case ActionCallback::e_SearchScopeActiveDoc:
      Search for 'keywords' in the current document
      break;
    case ActionCallback::e_SearchScopeFolder:
      Search for 'keywords' in the PDF file in the folder specified by' di_path ';
      break;
    case ActionCallback::e_SearchScopeIndex:
      Search for 'keywords' for files included in the index file specified in' di_path ';
      break;
    case ActionCallback::e_SearchScopeActiveIndexes:
      Search for 'keywords' in the files included in the selected index file in the current index list;
      break;
    default:
      break;
    }
}

AddSearchIndex

search.addIndex("c:/program files/exchhelp.xml",true);
virtual SearchIndexConfig AddSearchIndex(CONSTCWSTR di_path, bool is_selected){
    //Add the index specified by 'di_path' to the index list and set the name 'index1' for the index
    if(is_selected)
        Set the index to the selected state, and when the search scope of Query is "ActionCallback:: eSearchScopeActiveIndexes", search in the selected index
   return SearchIndexConfig("index1",true, di_path, is_selected);
}

GetSignatureAPStyleNameList

///appearances///
var myEngine = security.getHandler("Adobe.PPKLite");
var appArray = myEngine.appearances;
for( var i = 0; i < appArray.length; i++)
app.alert(appArray[i]);
std::map<WString, uint32> map_ap;
virtual WStringArray GetSignatureAPStyleNameList(){
    uint32 flag1 = Signature::e_APFlagLabel|Signature::e_APFlagSigner|Signature::e_APFlagReason
		|Signature::e_APFlagDN | Signature::e_APFlagLocation | Signature::e_APFlagText
		|Signature::e_APFlagSigningTime | Signature::e_APFlagBitmap | Signature::e_APFlagFoxitFlag;
    //Name flag1 style1
    map_ap["style1"] = flag1;
   uint32 flag2 = Signature::e_APFlagLabel|Signature::e_APFlagSigner|Signature::e_APFlagReason
		|Signature::e_APFlagDN | Signature::e_APFlagLocation | Signature::e_APFlagText
		|Signature::e_APFlagSigningTime | Signature::e_APFlagBitmap;
    //name flag2 style2
    map_ap["style2"] = flag2;
   foxit::WStringArray arr;
    arr.Add(L"style1");
    arr.Add(L"style2");
    return arr;
}

Updated on December 1, 2023

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: