Raster Image Export#

An application developer can export a document’s pages into raster image formats by invoking the MuPDF library directly, opening the document and processing the resulting pages into a raster image file sequence.

Loading MuPDF without a UI#

To load the MuPDF library and use it directly an application developer should import SODKLib and request a document load as follows:

import com.artifex.solib.*

fun loadDocument(
        activity: Activity,
        path: String
    ) {
    // use the registered configuration options of the application as
    // the document configuration options
    val docCfg = ArDkLib.getAppConfigOptions()

    val lib = ArDkUtils.getLibraryForPath(activity, path)

    // Load the document
    val doc:ArDkDoc = lib.openDocument(path, object : SODocLoadListener {
        override fun onPageLoad(pageNum: Int) {

        }

        override fun onDocComplete() {
            // see sample app
            val pngTask = GeneratePngsTask()
            pngTask.execute(null as Void?)
        }

        override fun onError(error: Int, errorNum: Int) {
            // Called when the document load fails
        }

        override fun onSelectionChanged(
            startPage: Int,
            endPage: Int
        ) {
            // Called when the selection changes
        }

        override fun onLayoutCompleted() {
            // Called when a core layout is done
        }
    }, activity, docCfg)
}


private class GeneratePngsTask : AsyncTask<Void, Void, Boolean>() {
    // see sample app
    override fun doInBackground(vararg p0: Void?): Boolean {

    }
}

By using the document load listeners an application developer should be able use a background task to process document pages as required and use the createBitmapForPath method of the SODKLib to export pages in bitmap format.

See the Android Sample app and the ExportFileAsPng class to reference a full example.


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