PSPDFKit 2.9 migration guide
This guide covers migrating to PSPDFKit 2.9 for React Native, after a new way was introduced to configure measurements using the MeasurementValueConfiguration
object as part of the PSPDFKitView
component. This configuration object replaces the old setMeasurementScale
and setMeasurementPrecision
APIs, which have now been removed.
If you were using the setMeasurementScale
and setMeasurementPrecision
APIs to set your measurements configuration, this needs to be updated.
For example, this is the old way of setting it:
this.pdfRef.current?.setMeasurementScale({ unitFrom: 'mm', valueFrom: 1.0, unitTo: 'mi', valueTo: 10.0, }); this.pdfRef.current?.setMeasurementPrecision('fourDP');
You now need to set above configuration the following way:
const scale: MeasurementScale = { unitFrom: Measurements.ScaleUnitFrom.MM, valueFrom: 1.0, unitTo: Measurements.ScaleUnitTo.MI, valueTo: 10.0, }; const measurementValueConfig: MeasurementValueConfiguration = { name: 'Custom Scale', scale: scale, precision: Measurements.Precision.FOUR_DP, isSelected: true, }; const configs = [measurementValueConfig]; await this.pdfRef.current?.setMeasurementValueConfigurations(configs);
The MeasurementValueConfiguration
object can also be passed in as part of the Configuration
when creating the PSPDFKitView
component:
<PSPDFKitView ref={this.pdfRef} document={measurementsDocument} configuration={{ iOSBackgroundColor: processColor('lightgrey'), pageMode: 'single', measurementValueConfigurations: [ { name: 'Custom Scale', scale: { unitFrom: Measurements.ScaleUnitFrom.INCH, valueFrom: 1.0, unitTo: Measurements.ScaleUnitTo.CM, valueTo: 3.0, }, precision: Measurements.Precision.TWO_DP, }, ], }} fragmentTag="PDF1" style={styles.pdfColor} />
For more information, refer to the PSPDFKit 2.9 for React Native changelog.