惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Jina AI
Jina AI
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
美团技术团队
腾讯CDC
博客园 - Franky
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
博客园_首页
V
V2EX
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss

Inside Nutrient

A guide to the invisible work behind documents Introducing Nutrient Documents for Salesforce: Native document generation and signing Document AI vs. traditional OCR: Choosing between OCR, AI, and hybrid pipelines PDF SDK compliance and security evaluation checklist for enterprise teams (2026) Invariant Corp replaces paper processes with Nutrient Workflow and scales without limits What is process mapping? A complete guide Nutrient vs. Conga Composer for Salesforce document generation (2026) Document routing: How to automate document distribution The CTO’s AI playbook: Why accountability architecture beats orchestration Compliance workflow automation: Why built-in compliance is table stakes Workflow diagrams: Examples, symbols, and how to build one that actually runs Digital forms: Replace paper forms with automated workflows Approval workflow software: How to automate approvals Why document-centric automation is different The CEO’s AI playbook: Why decision architecture beats model selection Nutrient SDK product updates for Q1 2026 PDF redaction verification: How to prove sensitive data is permanently removed What is a VPAT? The complete guide to accessibility conformance reports What is PDF/UA? The accessible PDF standard explained Salesforce eSignatures: Generate, sign, and track documents in one flow Online document viewer: Options, tradeoffs, and how to embed one Document viewer for web apps: React, Vue, Angular (2026) Best document viewers in 2026: A buyer’s guide How to edit a PDF in Python: Add text, images, and annotations Nutrient advances Workflow platform with agentic AI for enterprise-grade speed and consistency in document-heavy operations How to create a Salesforce quote template from opportunity data The business case for accessibility: Five ways it drives enterprise value Python PDF library comparison (2026): 7 libraries for developers Why your AI agent hallucinates PDF table data PDF.js limitations: When to upgrade to a commercial PDF SDK
How to build a .NET WinUI3 PDF viewer with Nutrient Web SDK
Shantanu Methikar · 2024-11-04 · via Inside Nutrient

Table of contents

    How to build a .NET WinUI3 PDF viewer with Nutrient Web SDK

    In this post, you’ll learn how to build a .NET WinUI3 PDF viewer with Nutrient Web SDK.

    WinUI 3(opens in a new tab) is the native UI platform component that ships with the Windows App SDK(opens in a new tab), which is completely decoupled from Windows SDKs. The Windows App SDK provides a unified set of APIs and tools that can be used to create production desktop apps that target Windows 10 and later and can be published to the Microsoft Store.

    You can use similar steps to build a PDF viewer using Nutrient on other .NET platforms like WPF(opens in a new tab), WinForms(opens in a new tab), and anything else that supports WebView2(opens in a new tab).

    Prerequisites

    windows application development component

    Follow the steps outlined below to build a WinUI3 PDF viewer with Nutrient Web SDK.

    Step 1 - Creating a new project

    1. Open Visual Studio.
    2. Choose Create New Project.
    3. Choose Blank App, Packaged (WinUI 3 in Desktop) from the list. project type
    4. Click Next.
    5. Under Project name, enter PSPDFKitWinUI3Example. Then, press Create.
    6. Once the new solution is created, the project tree will look like what’s shown in the following image. initial project structure

    Step 2 - Adding Nutrient

    1. Download the latest Nutrient Web SDK(opens in a new tab).
    2. Extract the ZIP file and copy the contents of package/dist to the Assets folder.

    Step 3 - Displaying a PDF in WinUI3

    1. Add the PDF document you want to display, e.g. document.pdf, in the Assets folder.

    2. Add the index.html file to the Assets folder, and add the following code to the index.html file:

      <!DOCTYPE html>

      <html>

      <head>

      <meta charset="UTF-8" />

      <meta

      name="viewport"

      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"

      />

      <title>Nutrient Example App</title>

      <style>

      html,

      body {

      margin: 0;

      padding: 0;

      background: #f6f7fa;

      }

      header {

      display: none;

      }

      #root {

      width: 100vw;

      height: 100vh;

      }

      </style>

      </head>

      <body>

      <header></header>

      <div id="root"></div>

      <script src="./pspdfkit.js"></script>

      <script type="module">

      let instance = null;

      async function load(document) {

      if (instance) {

      PSPDFKit.unload(instance);

      hasUnsavedAnnotations = false;

      instance = null;

      }

      const configuration = {

      document,

      container: '#root',

      // Add when using a license key.

      // licenseKey: "LICENSE KEY GOES HERE",

      };

      instance = await PSPDFKit.load(configuration);

      }

      window.onload = () => load('./document.pdf');

      </script>

      </body>

      </html>

    3. Double-click the project name to access the project file (PSPDFKitWinUI3Example.csproj) and replace the following:

      <ItemGroup>

      <Content Include="Assets\SplashScreen.scale-200.png" />

      <Content Include="Assets\LockScreenLogo.scale-200.png" />

      <Content Include="Assets\Square150x150Logo.scale-200.png" />

      <Content Include="Assets\Square44x44Logo.scale-200.png" />

      <Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />

      <Content Include="Assets\StoreLogo.png" />

      <Content Include="Assets\Wide310x150Logo.scale-200.png" />

      </ItemGroup>

      With this:

      <ItemGroup>

      <Content Include="Assets\**\*" />

      </ItemGroup>

    4. Replace the contents of the MainPage Window with:

      <WebView2 x:Name="WebView" Loaded="WebView_Loaded" />

    5. Add the Loaded event handler in the MainPage.xaml.cs file to open index.html and display the PDF:

      private async void WebView_Loaded(object sender, RoutedEventArgs e)

      {

      await WebView.EnsureCoreWebView2Async();

      // Set the virtual host for the assets folder.

      WebView.CoreWebView2.SetVirtualHostNameToFolderMapping(

      "pspdfkit-example",

      "Assets",

      Microsoft.Web.WebView2.Core.CoreWebView2HostResourceAccessKind.Deny);

      WebView.CoreWebView2.Navigate("https://pspdfkit-example/index.html");

      }

    Step 4 - Running the application

    1. Press F5 to run the application.
    2. The application will open with the PDF document displayed in the WebView2 control.

    PDF displayed in WebView2 control

    Step 5 - Sample code

    The code for the example in this post can be found in our PSPDFKit-labs GitHub repository(opens in a new tab).

    Conclusion

    In this post, you learned how to build a WinUI3 PDF viewer with Nutrient Web SDK. You can use similar steps to build a PDF viewer using Nutrient on other .NET platforms like WPF(opens in a new tab) and WinForms(opens in a new tab), or anything that supports WebView2(opens in a new tab).

    Explore related topics

    Try for free Ready to get started?

    Related SDK articles

    Explore more