Introduction
MuPDF Android App Kit
MuPDF iOS App Kit
Download App Kit

File Operations

There are a number of file operations available against a document, an application developer should only be required to implement these if using the Custom UI.

Save

Saving a document only needs to be invoked if there are changes made to a document. As such an application developer can verify if changes have been made or not and act accordingly.

Kotlin
if (mDocumentView.isDocumentModified()) {
    mDocumentView.save()
}
Java
if (mDocumentView.isDocumentModified()) {
    mDocumentView.save();
}

Save As

When saving a document using this method an application developer must provide a valid path on the file system to save to.

Kotlin
val docPath:String = "<YOUR_DOCUMENT_PATH>"

mDocumentView.saveTo(docPath) { result, err ->
    if (result == SODocSaveListener.SODocSave_Succeeded) { // success

    } else { //  error

    }
}
Java
String docPath = "<YOUR_DOCUMENT_PATH>";

mDocumentView.saveTo(newPath, new SODocSaveListener() {
    @Override
    public void onComplete(int result, int err) {
        if (result == SODocSave_Succeeded) { //  success

        } else { //  error

        }
    }
});

Print

Application developers should call the print() method against the DocumentView instance to open up the print dialog.

Kotlin
mDocumentView.print()
Java
mDocumentView.print();

Searching is invoked from the current document selection or cursor position and can be made forward or backward from this point. Successful searching automatically highlights the next instance of a found String and moves the document selection to that point.

NOTE
Search is case-insensitive.

Kotlin
fun search(text:String, Boolean:forward) {
    if (forward) {
        mDocumentView.searchForward(text)
    } else {
        mDocumentView.searchBackward(text)
    }
}
Java
private void search(String text, forward Boolean) {
    if (forward) {
        mDocumentView.searchForward(text);
    } else {
        mDocumentView.searchBackward(text);
    }
}

Get selected text

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

Kotlin
val selectedText:String? = mDocumentView?.selectedText
Java
String selectedText = mDocumentView.getSelectedText();

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