Document Setup#

Setup#

PDF documents in App Kit are always rendered inside a document view instance. Files which require to instantiate and access document views should reference the following:

import com.artifex.sonui.editor.DocumentView

Your Android Activity should handle the regular Android Activity Lifecycle events and inform any DocumentView instance of the corresponding Activity Events. Additionally Activity Interfaces require to be setup for full App Kit functionality.

For the Custom UI, there are also a set of common document events during the lifecycle of a document. An application developer can set up Listeners to respond to these events as required.

Activity Events#

Other events should be passed through to your DocumentView instance as follows:

public override fun onPause() {
    super.onPause()
    documentView?.onPause()
}

override fun onResume() {
    super.onResume()
    documentView?.onResume()
}

override fun onDestroy() {
    super.onDestroy()
    documentView?.onDestroy()
}

override fun onBackPressed() {
    documentView?.onBackPressed()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    documentView?.onActivityResult(requestCode, resultCode, data)
}

override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)
    documentView?.onConfigurationChange(newConfig)
}

Note

The above events with their corresponding document view calls are critical for document text editing and selection.

Activity Interfaces#

Security setup#

There are four optional interfaces that can be implemented via your own custom classes in order to define how App Kit manages data security.

Note

There are no defaults for these interfaces.

These interfaces are specifically important when considering a Custom UI approach.

Taken together, your own class implementations following these interfaces can be used to implement security at all the points where a user’s data might flow into, or out of, the application.

SODataLeakHandlers#

An interface that specifies the basis for implementing a class to provide hooks for an app to control file saving and other functions.

SOPersistentStorage#

An interface that specifies the basis for implementing a class allowing for storage/retrieval of key/value pairs.

SOClipboardHandler#

An interface that specifies the basis for implementing a class to handle clipboard actions for the document editor.

SOSecureFS#

An interface that specifies the basis for implementing a class to allow proprietary encrypted files, stored in a secure container. A developer can use this opportunity to enforce security and role restrictions, or map the file operations onto another mechanism, such as a database.

If required, the following code ( with it’s own implementations of these classes ) should be invoked at the start of your app’s main activity as part of your setup.

import com.artifex.solib.*
import com.artifex.sonui.editor.Utilities

public override fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)

    Utilities.setDataLeakHandlers(MyOwnDataLeakHandlers())
    Utilities.setPersistentStorage(MyOwnPersistentStorage())
    ArDkLib.setClipboardHandler(MyOwnClipboardHandler())
    ArDkLib.setSecureFS(MyOwnSecureFS())

    ...
}

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