Some test text!
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.
Integrate PDFTron core, tools and collab library as described here .
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"
}
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()
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
PDFTron SDK
COMPANY