Installing via npm in Your Project
For easy integration, the Document Authoring TypeScript library is available via the npm registry.
Requirements
-
A package manager compatible with npm. This guide contains examples for Yarn, pnpm, the npm CLI, and Bun. The npm CLI is installed with Node.js by default.
You need Node.js to complete this guide, but in general, Node.js isn’t a requirement for using the Document Authoring library.
Type Definitions and Module Systems
We provide type definitions and support for CommonJS, ESM, AMD, and a global DocAuth
object from the same package. These should be resolved automatically from our package.json
file.
Adding to Your Project
npm install @pspdfkit/document-authoring
yarn add @pspdfkit/document-authoring
pnpm add @pspdfkit/document-authoring
bun add @pspdfkit/document-authoring
Integrating into Your Project
-
Add an empty
<div>
element with aposition
set to a value other thanstatic
, and with a definedwidth
andheight
. This will be the target DOM element where the editor will be loaded:
<div id="editor" style="position: relative; width: 100%; height: 100vh; border: 1px solid #dcdcdc;"></div>
-
Import
@pspdfkit/document-authoring
into your application and initialize the editor:
import DocAuth from '@pspdfkit/document-authoring'; const docAuthSystem = await DocAuth.createDocAuthSystem(); const editor = await docAuthSystem.createEditor(document.getElementById('editor'), { document: await docAuthSystem.createDocumentFromPlaintext('Hi there!'), });
This is all you need to get started in an existing project.