Document API#

Options#

An application developer can register options for the following in the App Kit SDK:

Property Capability
Editing Enable
Save As Enable
Open In Enable
Sharing Enable
External Clipboard In Enable
External Clipboard Out Enable
Printing Enable
Launch External Url Enable
Form Filling Enable
Form Signing Enable
Redactions Enable
Full Screen Enable
Invert Content In Dark Mode Enable

To do so a developer should instantiate ConfigOptions, set the required variables within that object, and then register it against the SODKLib object.

The following code example disables editing on a document:

import com.artifex.solib.ConfigOptions
import com.artifex.solib.ArDkLib

fun setupConfigOptions() {
    var configOptions:ConfigOptions = ConfigOptions()
    configOptions.isEditingEnabled = false
    ArDkLib.setAppConfigOptions(configOptions)
}

Listeners#

Document listeners should only be required when using the Custom UI as the application developer is responsible for providing their own UI to manage relevant document events.

Available document listeners are as follows:

Page Loaded#

Called when pages are loaded.

Document Completed#

Called when the document has completely loaded.

Password Required#

Called when a password is required by the document.

On View Changed#

Called when the scale, scroll, or selection in the document changes.

documentView.setDocumentListener(object : DocumentListener {
    override fun onPageLoaded(p0: Int) {

    }

    override fun onDocCompleted() {

    }

    override fun onPasswordRequired() {

    }

    override fun onViewChanged(scale: Float,
     scrollX: Int,
     scrollY: Int,
     selectionRect: Rect?) {

    }
}

Document State Listeners#

To setup listeners for when the document has loaded and when document is exited (done()) use the following API:

documentView.setDocStateListener(object : DocStateListener {
    override fun docLoaded() {}
    override fun done() {}
})

Note

Listeners must be added before any invocation of the DocumentView start method.

On Update UI#

Called when UI updates are invoked by DocumentView.

documentView.setOnUpdateUI { }

Page Change#

Called on a page change event - i.e. when the document has scrolled or jumped to another page.

documentView.setPageChangeListener { pageNumber ->

}

Full Screen Mode#

A DocumentView document has the ability to fill the screen and enter a uneditable mode for an optimal reading experience. It is the application developer’s responsibility to turn off the UI that they do not wish to see when this mode is invoked and to ensure that their DocumentView instance fills the device screen. To turn desired UI back on again the DocumentView instance will invoke the application developer’s closure method upon exiting full screen mode ( when the user taps the screen ).

findViewById<View>(R.id.fullScreenButton).setOnClickListener {
    // hide this activity's UI

    // put DocumentView in full screen mode
    if (dv != null) {
        dv.enterFullScreen {
            // closure method to restore our UI upon exit
        }
    }
}

Document Actions#

Providing a Password#

An application developer should provide a way to enter a password for a document and then provide it to the document view as follows:

documentView.providePassword("my-password")

Undo#

To undo a previous action (such as adding an annotation) use the the following method against your document instance.

if (documentView.canUndo()) {
    documentView.undo()
}

Redo#

To redo a previous action (such as adding an annotation) use the the following method against your document instance.

if (documentView.canRedo()) {
    documentView.redo()
}

Get Selected Text#

To get the selected text from a document an application developer should request the selectedText property against the DocumentView instance.

val selectedText:String? = documentView.selectedText

Note

If there is no selected text in the document then a null value will be returned.

Can Select#

To query whether you are able to select objects in a document ( i.e. if the document is in read-only mode or not ) then use the following:

val canSelect:Boolean = documentView.canSelect()

This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at artifex.com or contact Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, CA 94129, USA, for further information.Discord logo