FoxitPDFSDKforWeb  v9.2.0
Foxit PDF SDK for Web
FindReplaceAddon Class Reference

Provides APIs to find or replace text in the PDF document. More...

Inherits UIXAddon.

Public Member Functions

 activate ()
 Activate find and replace function. More...
 
 deactivate ()
 Deactivate find and replace function. Must be called after activate. More...
 
 find (find, options)
 Find text. More...
 
 replace (find, replace, options)
 Replace text. More...
 
 replaceAll (find, replace, options)
 Replace all text. More...
 

Detailed Description

Provides APIs to find or replace text in the PDF document.

Since
9.2.0
Example of obtaining and using the FindReplace Addon:
pdfui.getAddonInstance('FindReplaceUIXAddon').then(findReplace => {
if (findReplace) {
// ...
} else {
console.error("FindReplace Addon instance not found.");
}
});

Member Function Documentation

◆ activate()

FindReplaceAddon::activate ( )
inline

Activate find and replace function.

Returns
Promise<void> - Promise resolved when the find and replace function is activated.
Example of obtaining and using the FindReplace Addon:
pdfui.getAddonInstance('FindReplaceUIXAddon').then(findReplace => {
if (findReplace) {
findReplace.activate();
} else {
console.error("FindReplace Addon instance not found.");
}
});
Since
9.2.0

◆ deactivate()

FindReplaceAddon::deactivate ( )
inline

Deactivate find and replace function. Must be called after activate.

Returns
Promise<void> - Promise resolved when the find and replace function is deactivated.
Example of obtaining and using the FindReplace Addon:
pdfui.getAddonInstance('FindReplaceUIXAddon').then(findReplace => {
if (findReplace) {
findReplace.deactivate();
} else {
console.error("FindReplace Addon instance not found.");
}
});
Since
9.2.0

◆ find()

FindReplaceAddon::find (   find,
  options 
)
inline

Find text.

Note
Usually, you need to activate the find and replace function before using the APIs. For activation and deactivation, see [activate]FindReplaceAddon#activate and [deactivate]FindReplaceAddon#deactivate.
Parameters
findstring - Text to find.
[options]Object - Options for finding.
[options.wholeWords=false]boolean - Whether to match whole words.
[options.caseSensitive=false]boolean - Whether to match case sensitive.
[options.isReversed=false]boolean - Whether to search in reversed order.
Returns
Promise<boolean> - Promise resolved with true if the text is found, false otherwise.
Example of obtaining and using the FindReplace Addon:
pdfui.getAddonInstance('FindReplaceUIXAddon').then(findReplace => {
if (findReplace) {
findReplace.activate().then(() => {
findReplace.find('text to find', {
wholeWords: true,
isReversed: true
}).then(isFound => {
// ...
});
});
} else {
console.error("FindReplace Addon instance not found.");
}
});
Since
9.2.0

◆ replace()

FindReplaceAddon::replace (   find,
  replace,
  options 
)
inline

Replace text.

Note
Usually, you need to activate the find and replace function before using the APIs. For activation and deactivation, see [activate]FindReplaceAddon#activate and [deactivate]FindReplaceAddon#deactivate.
Parameters
findstring - Text to find.
replacestring - Text to replace.
[options]Object - Options for finding.
[options.wholeWords=false]boolean - Whether to match whole words.
[options.caseSensitive=false]boolean - Whether to match case sensitive.
Returns
Promise<void> - Promise resolved when the text is replaced.
Example of obtaining and using the FindReplace Addon:
pdfui.getAddonInstance('FindReplaceUIXAddon').then(findReplace => {
if (findReplace) {
findReplace.activate().then(() => {
findReplace.replace('text to find', 'text to replace', {
wholeWords: true,
}).then(() => {
// The text is replaced
}, () => {
// Finished searching the document. No matches were found.
});
});
} else {
console.error("FindReplace Addon instance not found.");
}
});
Since
9.2.0

◆ replaceAll()

FindReplaceAddon::replaceAll (   find,
  replace,
  options 
)
inline

Replace all text.

Note
Usually, you need to activate the find and replace function before using the APIs. For activation and deactivation, see [activate]FindReplaceAddon#activate and [deactivate]FindReplaceAddon#deactivate.
Parameters
findstring - Text to find.
replacestring - Text to replace.
[options]Object - Options for finding.
[options.wholeWords=false]boolean - Whether to match whole words.
[options.caseSensitive=false]boolean - Whether to match case sensitive.
Returns
Promise<number> - Promise resolved with the number of replacements.
Example of obtaining and using the FindReplace Addon:
pdfui.getAddonInstance('FindReplaceUIXAddon').then(findReplace => {
if (findReplace) {
findReplace.activate().then(() => {
findReplace.replaceAll('text to find', 'text to replace', {
wholeWords: true,
}).then((count) => {
// ...
});
});
} else {
console.error("FindReplace Addon instance not found.");
}
});
Since
9.2.0

Foxit Software Corporation Logo
@2023 Foxit Software Incorporated. All rights reserved.