This example demonstrates how to use proximity search to find phrases or terms within a specified word distance in a document. The user is presented with a pre-filled search query in the search dialog and can execute the search to see highlighted results.
// Viewer instance: Represents the PDF viewer instance used for document rendering and interaction.
var viewer;
// Execute code when the window has fully loaded:
window.onload = async function () {
//DsPdfViewer.LicenseKey = "***key***";
viewer = new DsPdfViewer('#viewer', { restoreViewStateOnLoad: false });
viewer.addDefaultPanels();
var pdf = "/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/wetlands.pdf";
// Open the document and set the zoom mode to 1 (Fit Width):
await viewer.open(pdf);
viewer.zoom = { mode: 1 };
var findOptions = {
Text: 'existence ONEAR(5) "wildlife species"',
MatchCase: true,
Proximity: true,
HighlightAll: true,
WholeWord: true
};
viewer.plugin.floatingSearchBar.then(f => {
f.setOptions(findOptions);
f.show();
});
}