Open PDFs from an ArrayBuffer Using JavaScript
PSPDFKit for Web in Standalone mode accepts different input data types for a document: either as the document URL string, or as an ArrayBuffer
containing the document file. Just set it in the document
property of the PSPDFKit.Configuration
object passed to PSPDFKit.load()
:
PSPDFKit.load({ document: myDocumentArrayBuffer });
The ArrayBuffer
can be constructed from a file in any of the different supported input formats.
It’s also possible to set the initial conditions of the viewer in the same configuration object by setting the initialViewState
property. For example, if you want to open a document on page 8 with the thumbnails sidebar open, you can do it like this:
PSPDFKit.load({ document: myDocumentArrayBuffer, initialViewState: new PSPDFKit.ViewState({ pageIndex: 8, sidebarMode: PSPDFKit.SidebarMode.THUMBNAILS }) });
Loading Options
You can open files in any of the supported file formats: PDF, JPEG, PNG, and TIFF (for both Standalone and Server-Backed deployments) and Office files (for Server-Backed deployments only).
PSPDFKit.load()
also accepts different configuration options:
-
customFonts
(Standalone only) -
disableWebAssembly
(Standalone only) -
disableWebAssemblyStreaming
(Standalone only) -
document
(Standalone only) -
enableAutomaticLinkExtraction
(Standalone only) -
instantJSON
(Standalone only) -
licenseKey
(Standalone only) -
overrideMemoryLimit
(Standalone only) -
standaloneInstancesPoolSize
(Standalone only) -
trustedCAsCallback
(Standalone only) -
XFDF
(Standalone only) -
XFDFKeepCurrentAnnotations
(Standalone only)
Example:
PSPDFKit.load({ container, document: documentUrl, toolbarItems: PSPDFKit.defaultToolbarItems.filter(item => item.type !== "print"), initialViewState: new PSPDFKit.ViewState({ sidebarMode: PSPDFKit.SidebarMode.THUMBNAILS }) })