In JavaScript, you edit Word documents programmatically with the DOCX Editor add-on for the Apryse Web SDK. It loads a DOCX inside WebViewer and exposes the editor as an API, so your code drives tracked changes, search and replace, and text edits client-side while the document stays open in the browser. No document data leaves the client.
Client-Side, In-Browser DOCX Editing
Client-side editing runs in the browser, with the document open while your code drives the changes underneath. This is where contract redlining, in-app review, and any workflow that needs a person watching the document change live all belong. The DOCX Editor loads the file, your code calls the same editor the interface uses, and edits commit inside the browser session. No document data leaves the client.
Programmatic Editing vs. Browser-Based Editing
Programmatic editing and browser-based editing are not the same thing. Programmatic means your code makes the edits rather than a user typing them. Browser-based means those edits happen client-side, in the open document, with no server round-trip. The DOCX Editor does both at once: a scripted edit against a live, in-browser document in the same session.
Edit DOCX With the Apryse Web SDK DOCX Editor
Setup and Licensing
The DOCX Editor runs inside WebViewer and needs its own add-on license on top of the base Web SDK. It does not support mobile browsers. Every post-load call runs inside the documentLoaded handler on the WebViewer constructor promise.
Tracked Changes With TrackedChangeManager
Tracked changes go through the tracked changes API, TrackedChangeManager. Get a manager after the documentLoaded event fires, then accept, reject, or navigate to a change by ID.
Accept and Reject Tracked Changes
Navigate to and Retrieve Changes
Each tracked change carries a numeric ID, so your code acts on a specific change instead of the whole document. Use getTrackedChanges() to read the pending set and moveCursorToTrackedChange(id) to jump to one. The batch acceptTrackedChanges(ids) and rejectTrackedChanges(ids) methods resolve several changes in a single call.
Search and Replace
Search and replace works as a UI panel and as a programmatic API inside the DOCX Editor. Use it to automate placeholder replacement and bulk text corrections. See the search and replace guide for the method reference and setup steps.
Programmatic Text Editing
The DOCX Editor also edits text programmatically against a document open in the browser, with no user typing.
Insert, Delete, and Replace Text
Insert, delete, and replace text through the API to populate placeholders, apply a redline, or normalize boilerplate in one scripted pass. These calls run after the documentLoaded event fires.
Cursor and Selection Control
Drive the cursor and selection from code through the editor's text navigation APIs. A scripted edit then lands at the exact position you set in the open document.
What the DOCX Editor Supports
The DOCX Editor edits and styles text (font, size, color, bold, italic, underline, strikethrough) and formats headings, paragraphs, alignment, and bulleted and numbered lists. It inserts and edits tables, headers, footers, and images, and keeps structure and formatting when you paste content from another source. Track changes, search and replace, programmatic text editing, undo, redo, and comments are all included. It reads IME composition input for Chinese, Japanese, and Korean, opens existing DOCX files, and creates new ones from blank. The UI meets WCAG 2.2 Level AA, inherited from WebViewer.
Some features are not available yet. Page numbers, table of contents, revision history, simultaneous co-editing, superscript and subscript, and mobile browsers fall outside the current capability set.
When to Use the DOCX Editor
Use the Apryse Web SDK DOCX Editor when you need to edit an existing DOCX in the browser with code. Contract redlining, in-app document review, and scripted edits to a live document all fit, and the file stays on the client throughout. One API covers tracked changes, search and replace, and text editing. It runs on any JavaScript framework that mounts to a DOM element, including React, Angular, and Vue.
Frequently Asked Questions
Yes, with the DOCX Editor add-on for the Apryse Web SDK. It runs inside WebViewer and exposes tracked changes, search and replace, and text editing through an API, entirely client-side.
Use the TrackedChangeManager API. After the documentLoaded event fires, get a manager from the office editor, read the tracked changes, and call acceptTrackedChange(id) or rejectTrackedChange(id) on a change by ID. Batch methods resolve several changes at once.
No. The DOCX Editor does not run on mobile browsers. WebViewer views Office files on mobile, but editing is desktop-browser only.
Start Building
Install WebViewer through npm: npm i @pdftron/webviewer. Add the DOCX Editor add-on to your Web SDK license, then generate a free trial key. The trial key opens every DOCX Editor capability above, so you can test tracked changes, search and replace, and programmatic text editing against your own files before you commit. For framework setup, follow the React, Angular, or Vue guides.
