Some test text!

Jun 7 2022

How to View DOCX in a React Web App

by Andrey Safonov

Looking for a React DOCX viewer? This blog will reveal how to view Microsoft Office documents in a React file viewer app using

. This includes Microsoft Word, Excel, and PowerPoint formats and legacy formats like DOC, XLS, and PPT.

In a few lines of code, we'll show how you can view files client-side, with no server dependencies and without Microsoft Office licenses or third-party software. PDFTron’s WebViewer directly converts `DOCX`, `XLSX`, and `PPTX` files using JavaScript and renders them for viewing dynamically.

Try our

to test WebViewer with your files.

Check out the full React doc viewer demo on our

.

Additional Functionality

WebViewer supports more than simply viewing Office documents, offering

,
mail merge
on DOCX templates,
text editing
,
page manipulation
,
redaction
,
form filling and creation
, and much more.

WebViewer also supports formats like PDF, images,

, and
CAD
documents.

How to View DOCX in a React Web App

Step 1 - Get Started

Once the React doc viewer example is up and running,

the URL, blob, file path, or arrayBuffer to `initialDoc` property in WebViewer constructor.

Code Example for React Document Viewer

WebViewer({
  ...,
  initialDoc: 'https://myserver.com/myfile.docx',
}, document.getElementById('viewer'));

You can also call `loadDocument` with the same parameters.

WebViewer(...)
  .then(instance => {
    instance.UI.loadDocument('https://myserver.com/myfile.docx', { filename: 'myfile.docx' });
  });

Step 3 - Run the App

You can now run the app via 'npm start'.

To view the npm React file viewer docx app, navigate to http://localhost:3000/. The app automatically reloads if you change any of the source files.

A Customizable UI

If you want to configure the UI, WebViewer comes with a rich set of APIs. To get an idea of the vast array of possibilities, check out the

. You can also
create your own UI
by referencing our open-source
UI code
.

Conclusion

Adding Office document viewing and collaboration to your native npm React file browser app is straightforward with PDFTron’s WebViewer, a

. Find the source code for this blog post on our
GitHub

You can also check out other capabilities on our

If you have any questions about PDFTron’s SDK or WebViewer, please

.

Related articles

thumbnail

How to Add Accurate PDF to Word, Excel, and PowerPoint Conversion to Any Application

In this article, we take a glimpse at the full PDF-to-Office workflow, and how to help your users to edit effectively in Word, Excel, and PowerPoint with an accurate Office conversion SDK supporting the entire document lifecycle.

thumbnail

How to View DOCX in a React Web App

We explain how to open DOCX, XLSX, and PPTX in a React web app and so much more with PDFTron WebViewer.

thumbnail

How to View, Edit, and Annotate PDFs in Microsoft Teams

This blog shows you how easy it is to add full-fledged PDF document viewer, annotator, and editor to Microsoft Teams as a Teams App using PDFTron's WebViewer sample.

ANDREY SAFONOV

Head of Product

First a developer then a solution engineer. Now a product team leader and dev experience advocate.

Related Products

Share this post

Upcoming Webinar: SDK Features Preview and Live Run-Through | July 14, 2022 at 11 am PT

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use