PSPDFKit for Web 2018.2 migration insights
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, 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:
const buffer = await instance.renderCover({ width: 400 });// becomesconst buffer = await instance.renderPageAsArrayBuffer({ width: 400 }, 0);instance.renderCover({ width: 400 }).then(function(buffer) { console.log(buffer);});// becomesinstance.renderPageAsArrayBuffer({ width: 400 }, 0).then(function(buffer) { console.log(buffer);});const buffer = await instance.renderCover({ width: 400 }, 2);// becomesconst buffer = await instance.renderPageAsArrayBuffer({ width: 400 }, 2);instance.renderCover({ width: 400 }, 2).then(function(buffer) { console.log(buffer);});// becomesinstance.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.