Overview

MuPDF App Kit libraries enable quick and easy PDF document viewing and editing for Android and iOS platforms.

This guide demonstrates how our Drop-in UI solution allows you to get up and running with minimal coding effort.

NOTE
The Drop-in UI connects with the native file browser on your Android and iOS platforms for ease of integration and to enable the best possible document management experience.

Setup & integration

  1. Embed the App Kit libraries into your project folder:
  2. Set the minimum Android SDK level in your Gradle file:
  3. android {
        defaultConfig {
            minSdkVersion 23
            ...
        }
        ...
    }
  4. Reference the following dependencies in your Gradle file:
  5. dependencies {
        ...
        // Dependency on view binding
        implementation 'androidx.databinding:viewbinding:7.1.2'
        // Dependency on navigation fragments
        implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
        implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
    
        // Dependency on local binaries
        implementation fileTree(dir: 'libs', include: ['*.aar'])
    }
    
  6. Include the default UI activity in your AndroidManifest.xml as follows:

    <activity android:name="com.artifex.sonui.editor.default_ui.DefaultUIActivity"
        android:exported="true"
        android:configChanges="orientation|keyboard|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode"
        android:screenOrientation="fullSensor"
        android:theme="@style/sodk_editor_mui_theme">
    </activity>
  7. Import the default UI activity into your application code:
  8. 
    import com.artifex.sonui.editor.default_ui.DefaultUIActivity
    
    
  9. Instantiate the App Kit DefaultUIActivity with data representing your file URI and start the activity:
  10. Kotlin

    val defaultUI = Intent(this, DefaultUIActivity::class.java).apply {
        this.action = Intent.ACTION_VIEW
        this.data = uri
    }
    
    startActivity(defaultUI)

    Java

    Intent defaultUI = new Intent(this, DefaultUIActivity.class);
    defaultUI.setAction(Intent.ACTION_VIEW);
    defaultUI.setData(uri);
    
    startActivity(defaultUI);

    NOTE
    If you send null for the data uri value then the system file browser will open, whereby you can select a file to view

  1. Embed the App Kit frameworks into your Xcode project:
  2. Import the frameworks into your application code:
  3. Swift

    import mupdfdk
    import mupdf_default_ui
    

    Objective C

    #import "mupdfdk/mupdfdk.h"
    #import "mupdf_default_ui/mupdf_default_ui.h"
    
  4. Instantiate the App Kit DefaultUIViewController with your document URL and push it to your navigation controller:
  5. Swift

    if let vc = DefaultUIViewController.viewController(url: url) {
        vc.modalPresentationStyle = .fullScreen
        self.navigationController?.pushViewController(vc, animated: true)
    }
    

    Objective C

    DefaultUIViewController *vc = [DefaultUIViewController viewControllerWithURL:url];
    if (vc != nil) {
        [self.navigationController pushViewController:vc animated:YES];
    }
    

Customization

If you wish to build your own UI for file viewing then you should integrate your application code with the App Kit API.