2021.6 release notes
With PSPDFKit for Web 2021.6, we removed a handful of APIs that have been deprecated since 2020.5.0. This update:
- Removes
Instance#createAnnotation,Instance#createBookmark, andInstance#createFormFieldin favor ofInstance#create. - Removes
Instance#saveAnnotations,Instance#saveBookmarks,Instance#saveComments,Instance#saveFormFields, andInstance#saveFormFieldValuesin favor ofsave. - Removes
Instance#updateAnnotation,Instance#updateBookmark, andInstance#updateFormFieldin favor ofInstance#update. - Removes
Instance#deleteAnnotations,Instance#deletebookmark, andInstance#deleteFormFieldin favor ofInstance#delete. - Removes
Instance#ensureAnnotationSaved,Instance#ensureBookmarkSaved, andInstance#ensureFormFieldSavedin favor ofInstance#ensureChangesSaved. - Removes
Instance#hasUnsavedAnnotations,Instance#hasUnsavedBookmarks,Instance#hasUnsavedComments,Instance#hasUnsavedFormFieldValues, andInstance#hasUnsavedFormFieldsin favor ofInstance#hasUnsavedChanges.
Note that some of these deprecated APIs returned a single result, but the new API will always return an array. Make sure any of your code that relied on this behavior accesses the first element in the array.
Below is an example of how to use the new Instance#update API with a single annotation:
instance.update([annotation]).then((annotations) => { const savedAnnotation = annotations[0];});If you used to call Instance#createAnnotation to create a widget, and then attached it to a form using Instance#createFormField, you’ll now need to create the form field first.
You’ll also need to generate and set the widget’s ID using PSPDFKit#generateInstantId so that you can reference the widget from the form field before it’s added to the document.
Here’s an example of how you can do this using the new Instance.html#create API:
const annotation = new NutrientViewer.Annotations.WidgetAnnotation({ id: NutrientViewer.generateInstantId(), pageIndex: 0, formFieldName: "name", boundingBox: new NutrientViewer.Geometry.Rect({ left: 10, top: 20, width: 60, height: 40 })});
const form = new NutrientViewer.FormFields.TextFormField({ name: "name", annotationIds: NutrientViewer.Immutable.List([annotation.id]), label: "A label"});
instance.create([annotation, form]);By default, this makes signatures respect their aspect ratio when being resized by their corner handles. To opt out of this and go back to the old behavior, you can use the new onAnnotationResizeStart callback option:
NutrientViewer.load({ onAnnotationResizeStart: (event) => { if (event.annotation.isSignature && !event.isShiftPressed) { return { maintainAspectRatio: false }; }
return undefined; }});For a full list of changes, check out the changelog.
Migrate PSPDFKit Server
For more information, take a look at the PSPDFKit Server 2021.6 migration guide.