Angular Word viewer tutorial

The image below shows what you’ll be building.
You can see a demo of this feature in action.
Opening and rendering Office documents in the browser
Nutrient Web SDK brings support for Word, Excel, and PowerPoint formats to your application, without you or your users needing any MS Office software, MS Office licenses, or third-party open source software. The technology works by converting an Office document to PDF directly in the browser, and the document is then rendered in our JavaScript viewer.
Unlocking more capabilities with Office-to-PDF conversion
By converting an Office document to PDF using client-side JavaScript, you have the option to support a rich array of additional Office document functionality, such as:
Text editing — Edit text directly in the displayed Office document.
Page manipulation — Organize documents by adding, removing, or rearranging pages.
Annotations — Boost collaboration by adding text highlights, comments, or stamps.
Adding signatures — Draw, type, or upload a signature directly to a Word document.
Setup
Go to your terminal and install the Angular CLI. This will help you get up and running quickly with Angular:
npm install -g @angular/cli
yarn global add @angular/cli
Now, you can check the version of Angular:
ng --version
Add PDF functionality with Angular using Nutrient Web SDK
Nutrient Web SDK is a fast, flexible JavaScript library for rendering and interacting with PDFs entirely in the browser. It requires no server-side rendering and includes features like form filling, dark mode, bookmarks, and responsive design.
Follow the steps below to integrate Nutrient into your Angular app and build a fully functional PDF viewer.
Step 1 — Install the Nutrient viewer
Install the SDK package using your preferred package manager:
npm install @nutrient-sdk/viewer
Then, configure Angular to copy the SDK’s required assets at build time. Open your angular.json
file and add this to the assets
array:
"assets": [ "src/assets", { "glob": "**/*", "input": "./node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib/", "output": "./assets/nutrient-viewer-lib/" }]
This ensures Nutrient’s JavaScript and WebAssembly files are bundled into your app so the SDK can load them when the viewer runs.
Step 2 — Create and configure the PDF viewer
- Use Angular CLI to create a new component:
ng generate component docx-viewer
This creates the component’s HTML, TypeScript, and CSS files in src/app/docx-viewer
.
- In
docx-viewer.component.html
, add a container where the viewer will mount:
<div class="docx-viewer"> <div id="nutrient-container" style="width: 100%; height: 100vh"></div></div>
The #nutrient-container
div is where the SDK will render the PDF viewer UI.
Load and render the PDF
In docx-viewer.component.ts
, initialize the SDK:
import { Component, OnInit } from "@angular/core";import NutrientViewer from "@nutrient-sdk/viewer";
@Component({ selector: "docx-viewer", templateUrl: "./docx-viewer.component.html", styleUrls: ["./docx-viewer.component.css"], standalone: true,})export class PdfViewerComponent implements OnInit { ngOnInit(): void { NutrientViewer.load({ // The SDK loads viewer assets from this base URL. baseUrl: `${location.protocol}//${location.host}/assets/`, // PDF document to load document: "/assets/document.docx", // DOM container where the viewer should be rendered. container: "#nutrient-container", }).then((instance) => { // Optional: expose viewer instance for debugging. (window as any).instance = instance; }); }}
Add the DOC or DOCX file you want to display to the src/assets
directory. You can use our demo document as an example.
Step 3 — Display the viewer in your app
To make the viewer appear, import and use the PdfViewerComponent
in your root component.
In app.component.ts
:
import { Component } from "@angular/core";import { RouterOutlet } from "@angular/router";import { PdfViewerComponent } from "./docx-viewer/docx-viewer.component";
@Component({ selector: "app-root", imports: [RouterOutlet, PdfViewerComponent], templateUrl: "./app.component.html", styleUrls: ["./app.component.css"],})export class AppComponent { title = "angular";}
In app.component.html
:
<docx-viewer></docx-viewer>
This mounts your PDF viewer on the page using Angular’s component system.
Step 4 — Run the application
Start your Angular app with:
npm run dev
Navigate to http://localhost:4200
and you’ll see your PDF rendered inside the Nutrient viewer. The UI includes zoom, navigation, full-text search, annotation tools, and more — all ready to use.
A note about fonts
When you convert an Office document with custom fonts to a PDF, Nutrient Web SDK might not have access to these fonts due to licensing constraints. In this case, Nutrient typically replaces unavailable fonts with their equivalents — like Arial with Noto.
Adding even more capabilities
Once you’ve deployed your viewer, you can start customizing it to meet your specific requirements or easily add more capabilities. To help you get started, here are some of our most popular Angular guides:
- Instant synchronizationp
- Document assembly
- Page manipulation
- Editor
- Forms
- Signatures
- Redaction
- Document security
Conclusion
In this blog post, you learned how to build a Word viewer using Angular with the Nutrient SDK. It also discussed the benefits of using Nutrient Web SDK to render Office documents in the browser. If you hit any snags, don’t hesitate to reach out to our Support team for help.
You can also integrate our Angular Word viewer using web frameworks like Vue.js and React.js. To see a list of all web frameworks, start your free trial. Or, launch our demo to see our viewer in action.
FAQ
Can I view DOC and DOCX files without a server?
Yes. Nutrient Web SDK converts Word files to PDF entirely in the browser using WebAssembly. No server or Microsoft Office installation is required.
Does Nutrient Web SDK support DOCX editing?
You can annotate, add signatures, highlight text, and fill forms. Full Word-style content editing (e.g. reflowable text editing) is not supported in the current version.
What happens if my Word document uses a custom font?
If the font isn’t embedded or licensed for browser use, the SDK substitutes it with a fallback (e.g. Arial is replaced with Noto Sans). This ensures accurate rendering while respecting licensing.
Can I use Nutrient with Angular 17 and standalone components?
Yes. Nutrient Web SDK works seamlessly with Angular 17 and supports Angular standalone components using @Component({ standalone: true })
.
What file types besides Word does the SDK support?
The SDK supports viewing DOC, DOCX, XLSX, PPTX, PDF, JPG, PNG, TIFF, and more. See our file format support guide) for details.
Is there a free version or trial available?
Yes. You can try the SDK for free or launch the demo to test it in your browser without installing anything.