Class ViewerFeature
- java.lang.Object
-
- org.faceless.pdf2.viewer2.ViewerFeature
-
- Direct Known Subclasses:
ActionHandler
,ActiveWindowMenu
,AnnotationComponentFactory
,BackgroundSignatureVerifier
,BackgroundTextExtractor
,CropPage
,DesktopSupport
,DragAndDrop
,EditMenu
,Exporter
,Importer
,MarkupSelectionAction
,Menus
,MultiWindow
,OpenRecent
,RedactSelectionAction
,RemoteControl
,SidePanelFactory
,SignatureCapture
,SignatureProvider
,TextCopyAction
,TextHighlighter
,ThumbnailCopyAction
,ThumbnailCutAction
,ThumbnailDeleteAction
,ThumbnailExtractAction
,ThumbnailPasteAction
,ToolbarDisabling
,ToolbarFloating
,Toolbars
,Undo
,ViewerWidget
,WarningNotifier
public abstract class ViewerFeature extends Object
The ViewerFeature class can be used to control the various features of thePDFViewer
, such as widgets, side panels, annotations and action handlers. Most of the interesting methods are in the subclasses, particularlyViewerWidget
, but thegetAllFeatures()
method is commonly called to return a list of all the features available to the viewer.The list of default features is specified by the
See the viewer tutorial for more detail on how to use this class and the "viewer" package.org.faceless.pdf2.viewer2.ViewerFeature
service provider file. Thebfopdf.jar
file contains this file in theMETA-INF/services
folder, which lists the classnames of each feature to load by default. Each feature specified this way must be a subclass ofViewerFeature
, and contain a zero-parameter constructor or agetInstance()
method that returns a singleton. Additional features may be specified this way in any other Jars available to the application. See the Java Service Provider Interface documentation for more information.This 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.8
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ViewerFeature(String name)
Create a new ViewerFeature
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<ViewerFeature>
getAllEnabledFeatures()
Return a list of all features that return true fromisEnabledByDefault()
.static List<ViewerFeature>
getAllFeatures()
Return a Collection of all the features available, which can be passed to thePDFViewer
constructor or used as a base for your own set of features.String
getCustomJavaScript(String type, String name)
Return any custom JavaScript that needs to be run by this feature on the specified JavaScript event.String
getFeatureProperty(PDFViewer viewer, String key)
Get a custom property for this feature, as specified by the viewer.URL
getFeatureURLProperty(PDFViewer viewer, String key)
Exactly as forgetFeatureProperty()
but returns a URL valueString
getName()
Return the name of this Featurevoid
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).protected void
setFeatureName(String name)
Set the feature name.void
teardown()
Called when the PDFViewer containing this feature is closedString
toString()
-
-
-
Constructor Detail
-
ViewerFeature
protected ViewerFeature(String name)
Create a new ViewerFeature- Parameters:
name
- the name of the feature
-
-
Method Detail
-
getAllFeatures
public static final List<ViewerFeature> getAllFeatures()
Return a Collection of all the features available, which can be passed to thePDFViewer
constructor or used as a base for your own set of features.- See Also:
getAllEnabledFeatures()
-
getAllEnabledFeatures
public static final List<ViewerFeature> getAllEnabledFeatures()
Return a list of all features that return true fromisEnabledByDefault()
.- Since:
- 2.11.7
-
setFeatureName
protected final void setFeatureName(String name)
Set the feature name. This should only be called in the constructor - normally you would set the name by passing it into the constructor, but if you're overriding a feature that doesn't allow you to do this, this method allows you to change it.- Since:
- 2.11.20
-
initialize
public void initialize(PDFViewer viewer)
Called when the feature is first added to a viewer
-
teardown
public void teardown()
Called when the PDFViewer containing this feature is closed- Since:
- 2.11.18
-
isEnabledByDefault
public boolean isEnabledByDefault()
Return true if this feature is enabled by default (the default). Disabled features are excluded from the list returned bygetAllEnabledFeatures()
and byPDFTool
- Since:
- 2.11.7
-
getName
public final String getName()
Return the name of this Feature
-
getCustomJavaScript
public String getCustomJavaScript(String type, String name)
Return any custom JavaScript that needs to be run by this feature on the specified JavaScript event. Unlike JavaScript from the document, this JavaScript will be run outside the security sandbox so will have the same permissions as the application. The default implementation returnsnull
.- Parameters:
type
- the Event type : "App", "Doc" etc.name
- the Event name : "Init", "Open", "WillClose" etc.- Since:
- 2.10.6
-
getFeatureProperty
public final String getFeatureProperty(PDFViewer viewer, String key)
Get a custom property for this feature, as specified by the viewer. This method provides a convenient, standardised way to access properties for a feature at runtime, by querying the
PropertyManager
returned byPDFViewer.getPropertyManager()
. The key is prefixed by the name of this class, and if no value is found the superclass is specified.For example, calling this method from a
KeyStoreSignatureProvider
class asgetFeatureProperty(viewer, "name")
will first check the propertyfeature.KeyStoreSignatureProvider.name
. If no matching value is found,SignatureServiceProvider.name
and thenViewerFeature.name
are checked. Custom subclasses outside theorg.faceless.pdf2.viewer2
package will have their full classnames used - as an example, a subclass ofKeyStoreSignatureProvider
calledcom.mycompany.MyProvider
would checkcom.mycompany.MyProvider.name
first.- Parameters:
viewer
- thePDFViewer
to get the PropertyManager fromkey
- the property key- Since:
- 2.11
-
getFeatureURLProperty
public final URL getFeatureURLProperty(PDFViewer viewer, String key) throws MalformedURLException
Exactly as forgetFeatureProperty()
but returns a URL value- Throws:
MalformedURLException
- Since:
- 2.11.23
-
-