Skip to content

Commit 0ee353a

Browse files
Merge pull request #1463 from syncfusion-content/981582-RevampSmart2
981582: Restructure the documentation content on second set of the content in Smart PDF viewer
2 parents 1f0bc83 + a8b69a5 commit 0ee353a

File tree

7 files changed

+141
-139
lines changed

7 files changed

+141
-139
lines changed

Document-Processing/PDF/Smart-PDF-Viewer/blazor/custom-ai-service.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ documentation: ug
1111

1212
## Overview
1313

14-
Syncfusion Smart PDF Viewer provide built-in support for OpenAI and Azure OpenAI services. However, you can also integrate other AI services using the `IChatInferenceService` interface, which acts as a bridge between Smart PDF Viewer and your custom AI service.
14+
Syncfusion Smart PDF Viewer provides built-in support for OpenAI and Azure OpenAI services. It can also connect to other AI providers through the `IChatInferenceService` interface, which acts as a bridge between the viewer and a custom AI service.
1515

1616

1717
## IChatInferenceService Interface
@@ -26,13 +26,13 @@ public interface IChatInferenceService
2626
```
2727

2828
This interface enables:
29-
- Consistent communication between components and AI services
30-
- Easy switching between different AI providers
29+
- Consistent communication between components and AI services.
30+
- Easy switching between different AI providers.
3131

3232

3333
## Implemented AI Services
3434

35-
Here are examples of AI services integrated using the `IChatInferenceService` interface:
35+
The following examples demonstrate AI services integrated using the `IChatInferenceService` interface:
3636

3737
| Service | Documentation |
3838
|---------|---------------|
@@ -43,7 +43,7 @@ Here are examples of AI services integrated using the `IChatInferenceService` in
4343

4444
## Service Registration
4545

46-
Register your custom implementation in `Program.cs`:
46+
Register the custom implementation in `Program.cs`:
4747

4848
```csharp
4949
using Syncfusion.Blazor.AI;
@@ -52,16 +52,16 @@ builder.Services.AddSingleton<IChatInferenceService, YourCustomService>();
5252

5353
## Handling Error in Custom AI Service
5454

55-
Since the Custom AI service operates independently from the built-in AI service, error popups must be handled at the sample level. To capture error details, use a try-catch block within the request and response logic of the Custom AI service. Once an error message is received, pass it to the Smart PDF Viewer component, where it should be displayed in a dialog—replicating the behavior of the default built-in error popup.
55+
Because a custom AI service operates independently of the built-in providers, error popups must be handled at the sample level. Capture errors with try-catch in the request/response flow, propagate the message to the Smart PDF Viewer component, and display it in a dialog to mirror the built-in behavior. For production scenarios, surface user-friendly messages while logging technical details.
5656

5757
### Capture Error in CustomService
5858

59-
Exceptions that occur while creating a request to the custom AI service are captured using try-catch blocks. The resulting error message is assigned to the DialogMessage property, and the OnDialogOpen event is triggered to notify other components such as Home so they can display the error in a dialog appropriately.
59+
Use try-catch to capture exceptions during request creation or response handling. Assign the message to the `DialogMessage` property and raise `OnDialogOpen` to notify listening components to render the dialog. Consider mapping low-level exceptions to localized, user-friendly text.
6060

6161
## Step 1: Create a ErrorDialog Service
6262

63-
1.Create a new class file named ErrorDialogService.cs in your project
64-
2.Add the following implementation:
63+
1. Create a new class file named ErrorDialogService.cs in the project.
64+
2. Add the following implementation:
6565

6666
```cs
6767
public class ErrorDialogService
@@ -110,7 +110,7 @@ public class ErrorDialogService
110110

111111
### Step 3: Configure the Dialog Service
112112

113-
Configure the dialog service in `Program.cs` to enable error display functionality when a request or response to the Custom AI service fails. This setup ensures that any errors encountered during communication with the service can be shown in a dialog component.
113+
Configure services in `Program.cs` to enable error display when a request or response to the custom AI service fails. This setup ensures any errors encountered during communication can be surfaced via a dialog component.
114114

115115
{% tabs %}
116116
{% highlight c# tabtitle="~/Program.cs" hl_lines="1 2 5 6" %}
@@ -141,10 +141,10 @@ builder.Services.AddScoped<IChatInferenceService, MyCustomService>(sp =>
141141

142142
### Step 5: Show the Error Dialog
143143

144-
In the Smart PDF Viewer, error messages are displayed using SfDialogService. The component listens for the OnDialogOpen event from CustomService, and when triggered, the OpenDialog method calculates the dialog size dynamically based on the length of the error message and presents it accordingly. To ensure efficient resource management, the event subscription is properly disposed of when the component is no longer in use.
144+
In Smart PDF Viewer, error messages are displayed using `SfDialogService`. The component subscribes to `OnDialogOpen` from the custom service and, when triggered, `OpenDialog` computes a dialog size based on message length and shows it. The subscription is disposed when the component is no longer in use.
145145

146-
1.Create a new class file named Home.razor.cs by right-clicking on the Pages folder, then selecting Add → Class.
147-
2.Add the following implementation:
146+
1. Create a new class file named Home.razor.cs by right-clicking the Pages folder, then selecting Add → Class.
147+
2. Add the following implementation:
148148

149149
{% tabs %}
150150
{% highlight cs tabtitle="~/Home.razor.cs" %}

Document-Processing/PDF/Smart-PDF-Viewer/blazor/deepseek-service.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ documentation: ug
99

1010
# Getting Started with Smart PDF Viewer using DeepSeek AI
1111

12-
This guide demonstrates how to integrate DeepSeek's powerful AI capabilities with Syncfusion Smart PDF Viewer in your Blazor App.
12+
This guide explains how to integrate DeepSeek AI with the Syncfusion Smart PDF Viewer in a Blazor app.
1313

1414
## Prerequisites
1515

1616
Before you begin, ensure you have:
1717

1818
* [System requirements for Blazor components](https://blazor.syncfusion.com/documentation/system-requirements)
1919
* DeepSeek account and API key (see setup instructions below)
20+
* A supported .NET SDK and target framework for the installed Syncfusion Blazor version
2021

2122
### Setting Up DeepSeek
2223

@@ -41,21 +42,23 @@ After completing this setup, you can:
4142

4243
## Install the following NuGet packages to your project:
4344

44-
open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search and install the following packages
45+
Open the NuGet Package Manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), then search and install the following packages:
4546

46-
1.[Microsoft.Extensions.AI](https://www.nuget.org/packages/Microsoft.Extensions.AI).
47-
2.[Microsoft.SemanticKernel](https://www.nuget.org/packages/Microsoft.SemanticKernel).
48-
3.[Microsoft.SemanticKernel.Connectors.AzureOpenAI](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.AzureOpenAI).
47+
1. [Microsoft.Extensions.AI](https://www.nuget.org/packages/Microsoft.Extensions.AI).
48+
2. [Microsoft.SemanticKernel](https://www.nuget.org/packages/Microsoft.SemanticKernel).
49+
3. [Microsoft.SemanticKernel.Connectors.AzureOpenAI](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.AzureOpenAI).
4950

5051
## Step 1: Create a Custom AI Service
5152

5253
To integrate DeepSeek with Syncfusion Smart PDF Viewer, we'll create a custom implementation of the `IChatInferenceService` interface. This interface acts as a bridge between Syncfusion Smart PDF Viewer and your AI service.
5354

54-
The `IChatInferenceService` interface is the bridge between Syncfusion Smart PDF Viewer and AI services:S
55+
The `IChatInferenceService` interface is the bridge between Syncfusion Smart PDF Viewer and AI services:
5556

5657
1. Create a new file named `MyCustomService.cs`
5758
2. Add the following implementation:
5859

60+
N> Ensure the project includes required using directives and valid XML documentation tags in custom code implementations.
61+
5962
{% tabs %}
6063
{% highlight c# tabtitle="~/MyCustomService.cs" %}
6164

@@ -148,9 +151,7 @@ var app = builder.Build();
148151

149152
N> [View sample in GitHub](https://github.com/SyncfusionExamples/blazor-smart-pdf-viewer-examples/tree/master/Custom%20Services/DeepseekService)
150153

151-
N> Running Deepseek service may lead to slower response times due to system resource usage.
152-
To accommodate this, you can configure the Syncfusion Smart PDF Viewer to disable timeout for AI assist view operations by setting the timeout to 0.
153-
[Learn more](https://help.syncfusion.com/document-processing/pdf/smart-pdf-viewer/blazor/document-summarizer#timeout)
154+
N> Running the DeepSeek service may lead to slower response times due to system resource usage. To accommodate this, configure the Syncfusion Smart PDF Viewer to disable timeout for AI assist view operations by setting the timeout to 0. [Learn more](https://help.syncfusion.com/document-processing/pdf/smart-pdf-viewer/blazor/document-summarizer#timeout)
154155

155156
## See also
156157

Document-Processing/PDF/Smart-PDF-Viewer/blazor/getting-started/maui-blazor-app.md

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
---
22
layout: post
3-
title: Deploy SfSmartPdfViewer in Blazor MAUI in windows | Syncfusion
4-
description: Learn how to deploy SfSmartPdfViewer in Blazor MAUI Application on Windows in Syncfusion Blazor SfSmartPdfViewer component and much more details.
3+
title: Use Smart PDF Viewer in Blazor MAUI in Windows | Syncfusion
4+
description: Learn how to add and run the Syncfusion Blazor Smart PDF Viewer in a .NET MAUI Blazor app on Windows and Android, including package installation.
55
platform: document-processing
66
control: SfSmartPdfViewer
77
documentation: ug
88
---
99

1010
# Using Smart PDF Viewer Component in the Blazor MAUI app
1111

12-
In this section, we'll guide you through the process of adding Syncfusion&reg; Blazor Smart PDF Viewer component to your Blazor Maui app. We'll break it down into simple steps to make it easy to follow.
12+
This section describes how to add the Syncfusion&reg; Blazor Smart PDF Viewer component to a .NET MAUI Blazor app and run it on Windows and Android.
1313

1414
## Prerequisites
1515

16-
To use the MAUI project templates, install the Mobile development with the .NET extension for Visual Studio. For more details, refer to [here](https://learn.microsoft.com/en-us/dotnet/MAUI/get-started/installation?tabs=vswin).
16+
To use MAUI project templates, install the Mobile development with .NET workload for Visual Studio. For detailed steps, see [Install .NET MAUI](https://learn.microsoft.com/en-us/dotnet/MAUI/get-started/installation?tabs=vswin) on Windows in the Microsoft documentation.
1717

1818
## Create a new Blazor MAUI App in Visual Studio
1919

20-
Create a new Blazor MAUI app and by selecting the template **.NET MAUI Blazor Hybrid APP ** in VS.
20+
Create a new .NET MAUI Blazor App in Visual Studio by selecting the template named **.NET MAUI Blazor Hybrid APP**.
2121

2222
## Install Smart PDF Viewer NuGet package in Blazor Maui App
2323

24-
Add the following NuGet packages into the Blazor Maui app.
24+
Add the following NuGet packages to the Blazor MAUI app.
2525

2626
* [Syncfusion.Blazor.SfSmartPdfViewer](https://www.nuget.org/packages/Syncfusion.Blazor.SfSmartPdfViewer)
2727
* [Syncfusion.Blazor.Themes](https://www.nuget.org/packages/Syncfusion.Blazor.Themes)
@@ -72,16 +72,20 @@ public static class MauiProgram
7272

7373
builder.Services.AddSingleton<WeatherForecastService>();
7474
builder.Services.AddSyncfusionBlazor();
75-
75+
7676
return builder.Build();
7777
}
7878
}
7979

8080
{% endhighlight %}
8181
{% endtabs %}
8282

83+
Note: Ensure the Syncfusion license is registered in the application before using Syncfusion components.
84+
8385
## To Configure Azure OpenAI Service
8486

87+
This section is required only when enabling AI-powered features in Smart PDF Viewer (such as document summarization, smart redaction, or smart fill). It is not required for basic PDF rendering.
88+
8589
In **Visual Studio**, Go to Tools → NuGet Package Manager → Package Manager Console. Run these commands one by one:
8690

8791
{% tabs %}
@@ -94,7 +98,7 @@ Install-Package Microsoft.Extensions.AI.OpenAI -Version 9.8.0-preview.1.25412.6
9498
{% endhighlight %}
9599
{% endtabs %}
96100

97-
In **Visual Studio Code**, Open terminal in VS Code. Run these commands:
101+
In **Visual Studio Code**, open the terminal and run these commands:
98102

99103
{% tabs %}
100104
{% highlight razor tabtitle="Package Manager" %}
@@ -136,11 +140,11 @@ var app = builder.Build();
136140
{% endtabs %}
137141

138142
Here,
139-
* **apiKey**: “Azure OpenAI API Key”;
140-
* **deploymentName**: “Azure OpenAI deployment name”;
141-
* **endpoint**: “Azure OpenAI deployment end point URL”;
143+
* **apiKey**: “Azure OpenAI API Key”
144+
* **deploymentName**: “Azure OpenAI deployment name”
145+
* **endpoint**: “Azure OpenAI deployment endpoint URL”
142146

143-
For **Azure OpenAI**, first [deploy an Azure OpenAI Service resource and model](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/create-resource?pivots=web-portal), then values for `apiKey`, `deploymentName` and `endpoint` will all be provided to you.
147+
For **Azure OpenAI**, first [deploy an Azure OpenAI Service resource and model](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/create-resource?pivots=web-portal), then the values for `apiKey`, `deploymentName`, and `endpoint` will be available.
144148

145149
## Adding stylesheet and script
146150

@@ -161,7 +165,7 @@ Add the following stylesheet and script to the head section of the **~/wwwroot/i
161165

162166
## Add Smart PDF Viewer component
163167

164-
Add the Syncfusion<sup style="font-size:70%">&reg;</sup> PDF Viewer (Next Gen) component in the **~/Pages/Index.razor** file.
168+
Add the Syncfusion Blazor Smart PDF Viewer component in the **~/Pages/Index.razor** file.
165169

166170
{% tabs %}
167171
{% highlight razor %}
@@ -176,30 +180,30 @@ Add the Syncfusion<sup style="font-size:70%">&reg;</sup> PDF Viewer (Next Gen) c
176180

177181
## Run on Windows
178182

179-
Run the sample in Windows Machine mode, and it will run Blazor MAUI in Windows.
183+
Run the sample in Windows Machine mode. The application will run the Blazor MAUI app targeting Windows.
180184

181-
![Run Windows machine](gettingstarted-images/Windows-machine.png)
185+
![Run MAUI app on Windows target](gettingstarted-images/Windows-machine.png)
182186

183-
Upon successfully launching the application, the PDF Viewer component will seamlessly render the specified PDF document within its interface.
187+
After the application launches, the PDF Viewer component renders the specified PDF document within its interface.
184188

185-
![Blazor SfSmartPdfViewerPdfViewer Component](gettingstarted-images/Windows-maui-output.png)
189+
![Blazor Smart PDF Viewer rendered on Windows](gettingstarted-images/Windows-maui-output.png)
186190

187191
## Run on Android
188192

189-
To run the PDF Viewer in a Blazor Android MAUI application using the Android emulator, follow these steps:
193+
To run the PDF Viewer in a Blazor Android MAUI application using the Android emulator, follow these steps. These steps are required only when using local embeddings for AI features; they are not needed for basic PDF viewing.
190194

191-
1. Add the following Assets files in your Project by creating Assets folder(Platform -> Android -> Assets)
192-
[model](https://github.com/SyncfusionExamples/blazor-smart-pdf-viewer-examples/blob/master/Common/LocalEmbeddingsModel/model.onnx) & [vocab](https://github.com/SyncfusionExamples/blazor-smart-pdf-viewer-examples/blob/master/Common/LocalEmbeddingsModel/vocab.txt)
195+
1. Add the following asset files to the project by creating an Assets folder (Platforms → Android Assets):
196+
[model](https://github.com/SyncfusionExamples/blazor-smart-pdf-viewer-examples/blob/master/Common/LocalEmbeddingsModel/model.onnx) and [vocab](https://github.com/SyncfusionExamples/blazor-smart-pdf-viewer-examples/blob/master/Common/LocalEmbeddingsModel/vocab.txt).
193197

194-
2. Right click the Added files and go to (Properties -> BuildAction) set as AndroidAsset.
195-
3. Add the following code in your .csproj file
198+
2. Right-click the added files and set Properties → Build Action to AndroidAsset.
199+
3. Add the following entries to the project .csproj file:
196200
```
197201
<ItemGroup>
198202
<AndroidAsset Include="Platforms\Android\Assets\model.onnx" />
199203
<AndroidAsset Include="Platforms\Android\Assets\vocab.txt" />
200204
</ItemGroup>
201205
```
202-
4. Add the following code in your MauiProgram.cs file
206+
4. Add the following code in **MauiProgram.cs**:
203207

204208
{% tabs %}
205209
{% highlight c# tabtitle="~/MauiProgram.cs" hl_lines="7 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25" %}
@@ -208,19 +212,19 @@ public static class MauiProgram
208212
{
209213
public static MauiApp CreateMauiApp()
210214
{
211-
...
212-
builder.Services.AddSyncfusionBlazor();
215+
...
216+
builder.Services.AddSyncfusionBlazor();
213217
#if ANDROID
214-
EnsureModelExistsAsync();
218+
EnsureModelExistsAsync();
215219
#endif
216220
return builder.Build();
217-
}
218-
private static async void EnsureModelExistsAsync()
219-
{
220-
string[] requiredFiles = { "model.onnx", "vocab.txt" };
221-
string targetDir = Path.Combine(FileSystem.AppDataDirectory, "LocalEmbeddingsModel/default");
222-
Directory.CreateDirectory(targetDir);
223-
foreach (string fileName in requiredFiles)
221+
}
222+
private static async void EnsureModelExistsAsync()
223+
{
224+
string[] requiredFiles = { "model.onnx", "vocab.txt" };
225+
string targetDir = Path.Combine(FileSystem.AppDataDirectory, "LocalEmbeddingsModel/default");
226+
Directory.CreateDirectory(targetDir);
227+
foreach (string fileName in requiredFiles)
224228
{
225229
string targetPath = Path.Combine(targetDir, fileName);
226230
if (!File.Exists(targetPath))
@@ -230,18 +234,18 @@ public static class MauiProgram
230234
await assetStream.CopyToAsync(fileStream);
231235
}
232236
}
233-
}
237+
}
234238
}
235239
{% endhighlight %}
236240
{% endtabs %}
237241

238-
![Run Windows machine](gettingstarted-images/android-maui.png)
242+
![Run MAUI app on Android emulator](gettingstarted-images/android-maui.png)
239243

240-
Refer [here](https://learn.microsoft.com/en-us/dotnet/maui/android/emulator/device-manager#android-device-manager-on-windows) to install and launch Android emulator.
244+
Refer [here](https://learn.microsoft.com/en-us/dotnet/maui/android/emulator/device-manager#android-device-manager-on-windows) to Set up the Android emulator with Android Device Manager.
241245

242-
N> If you encounter any errors while using the Android Emulator, refer to the following link for troubleshooting guidance[Troubleshooting Android Emulator](https://learn.microsoft.com/en-us/dotnet/maui/android/emulator/troubleshooting).
246+
N> If any errors occur while using the Android Emulator, see [Troubleshooting the Android Emulator](https://learn.microsoft.com/en-us/dotnet/maui/android/emulator/troubleshooting).
243247

244-
![Blazor SfPdfViewer Component](gettingstarted-images/android-emulator.png)
248+
![Blazor Smart PDF Viewer rendered on Android emulator](gettingstarted-images/android-emulator.png)
245249

246250
>[View Sample in GitHub](https://github.com/SyncfusionExamples/blazor-smart-pdf-viewer-examples/tree/master/GettingStartedMAUI).
247251

0 commit comments

Comments
 (0)