Class BackgroundTextExtractor
- java.lang.Object
-
- org.faceless.pdf2.viewer2.ViewerFeature
-
- org.faceless.pdf2.viewer2.feature.BackgroundTextExtractor
-
- All Implemented Interfaces:
DocumentPanelListener
,PDFBackgroundTask
public class BackgroundTextExtractor extends ViewerFeature implements DocumentPanelListener, PDFBackgroundTask
This feature will cause text to be extracted automatically when a PDF is loaded by the viewer. A background thread will be started and run at low priority - early extraction like this means that other features that depend on text extraction (searching, selecting text matching a certain pattern and a "select all" on text - ie
SearchPanel
andTextTool
) will not have to run the extraction on demand and so should feel noticably faster to the user.Note this feature is not enabled by default - it must be explicitly selected
The name of this feature is BackgroundTextExtractorThis code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.
- Since:
- 2.11.7
-
-
Constructor Summary
Constructors Constructor Description BackgroundTextExtractor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
documentUpdated(DocumentPanelEvent event)
Called when anDocumentPanelEvent
is raisedvoid
extract(DocumentPanel docpanel)
This method is run by this feature when a new DocumentPanel is loaded.void
initialize(PDFViewer viewer)
Called when the feature is first added to a viewerboolean
isEnabledByDefault()
Return true if this feature is enabled by default (the default).boolean
isPaused()
Return true if the task has been paused with thePDFBackgroundTask.pause()
methodboolean
isRunning()
Returns true if the task is still runningvoid
pause()
Pause the task until thePDFBackgroundTask.unpause()
method is called.void
startExtraction(DocumentPanel docpanel)
Start a background thread to run theextract(org.faceless.pdf2.viewer2.DocumentPanel)
methodvoid
unpause()
Unpause the task after a call toPDFBackgroundTask.pause()
-
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, setFeatureName, teardown, toString
-
-
-
-
Method Detail
-
initialize
public void initialize(PDFViewer viewer)
Description copied from class:ViewerFeature
Called when the feature is first added to a viewer- Overrides:
initialize
in classViewerFeature
-
isEnabledByDefault
public boolean isEnabledByDefault()
Description copied from class:ViewerFeature
Return true if this feature is enabled by default (the default). Disabled features are excluded from the list returned byViewerFeature.getAllEnabledFeatures()
and byPDFTool
- Overrides:
isEnabledByDefault
in classViewerFeature
-
documentUpdated
public void documentUpdated(DocumentPanelEvent event)
Description copied from interface:DocumentPanelListener
Called when anDocumentPanelEvent
is raised- Specified by:
documentUpdated
in interfaceDocumentPanelListener
-
isPaused
public boolean isPaused()
Description copied from interface:PDFBackgroundTask
Return true if the task has been paused with thePDFBackgroundTask.pause()
method- Specified by:
isPaused
in interfacePDFBackgroundTask
-
isRunning
public boolean isRunning()
Description copied from interface:PDFBackgroundTask
Returns true if the task is still running- Specified by:
isRunning
in interfacePDFBackgroundTask
-
pause
public void pause()
Description copied from interface:PDFBackgroundTask
Pause the task until thePDFBackgroundTask.unpause()
method is called. This method waits until the task has actually paused.- Specified by:
pause
in interfacePDFBackgroundTask
-
unpause
public void unpause()
Description copied from interface:PDFBackgroundTask
Unpause the task after a call toPDFBackgroundTask.pause()
- Specified by:
unpause
in interfacePDFBackgroundTask
-
startExtraction
public void startExtraction(DocumentPanel docpanel)
Start a background thread to run theextract(org.faceless.pdf2.viewer2.DocumentPanel)
method- Parameters:
docpanel
- the DocumentPanel
-
extract
public void extract(DocumentPanel docpanel)
This method is run by this feature when a new DocumentPanel is loaded. If the feature is not used, it could also be called externally to start background extraction for the specified panel.- Parameters:
docpanel
- the DocumentPanel
-
-