PDFTron is now Apryse. Same great products, new name.

Undo/Redo and other API improvements With WebViewer 6.0

By Matt Parizeau | 2020 Jan 28

Sanity Image

With WebViewer 6 we've added built in support for undo/redo, annotation status and improved several APIs (among other things). If you're loading CoreControls.js directly it also no longer depends on jQuery which was the last place where jQuery was being used.

Check out all of the new APIs and changes here.

Undo/Redo

WebViewer now provides access to an AnnotationHistoryManager object which allows you to undo and redo recent changes. By default in the UI you can press "ctrl/cmd + z" to undo and "ctrl/cmd + y" to redo.

Programmatically you can use it as follows:

const annotHistoryManager = docViewer.getAnnotationHistoryManager();
annotHistoryManager.undo();

Annotation status

PDF documents allow a status to be associated with comments, for example Accepted, Rejected, etc, and this is now able to be set in WebViewer. The getStatus API will return the current status of the annotation.

Blog image

createDocument API

The CoreControls.createDocument API greatly simplifies the process of creating a document object outside of the default WebViewer UI component. Previously you would need to create a "part retriever" and the Document object, then call loadAsync and now this is all handled by createDocument. Just pass in the URL or blob and any options and it returns a promise that resolves when the Document is loaded.

const licenseKey = 'Insert commercial license key here after purchase';
const doc = await CoreControls.createDocument('/path/file.pdf', { l: licenseKey });
// doc.loadCanvasAsync, doc.loadPageText, etc

And more

As mentioned above CoreControls.js also no longer relies on jQuery, so any APIs that were depending on jQuery have been changed. AnnotationManager's import and exportAnnotations functions have also been changed to be always asynchronous so that potential timing issues could be eliminated. See the migration guide for more details.

For all the changes see the WebViewer 6.0 changelog.

Sanity Image

Matt Parizeau

Share this post

email
linkedIn
twitter