Optionaloptions: CloseOptionsClose options, the defalut value is {promptToSave: true, showCancel: true}
If close the document successfully, return true, otherwise return false.
Creates a blank document.
Gets the top-most document which for displaying PDF file type.
Get the active tool.
Get the path of the current application.
The path of the current application.
Get the title of the current application.
The title of the current application.
Gets the document by specified index.
The number of documents currently open.
Returns the currently open document number.
Get the name of the current application.
Get the name of the application. It will be "Foxit PhantomPDF" or "Foxit Reader".
Get the ribbon bar of the application.
The parent window of the ribbon bar.
Returns the ribbon bar of the application.
Get a tool by name.
Get the version of the current application.
Get the version of the application.
Get the task pane show status.
Load the graphic object addon.
Open a PDF document from a URL.
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}`);
}
}
});
Open a PDF document by OpenFromFileOptions.
The options of opening a PDF document.
Registers a user-supplied event handler to document window.
The callback set. Reader will call a corresponding callback when the doc event occurs
TRUE means successful, otherwise not.
Register the context menu.
Appends the type name of the right-click menu. Like: "Page","Annot","Select"
The menu items of the context menu.
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);
register a page object selection handler.
The callback set. Reader will call a corresponding callback when the page object selection is made.
Returns the page object selection handler object, which can be used to unregister the page object selection handler.
Register the rectangle handler.
The callback set. Reader will call a corresponding callback when the rectangle is drawn.
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);
register a selection handler.
The callback set. Reader will call a corresponding callback when the selection is made.
Returns the selection handler object, which can be used to unregister the selection 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.registerSelectionHandler(callbacks);
The selectOpenFile method is used to open a file selection dialog, allowing the user to select one or more files.
A file filter string used to specify the visible file types.
Indicates whether multiple file selection is allowed.
Returns a promise that resolves to an array of strings, indicating the paths of the selected files.
Set the active document.It will be showed top-most.
Set the active document by index.
The index of the document. This value can be iterated through from getDocsCount.
If set the document active successfully, return true, otherwise return false.
Set the active tool.
Show or hide the task pane.
Whether to show the task pane. Default is true.
Unregister the page object selection event handler
The page object selection event handler, usually the object returned by registerPageObjectSelectionHandler
Returns the unregistration result
Unregister the rectangle handler.
The rectangle handler to be unregistered, generally the object returned by registerRectangleHandler.
Returns true if the rectangle handler is unregistered successfully, otherwise returns false.
Unregister the selection event handler
The selection event handler, usually the object returned by registerSelectionHandlerJs
Returns the unregistration result
Close the current active document.