DocxPreview.Blazor
1.0.1
dotnet add package DocxPreview.Blazor --version 1.0.1
NuGet\Install-Package DocxPreview.Blazor -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DocxPreview.Blazor" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DocxPreview.Blazor" Version="1.0.1" />
<PackageReference Include="DocxPreview.Blazor" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DocxPreview.Blazor --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DocxPreview.Blazor, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DocxPreview.Blazor@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DocxPreview.Blazor&version=1.0.1
#tool nuget:?package=DocxPreview.Blazor&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DocxPreview.Blazor
Blazor component for previewing DOCX documents, powered by docx-preview.
Features
- Render
.docxfiles directly in Blazor apps (Server and WebAssembly) - All JavaScript dependencies bundled in the NuGet package — no CDN, works offline
- Full set of docx-preview rendering options exposed via
DocxRenderOptions - Clean API with JS isolation (no manual
<script>tags needed)
Installation
dotnet add package DocxPreview.Blazor
Usage
@using DocxPreview.Blazor
<DocxPreview DocumentBytes="@fileBytes"
Options="@new DocxRenderOptions { BreakPages = true, InWrapper = true }" />
Parameters
| Parameter | Type | Description |
|---|---|---|
DocumentBytes |
byte[] |
Raw .docx file content |
Options |
DocxRenderOptions? |
Rendering options (see below) |
Class |
string? |
Additional CSS class for the container |
Style |
string? |
Inline styles for the container |
OnRendered |
EventCallback |
Callback invoked after rendering completes |
DocxRenderOptions
All options match the docx-preview API:
| Property | Default | Description |
|---|---|---|
ClassName |
"docx" |
Class name prefix for document styles |
InWrapper |
true |
Wrap document content in a page-like container |
IgnoreWidth |
false |
Disable page width rendering |
IgnoreHeight |
false |
Disable page height rendering |
IgnoreFonts |
false |
Disable font rendering |
BreakPages |
true |
Enable page breaks |
IgnoreLastRenderedPageBreak |
true |
Ignore editor-inserted page breaks |
Experimental |
false |
Enable experimental features (tab stops) |
UseBase64URL |
false |
Use base64 URLs for images/fonts |
RenderHeaders |
true |
Render document headers |
RenderFooters |
true |
Render document footers |
RenderFootnotes |
true |
Render footnotes |
RenderEndnotes |
true |
Render endnotes |
RenderChanges |
false |
Render tracked changes (experimental) |
RenderComments |
false |
Render comments (experimental) |
Debug |
false |
Enable debug logging |
Complete Example
@page "/preview"
@rendermode InteractiveServer
@using DocxPreview.Blazor
<h3>Upload a DOCX file</h3>
<InputFile OnChange="HandleFile" accept=".docx" />
@if (docxBytes != null)
{
<DocxPreview DocumentBytes="docxBytes"
Options="new DocxRenderOptions { BreakPages = true, RenderHeaders = false }" />
}
@code {
private byte[]? docxBytes;
private async Task HandleFile(InputFileChangeEventArgs e)
{
using var ms = new MemoryStream();
await e.File.OpenReadStream(50 * 1024 * 1024).CopyToAsync(ms);
docxBytes = ms.ToArray();
}
}
Requirements
- .NET 8.0+
- Blazor Server or Blazor WebAssembly
License
Licensed under the Apache License, Version 2.0.
The bundled docx-preview.js and jszip.js libraries are distributed under their respective licenses:
- docx-preview — Apache 2.0
- JSZip — MIT/GPLv3
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.0)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 92 | 5/30/2026 |