How can I create a bookmark from an outline element

Q: How can I create a bookmark from an outline element?

A: A way to achieve it is to manually “turn” an outline element into a bookmark using our getDocumentOutline() and instance.create API

const outlineElements = await instance.getDocumentOutline();
const outlines = outlineElements.toJS();

const bookmark = new PSPDFKit.Bookmark({
  name: outlines[0].title,
  action: new PSPDFKit.Actions.GoToAction(outlines[0].action)
});

instance.create(bookmark);

This has been tested with PSPDFKit for Web 2021.2.0.