Some test text!

Loading...
Guides
Android pre-built Real-time Collaboration

Android pre-built Real-time Collaboration

PDFTron offers a pre-built collaboration solution for document collaboration. It includes a server module and multiple client modules that allow you to rapidly implement a real-time collaboration system into any cross-platform application. This article will focus on the Android client module.

Prerequisites

  • Minimum API: 21
  • Java 8

Integration

  1. Integrate PDFTron core, tools and collab library as described here .

  2. In your app module's build.gradle file (usually app/build.gradle), set the minSdkVersion to 21+ and enable compatibility for Java 8 features. Then, add the dependency for PDFTron's collaboration package:

    android {
        defaultConfig {
            minSdkVersion 21
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    
    dependencies {
        implementation "com.pdftron:collab-client:2.0.0"
    }

Connecting to the server module

After the server module is setup, we can connect the client package to the server:

mCollabClient = CollabClient.Builder()
    .url("http://yourIPv4:3000")
    .subscriptionUrl("ws://yourIPv4:3000/subscribe")
    .build()

Logging in and view documents

Subscribe to the TabHostListener event in the collaboration viewer, and in the onTabDocumentLoaded event, do:

CoroutineScope(Job() + Dispatchers.IO).launch {

    var user = mCollabClient.getUserSession()
    if (user == null) {
        user = mCollabClient.loginAnonymous("your_user_name")
    }
    val documentId = "your_document_id"
    var document = user?.getDocument(documentId)
    if (document == null) {
        Log.d(TAG, "document NOT FOUND, creating a new one")
        document = user?.createDocument(
            documentId,
            "new_collab.pdf",
            true,
            collabManager.annotations
        )
    } else {
        Log.d(TAG, "document FOUND")
    }
    document?.let {
        Log.d(
            TAG,
            "start session: $documentId with user ${user?.collabUser?.userName}"
        )
        it.join()
        it.view()
    }
}

Get the answers you need: Support

Upcoming Webinar: SDK Features Preview and Live Run-Through | July 14, 2022 at 11 am PT

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use