@LBuchan1
Welcome to GroupDocs Forum!
The Viewer itself does not have any UI that can be used in a view. It’s a converter that can load a file and create pages in HTML/PNG/JPEG formats. The code snippet posted above will open a document and create HTML files on a disk where each HTML file represents a page in a document.
To render a document page on a webpage you can return that page contents as shown in the code snippet (I’m running .NET Core App but the idea would be the same for ASP.NET MVC)
using System.IO;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace RenderPage
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
var pageStream = GetPageStream("sample.docx", 1);
context.Response.ContentType = "text/html";
await pageStream.CopyToAsync(context.Response.Body);
});
});
}
private static MemoryStream GetPageStream(string filePath, int pageNumber)
{
var pageStream = new MemoryStream();
using (Viewer viewer = new Viewer(filePath))
{
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(
num => pageStream,
(num, stream) => { });
viewer.View(viewOptions, pageNumber);
}
pageStream.Position = 0;
return pageStream;
}
}
}
Your application is targeting .NET Framework or .NET / .NET Core?
In case it’s .NET / .NET Core application please check this demo app that handles rendering and includes UI out of the box.