COMING SOON: Fall 2024 Release

How to View DOCX in an Angular Web App

By Apryse | 2024 Oct 15

Sanity Image
Read time

2 min

Looking for an Angular DOCX viewer?

This blog describes how to view Microsoft Office documents in an Angular file viewer app using Apryse’s WebViewer. This includes Microsoft Word, Excel, and PowerPoint formats as well as the legacy formats such as DOC, XLS, and PPT. 

With just a few lines of code, you can view files client-side, without server dependencies, Microsoft Office licenses, or third-party software. The Apryse WebViewer directly converts DOCX, XLSX, and PPTX files using JavaScript, and renders them for viewing dynamically.

You can also try our office demo to test your files in WebViewer.

View our full Angular doc viewer demo on GitHub, or visit the documentation for get-started steps and further information on additional functionality. 

Additional Functionality 

WebViewer supports more than simply viewing Office documents - you can also edit DOCX files - as well as being able to annotate, mail merge on DOCX templates, edit PDF content, manipulate pages, apply redactions, create and fill forms filling, and much more.

WebViewer also supports formats like PDF, images, videos, and CAD documents. 

How to View DOCX in an Angular Web App

Copied to clipboard

Step 1 - Get Started

For the purposes of this article, we'll assume that you followed the steps of the Getting Started with Angular guide (or just cloned the GitHub. repo). If that is the case, then you will already have a PDF viewer running in your browser.

Step 2 - Specify the DOCX file to be opened

Make sure that the DOCX file is somewhere accessible, then pass the URL, blob, file path, or arrayBuffer to initialDoc property in the WebViewer constructor. 

WebViewer({
  ...,
  initialDoc: 'https://myserver.com/myfile.docx',
}, this.viewer.nativeElement)

Alternatively, you can also call loadDocument with the same parameters once WebViewer has loaded.

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

Step 3 - Run the App

If you hadn't already started the app then do so now using 'npm start'.

View the app, by navigating to http://localhost:4200/.

A DOCX file being shown in the Angular WebViewer app

You can now see the DOCX file within the viewer.

The app automatically reloads if you change any source files.

A Customizable UI

Copied to clipboard

WebViewer comes with a rich set of APIs to customize the UI. For an idea of the vast possibilities, check out the UI customization guide - and the new Modular UI options. Alternatively you can create your own UI by referencing our open-source UI code.

Conclusion

Copied to clipboard

The process to add Office document viewing and collaboration to your Angular file browser app is straightforward using the Apryse WebViewer, a JavaScript-based MS Office SDK.

See for yourself. Try out Apryse features using your own documents with the interactive demo with Apryse showcase.

Have any questions about Apryse’s SDK or WebViewer? Start a chat on Discord with our solutions engineers or reach out to our sales team for a personalized demo.

Sanity Image

Apryse

Share this post

email
linkedIn
twitter