Docs / Get started

Markdown

Get started with Blazor

The full viewer as a Razor component. You write no JavaScript.

Install

dotnet add package DocuVerse

One package: the engine for .NET, and on .NET 10 ASP.NET Core the Blazor component (Blazor Server or a Blazor Web App with interactive server rendering).

A licence key is needed: without one, nothing opens. Make a free account for trial keys (everything works, with a watermark), or choose a plan on the pricing page. Each key is for one SDK, made in your account under Keys: a Web SDK key for the viewer in websites (licenseKey), a Server SDK key for Node.js (setLicenseKey(key)) and .NET (License.SetKey(key)), a Mobile SDK key for apps. A key used with another SDK is refused with an error that says which key to make.

Add the component

@using DocuVerse.Blazor@rendermode InteractiveServer <PdfViewer @ref="viewer" Document="@bytes" Author="Jane Doe"           HeaderButtons="@buttons" OnHeaderButton="OnButton" OnSave="Saved" /> @code {    PdfViewer? viewer;    byte[] bytes = File.ReadAllBytes("contract.pdf");    PdfHeaderButton[] buttons = { new("approve", "Approve") };     async Task OnButton(string id) =>        await File.WriteAllBytesAsync("approved.pdf", await viewer!.SaveAsync());     Task Saved(PdfSavedEventArgs e) => File.WriteAllBytesAsync(e.FileName, e.Bytes);}

Parameters

ParameterMeaning
Document, DocumentUrl, FileNamePDF, Word or Excel file to open (bytes or URL); none shows an Open button
Author, Theme, AccentColor, ReadOnlyLook and behaviour; Theme is light, dark or auto
Tools, DisabledElements, InitialZoom, InitialTab, HeightWhich tools and parts show, starting zoom and tab, height (default 100vh)
Layout, ScrollModePage layout (single, double or cover) and scrolling (continuous or page)
HeaderButtons + OnHeaderButtonYour own header buttons, handled in C#
OnSaveReceive the saved bytes in C# instead of downloading
OnEvent, OnReadyViewer events such as documentLoaded and annotationsChanged

Methods: SaveAsync(incremental), SaveWordAsync(), LoadAsync(bytes, fileName), LoadUrlAsync(url), SetToolAsync(tool), SetThemeAsync(theme), AnnotationsJsonAsync(), IsWordDocumentAsync().