2018.2 Migration Guide

PSPDFKit for Web 2018.2 adds support for Electron, improved APIs, localization for 27 languages, and much more.

If you’re maintaining a Server installation, make sure to check out the 2018.2 Server Migration Guide.

Render Bitmaps

This version deprecates the Instance#renderCover API method in favor of Instance#renderPageAsArrayBuffer, which now works on server deployments too.

In contrast to renderCover, the new method expects a mandatory pageIndex as its second argument.

To migrate, please replace any occurrence of renderCover with Instance#renderPageAsArrayBuffer, and make sure to pass 0 as the pageIndex in the place where you were previously omitting the second argument:

Copy
1
2
3
const buffer = await instance.renderCover({ width: 400 });
// becomes
const buffer = await instance.renderPageAsArrayBuffer({ width: 400 }, 0);
Copy
1
2
3
4
5
6
7
8
9
instance.renderCover({ width: 400 }).then(function(buffer) {
  console.log(buffer);
});
// becomes
instance
  .renderPageAsArrayBuffer({ width: 400 }, 0)
  .then(function(buffer) {
    console.log(buffer);
  });
Copy
1
2
3
const buffer = await instance.renderCover({ width: 400 }, 2);
// becomes
const buffer = await instance.renderPageAsArrayBuffer({ width: 400 }, 2);
Copy
1
2
3
4
5
6
7
8
9
instance.renderCover({ width: 400 }, 2).then(function(buffer) {
  console.log(buffer);
});
// becomes
instance
  .renderPageAsArrayBuffer({ width: 400 }, 2)
  .then(function(buffer) {
    console.log(buffer);
  });

PSPDFKit for Web 2018.2 also introduces Instance#renderPageAsImageURL, which renders a page and returns a URL to the generated image. This method works on standalone and server-based deployments.

For a full list of changes, check out the changelog.