Migrating from MuPDF to ComPDFKit PDF SDK

Tutorials | Migrate · Alternative · Android Fri. 05 Jan. 2024

MuPDF is a versatile and efficient document rendering library known for its lightweight design and broad file format support. However, there are some reasons leading users to migrate from MuPDF to other alternatives, for example, MuPDF only supports simple features to edit PDFs. This article is going to provide an in-depth introduction to MuPDF, explain why some people are migrating from MuPDF to ComPDFKit, and highlight the benefits of using ComPDFKit to replace MuPDF.

 

What Is MuPDF

MuPDF comprises a software library, command line tools, and platform-specific viewers, with the SDK available for commercial licensing through Artifex or under the AGPL for open-source applications. Operating across diverse systems such as Android, iOS, Windows, macOS, Linux, and Unix-like platforms, MuPDF also offers language bindings for Java, C++, and Python, along with the development of Web Viewers powered by WebAssembly.

 

Reasons for Replacing from MuPDF

MuPDF users report a number of limitations that motivate them to look for alternatives to MuPDF. Here is a list of the key concerns users mentioned:

 

    - Limited Editing Options: Its current capabilities fall short of some basic PDF functions such as text highlighting, advanced editing features, zooming, etc., impacting the overall utility as a PDF editor.

    - Poor User Interface: Users express dissatisfaction with the interface, calling for more viewing options such as a toolbar for zooming and the ability to view multiple pages at once.

    - Performance Issues: Users experience occasional unresponsiveness, resulting in program hang-ups that require manual closure and reopening. Lagging is also observed when handling multiple PDFs or engaging in editing tasks.

 

It is evident that MuPDF lacks numerous essential PDF features and presents significant potential for performance improvement, which can explain why users need a MuPDF alternative. ComPDFKit is a more powerful PDF SDK that helps build a feature-rich PDF viewer and editor.

 

Advantages of Migrating MuPDF to ComPDFKit

ComPDFKit not only addresses the deficiencies of MuPDF but also offers comprehensive technical support, empowering developers to quickly migrate from MuPDF and seamlessly integrate advanced PDF features into their applications, thereby enhancing the overall user experience.

 

    - Comprehensive PDF Features: More than just the fundamental viewing and annotating features, ComPDFKit designs other commonly-used functions, including signatures, form filling, security, content editing, conversion, comparing PDFs, etc. To learn more, please visit our feature list.

    - Swift Integration: It only requires a few lines of code to quickly migrate from MuPDF and seamlessly integrate ComPDFKit PDF SDK into your applications, which not only accelerates the development process but also contributes to cost savings. 

    - Customized UI: ComPDFKit allows developers to customize the UI to meet specific user preferences, enhancing usability and ensuring that your PDF editor matches users' unique needs and preferences. 

    - High-quality Technical Support: ComPDFKit offers robust technical support with demo videos, documentation, and blogs for troubleshooting and PDF editor development. Our R&D team provides diverse assistance through one-to-one voice and video calls.

    - Price Support for Startups: ComPDFKit offers affordable, cost-effective special community licenses for individual developers, startups, and more to help them develop powerful PDF viewer & editor.

 

How to Migrate from MuPDF to ComPDFKit

The following steps will help you migrate an existing MuPDF project to ComPDFKit PDF SDK.

 

Step 1: Integrate With Gradle

 

1. Open the settings.gradle file located in your project's root directory and add the mavenCentral repository:

 

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
+       mavenCentral()
    }
}

 

2. Open the build .gradle file in the application module directory

 

3. Edit it and add the complete ComPDFKit SDK dependency:

 

dependencies {
  implementation 'com.compdf:compdfkit:1.10.0'
  implementation 'com.compdf:compdfkit-ui:1.10.0'
}

 

4. Apply for read and write permissions in AndroidManifest.xml:

 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

 

Note: On your apps that target Android 6.0 or higher, make sure to check for and request read and write permissions to external storage at runtime.

 

Step 2: Integrate Manually

1. Copy "ComPDFKit.aar" and "ComPDFKit-UI.aar" to the "libs" directory of the app.

 

2. Add the following code into the app dictionary's "build.gradle" file:

 

...
dependencies {
    /*ComPDFKit SDK*/
    implementation(fileTree('libs'))
    ...
}
...

 

3. Add ComPDFKit PDF SDK for Android as a dependency to the project. Inside the app dictionary's "build.gradle", add "ComPDFKit.aar", "ComPDFKit-UI.aar", and the related support libraries to the dependencies. For simplicity, update the dependencies as follows:

 

dependencies {
    ...
    //glide
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

    implementation 'androidx.documentfile:documentfile:1.0.1'
}

 

4. Apply for read and write permissions in AndroidManifest.xml:

 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

 

Note: On your apps that target Android 6.0 or higher, make sure to check for and request read and write permissions to external storage at runtime.

 

Step 3: Apply the License Key

Contact ComPDFKit's sales team to get a license for free to test this project. Add this license in the AndroidManifest.xml of the main module:

 

<meta-data
    android:name="compdfkit_key"
    android:value="{your ComPDFKit key}" />
<meta-data
    android:name="compdfkit_secret"
    android:value="{your ComPDFKit secret}" />

 

Step 4: Add Proguard Rules

In the proguard-rules.pro file, please add the obfuscation configuration information for compdfkit as follows:

 

-keep class com.compdfkit.ui.** {*;}
-keep class com.compdfkit.core.** {*;}

 

Conclusion

 

ComPDFKit is a powerful MuPDF alternative that provides more PDF features and customizable UI. With our comprehensive documentation and dedicated support team, developers can easily and quickly migrate from MuPDF to ComPDFKit PDF SDK. In addition to MuPDF, ComPDFKit can also help you migrate from any other libraries. If you want to learn how ComPDFKit performs, welcome to contact us for a free trial.

 

Ready to Get Started?

Download our all-in-one ComPDFKit for free and run it to your project within minutes!