Nutrient 10.6 migration guide
This guide outlines the changes to Nutrient Android SDK 10.6.
AI Assistant
New AI Assistant API
Nutrient 10.6 introduces a new, streamlined AI Assistant API that replaces the previous standaloneAiAssistant
method.
Creating AI Assistant instances
val documentDescriptors = assetFiles.map { DocumentDescriptor.fromDataProviders(listOf(AssetDataProvider(it)), listOf(), listOf())}
val assistant = createAiAssistant( context = this, documentsDescriptors = documentDescriptors, ipAddress = "your-server-ip", sessionId = "your-session-id", jwtToken = { documentIds -> generateJwtToken( context = this, claims = mapOf( "document_ids" to documentIds, "session_ids" to listOf("your-session-id"), "request_limit" to mapOf( "requests" to 160, "time_period_s" to 600000 ) ) ) })
AiAssistantProvider interface
AI Assistant now requires implementing the AiAssistantProvider
interface in your Activity:
class YourActivity : AppCompatActivity(), AiAssistantProvider { override fun getAiAssistant(): AiAssistant { return assistant }
// Optional: Implement navigation callback for multi-document support. override fun navigateTo( documentRect: List<RectF>, pageIndex: Int, documentIndex: Int ) { // Handle navigation to specific document, page, and highlight rectangles. }}
Multi-document support
AI Assistant now supports multiple documents simultaneously:
val assetFiles = listOf("document1.pdf", "document2.pdf", "document3.pdf")val documentDescriptors = assetFiles.map { DocumentDescriptor.fromDataProviders(listOf(AssetDataProvider(it)), listOf(), listOf())}
val assistant = createAiAssistant( context = this, documentsDescriptors = documentDescriptors, // Multiple documents ipAddress = "your-server-ip", sessionId = "your-session-id", jwtToken = { documentIds -> /* generate JWT */ })
Programmatic AI Assistant display
You can now show the AI Assistant dialog programmatically:
import com.pspdfkit.ai.showAiAssistant
// Show AI Assistant dialog.showAiAssistant(context)
Initialization improvements
Simplified initialization control with session history options:
// Initialize with session history (default).aiAssistant.initialize(withSessionHistory = true)
AI Migration checklist
- Update AI Assistant creation — Replace
standaloneAiAssistant
withcreateAiAssistant
. - Implement AiAssistantProvider — Add the interface to your Activity.
- Update JWT generation — Use the new Lambda-based JSON Web Token (JWT) generation.
- Update initialization — Use the new
initialize
method with session history control. - Consider multi-document support — Update your implementation to support multiple documents if needed.
Breaking API
Immersive mode
The immersive mode option previously defaulted to false
but is now true
. If you experience layout issues, set the immersive mode option to false
in the PdfActivityConfiguration
.
Outline view width
PdfOutlineView
used to have a fixed width of 480 dp. Starting with version 10.6, this width is customized with the pspdf__width
dimension attribute in the pspdf__OutlineView
styleable. If this isn’t set, the width will be set to the parent view width, which usually means it covers the width of the screen. If you set the width to be wider than the parent, it’ll be overridden as the parent. If you want a custom width in landscape mode or on a tablet, set the value to your desired width.
For more information, refer to the changelog.