Nutrient React Native SDK 2.16 migration guide

This guide covers migrating to Nutrient React Native SDK 2.16. The most notable change is that the behavior of the annotations APIs has been updated with the addition of the applyInstantJSON API.

Adding annotations

In previous versions, the addAnnotations API was used to add Document JSON to the current document:

const annotationJSON = {
	annotations: [
		{
			// Annotation in Instant JSON format.
		},
	],
	format: 'https://pspdfkit.com/instant-json/v1',
};

const result = await this.pdfRef.current
	?.getDocument()
	.addAnnotations(annotationJSON);

Going forward, the addAnnotations API will be used to add an array of typed annotations in Instant JSON format to the current document:

const inkAnnotation: InkAnnotation = new InkAnnotation({
	// Annotation properties.
});

const result = await this.pdfRef.current
	?.getDocument()
	.addAnnotations([inkAnnotation]);

To apply more complex annotations — such as image annotations, which include attachments — use Document JSON in conjunction with the applyInstantJSON API:

const documentJSON: DocumentJSON = {
	annotations: [
		{
			// Annotation in Instant JSON format.
		},
	],
	format: 'https://pspdfkit.com/instant-json/v1',
	attachments: {
		'492adff9842bff7dcb81a20950870be8a0bb665c8d48175680c1e5e1070243ff': {
			binary: 'base64-image-data',
			contentType: 'image/png',
		},
	},
};

const result = await this.pdfRef.current
	?.getDocument()
	.applyInstantJSON(documentJSON);

Maven dependency

After rebranding to Nutrient, our Maven dependency URL also changed. In your application’s build.gradle file found inside the android directory, apply the following update:

allprojects {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        maven {
-            url 'https://my.pspdfkit.com/maven/'
+            url 'https://my.nutrient.io/maven/'
        }
    }
}

For more information, refer to the Nutrient React Native SDK 2.16 changelog.