Class ViewerFeature

    • 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 the PDFViewer constructor or used as a base for your own set of features.
        See Also:
        getAllEnabledFeatures()
      • 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 by getAllEnabledFeatures() and by PDFTool
        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 returns null.
        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 by PDFViewer.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 as getFeatureProperty(viewer, "name") will first check the property feature.KeyStoreSignatureProvider.name. If no matching value is found, SignatureServiceProvider.name and then ViewerFeature.name are checked. Custom subclasses outside the org.faceless.pdf2.viewer2 package will have their full classnames used - as an example, a subclass of KeyStoreSignatureProvider called com.mycompany.MyProvider would check com.mycompany.MyProvider.name first.

        Parameters:
        viewer - the PDFViewer to get the PropertyManager from
        key - the property key
        Since:
        2.11