diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md b/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md index b7eca5a23d..c341914d55 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md @@ -43,52 +43,52 @@ Before proceeding, ensure the following are in place: [Syncfusion.Maui.Core](https://www.nuget.org/packages/Syncfusion.Maui.Core/) is automatically installed as a dependency when [Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) NuGet is installed. 1. Add the following namespace in your `MauiProgram.cs` file. -{% tabs %} -{% highlight c# tabtitle="MauiProgram.cs" %} -using Syncfusion.Maui.Core.Hosting; -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight c# tabtitle="MauiProgram.cs" %} + using Syncfusion.Maui.Core.Hosting; + {% endhighlight %} + {% endtabs %} 2. Register the Syncfusion core handler in your `MauiProgram.cs` file to use Syncfusion controls. -{% tabs %} -{% highlight c# tabtitle="MauiProgram.cs" hl_lines="11" %} - -public static MauiApp CreateMauiApp() -{ - var builder = MauiApp.CreateBuilder(); - builder - .UseMauiApp() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }); - - builder.ConfigureSyncfusionCore(); - return builder.Build(); -} - -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight c# tabtitle="MauiProgram.cs" hl_lines="11" %} + + public static MauiApp CreateMauiApp() + { + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + }); + + builder.ConfigureSyncfusionCore(); + return builder.Build(); + } + + {% endhighlight %} + {% endtabs %} ## Step 4: Add PDF Viewer Open the `MainPage.xaml` file and follow the steps below. - + 1. Add the following namespace in your MainPage.xaml file. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - -xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + + xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" + {% endhighlight %} + {% endtabs %} 2. Add the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) control. - -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - -{% endhighlight %} -{% endtabs %} + + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + + {% endhighlight %} + {% endtabs %} ## Step 5: Load a PDF Document @@ -98,79 +98,79 @@ xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Ma {% tabs %} {% highlight c# tabtitle="PdfViewerViewModel.cs" %} - -using System.ComponentModel; -using System.Reflection; -public class PdfViewerViewModel : INotifyPropertyChanged -{ - private Stream pdfDocumentStream; - - /// - /// Occurs when a property value changes. - /// - public event PropertyChangedEventHandler? PropertyChanged; - - /// - /// Gets or sets the stream of the currently loaded PDF document. - /// - public Stream PdfDocumentStream + using System.ComponentModel; + using System.Reflection; + + public class PdfViewerViewModel : INotifyPropertyChanged { - get + private Stream pdfDocumentStream; + + /// + /// Occurs when a property value changes. + /// + public event PropertyChangedEventHandler? PropertyChanged; + + /// + /// Gets or sets the stream of the currently loaded PDF document. + /// + public Stream PdfDocumentStream { - return pdfDocumentStream; + get + { + return pdfDocumentStream; + } + set + { + pdfDocumentStream = value; + OnPropertyChanged(nameof(PdfDocumentStream)); + } } - set + + /// + /// Initializes a new instance of the class. + /// + public PdfViewerViewModel() { - pdfDocumentStream = value; - OnPropertyChanged(nameof(PdfDocumentStream)); + // Load the embedded PDF document stream. + // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. + pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); } + + /// + /// Raises the event for the specified property name. + /// + /// The name of the property that changed. + public void OnPropertyChanged(string name) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + } } - - /// - /// Initializes a new instance of the class. - /// - public PdfViewerViewModel() - { - // Load the embedded PDF document stream. - // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. - pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); - } - - /// - /// Raises the event for the specified property name. - /// - /// The name of the property that changed. - public void OnPropertyChanged(string name) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); - } -} {% endhighlight %} {% endtabs %} 4. Open the `MainPage.xaml` file again and add the namespace `PdfViewerExample` and name it as `local`. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} -xmlns:local="clr-namespace:PdfViewerExample" -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + xmlns:local="clr-namespace:PdfViewerExample" + {% endhighlight %} + {% endtabs %} 5. Set an instance of the `PdfViewerViewModel` class as the `BindingContext`. Bind the PDF viewer's [DocumentSource](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentSource) to the `PdfDocumentStream` property of the `PdfViewerViewModel` class. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - - - - - - -{% endhighlight %} -{% endtabs %} - -N> 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). -N> 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + + + + + + + {% endhighlight %} + {% endtabs %} + + N> 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). + N> 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. ## Step 6: Running the Application @@ -207,149 +207,149 @@ Before proceeding, ensure the following are in place: [Syncfusion.Maui.Core](https://www.nuget.org/packages/Syncfusion.Maui.Core/) will be automatically installed as a dependency when [Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) NuGet is installed. 1. Add the following namespace in your `MauiProgram.cs` file. -{% tabs %} -{% highlight c# tabtitle="MauiProgram.cs" %} -using Syncfusion.Maui.Core.Hosting; -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight c# tabtitle="MauiProgram.cs" %} + using Syncfusion.Maui.Core.Hosting; + {% endhighlight %} + {% endtabs %} 2. Register the Syncfusion core handler in your `MauiProgram.cs` file to use Syncfusion controls. -{% tabs %} -{% highlight c# tabtitle="MauiProgram.cs" hl_lines="11" %} - -public static MauiApp CreateMauiApp() -{ - var builder = MauiApp.CreateBuilder(); - builder - .UseMauiApp() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }); + {% tabs %} + {% highlight c# tabtitle="MauiProgram.cs" hl_lines="11" %} - builder.ConfigureSyncfusionCore(); - return builder.Build(); -} + public static MauiApp CreateMauiApp() + { + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + }); -{% endhighlight %} -{% endtabs %} + builder.ConfigureSyncfusionCore(); + return builder.Build(); + } + + {% endhighlight %} + {% endtabs %} ## Step 4: Add PDF Viewer Open the `MainPage.xaml` file and follow the steps below. 1. Add the following namespace in your MainPage.xaml file. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} -xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" -{% endhighlight %} -{% endtabs %} + xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" + {% endhighlight %} + {% endtabs %} 2. Add the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) control. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} - + -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} ## Step 5: Load a PDF Document 1. From the solution explorer of the project, add a new folder to the project named `Assets` and add the PDF document you need to load into the PDF viewer. Here, a PDF document named `PDF_Succinctly.pdf` is used. 2. Open the `.csproj` file and add the following code snippet to embed the PDF document as a resource. -{% tabs %} -{% highlight xml tabtitle="PdfViewerExample.csproj" %} + {% tabs %} + {% highlight xml tabtitle="PdfViewerExample.csproj" %} - - - + + + -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} -If the project does not reload automatically after editing the `.csproj`, close and reopen the project. + If the project does not reload automatically after editing the `.csproj`, close and reopen the project. 3. In this example, the PDF document is loaded using MVVM binding. Create a new C# file named `PdfViewerViewModel.cs` and add the following code snippet. {% tabs %} {% highlight c# tabtitle="PdfViewerViewModel.cs" %} -using System.ComponentModel; -using System.Reflection; - -public class PdfViewerViewModel : INotifyPropertyChanged -{ - private Stream pdfDocumentStream; - - /// - /// Occurs when a property value changes. - /// - public event PropertyChangedEventHandler? PropertyChanged; - - /// - /// Gets or sets the stream of the currently loaded PDF document. - /// - public Stream PdfDocumentStream + using System.ComponentModel; + using System.Reflection; + + public class PdfViewerViewModel : INotifyPropertyChanged { - get + private Stream pdfDocumentStream; + + /// + /// Occurs when a property value changes. + /// + public event PropertyChangedEventHandler? PropertyChanged; + + /// + /// Gets or sets the stream of the currently loaded PDF document. + /// + public Stream PdfDocumentStream { - return pdfDocumentStream; + get + { + return pdfDocumentStream; + } + set + { + pdfDocumentStream = value; + OnPropertyChanged(nameof(PdfDocumentStream)); + } } - set + + /// + /// Initializes a new instance of the class. + /// + public PdfViewerViewModel() { - pdfDocumentStream = value; - OnPropertyChanged(nameof(PdfDocumentStream)); + // Load the embedded PDF document stream. + // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. + pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); } - } - /// - /// Initializes a new instance of the class. - /// - public PdfViewerViewModel() - { - // Load the embedded PDF document stream. - // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. - pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); + /// + /// Raises the event for the specified property name. + /// + /// The name of the property that changed. + public void OnPropertyChanged(string name) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + } } - /// - /// Raises the event for the specified property name. - /// - /// The name of the property that changed. - public void OnPropertyChanged(string name) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); - } -} - -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} 4. Open the `MainPage.xaml` file again and add the namespace `PdfViewerExample` and name it as `local`. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} -xmlns:local="clr-namespace:PdfViewerExample" -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + xmlns:local="clr-namespace:PdfViewerExample" + {% endhighlight %} + {% endtabs %} 5. Set an instance of the `PdfViewerViewModel` class as the `BindingContext`. Bind the PDF viewer's [DocumentSource](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentSource) to the `PdfDocumentStream` property of the `PdfViewerViewModel` class. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - - - + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + + + - - -{% endhighlight %} -{% endtabs %} + + + {% endhighlight %} + {% endtabs %} -N> 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). -N> 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. + N> 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). + N> 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. ## Step 6: Running the Application @@ -381,158 +381,158 @@ Before proceeding, ensure the following are set up: 2. Search for [Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) and install the latest version. 3. Ensure the dependencies are installed, and the project is restored. If not, open the Terminal in Rider and manually run the following code. -{% tabs %} -{% highlight c# tabtitle="terminal" %} + {% tabs %} + {% highlight c# tabtitle="terminal" %} -dotnet restore + dotnet restore -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} ## Step 3: Register the Syncfusion® Core Handler [Syncfusion.Maui.Core](https://www.nuget.org/packages/Syncfusion.Maui.Core/) is automatically installed as a dependency when [Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) NuGet is installed. 1. Add the following namespace in your `MauiProgram.cs` file. -{% tabs %} -{% highlight c# tabtitle="MauiProgram.cs" %} -using Syncfusion.Maui.Core.Hosting; -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight c# tabtitle="MauiProgram.cs" %} + using Syncfusion.Maui.Core.Hosting; + {% endhighlight %} + {% endtabs %} 2. Register the Syncfusion core handler in your `MauiProgram.cs` file to use Syncfusion controls. -{% tabs %} -{% highlight c# tabtitle="MauiProgram.cs" hl_lines="11" %} - -public static MauiApp CreateMauiApp() -{ - var builder = MauiApp.CreateBuilder(); - builder - .UseMauiApp() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }); + {% tabs %} + {% highlight c# tabtitle="MauiProgram.cs" hl_lines="11" %} - builder.ConfigureSyncfusionCore(); - return builder.Build(); -} + public static MauiApp CreateMauiApp() + { + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + }); + + builder.ConfigureSyncfusionCore(); + return builder.Build(); + } -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} ## Step 4: Add PDF Viewer Open the `MainPage.xaml` file and follow the steps below. 1. Add the following namespace in your MainPage.xaml file. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} -xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" + {% endhighlight %} + {% endtabs %} 2. Add the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) control. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} - + -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} ## Step 5: Load a PDF Document 1. From the solution explorer of the project, add a new folder to the project named `Assets` and add the PDF document you need to load into the PDF viewer. Here, a PDF document named `PDF_Succinctly.pdf` is used. 2. Open the `.csproj` file and add the following code snippet to embed the PDF document as a resource. -{% tabs %} -{% highlight xml tabtitle="PdfViewerExample.csproj" %} + {% tabs %} + {% highlight xml tabtitle="PdfViewerExample.csproj" %} - - - + + + -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} 3. In this example, the PDF document is loaded using MVVM binding. Create a new C# file named `PdfViewerViewModel.cs` and add the following code snippet. {% tabs %} {% highlight c# tabtitle="PdfViewerViewModel.cs" %} + + using System.ComponentModel; + using System.Reflection; -using System.ComponentModel; -using System.Reflection; - -public class PdfViewerViewModel : INotifyPropertyChanged -{ - private Stream pdfDocumentStream; + public class PdfViewerViewModel : INotifyPropertyChanged + { + private Stream pdfDocumentStream; - /// - /// Occurs when a property value changes. - /// - public event PropertyChangedEventHandler? PropertyChanged; + /// + /// Occurs when a property value changes. + /// + public event PropertyChangedEventHandler? PropertyChanged; - /// - /// Gets or sets the stream of the currently loaded PDF document. - /// - public Stream PdfDocumentStream - { - get + /// + /// Gets or sets the stream of the currently loaded PDF document. + /// + public Stream PdfDocumentStream { - return pdfDocumentStream; + get + { + return pdfDocumentStream; + } + set + { + pdfDocumentStream = value; + OnPropertyChanged(nameof(PdfDocumentStream)); + } } - set + + /// + /// Initializes a new instance of the class. + /// + public PdfViewerViewModel() { - pdfDocumentStream = value; - OnPropertyChanged(nameof(PdfDocumentStream)); + // Load the embedded PDF document stream. + // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. + pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); } - } - /// - /// Initializes a new instance of the class. - /// - public PdfViewerViewModel() - { - // Load the embedded PDF document stream. - // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. - pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); + /// + /// Raises the event for the specified property name. + /// + /// The name of the property that changed. + public void OnPropertyChanged(string name) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + } } - /// - /// Raises the event for the specified property name. - /// - /// The name of the property that changed. - public void OnPropertyChanged(string name) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); - } -} - -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} 4. Open the `MainPage.xaml` file again and add the namespace `PdfViewerExample` and name it as `local`. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} -xmlns:local="clr-namespace:PdfViewerExample" -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + xmlns:local="clr-namespace:PdfViewerExample" + {% endhighlight %} + {% endtabs %} 5. Set an instance of the `PdfViewerViewModel` class as the `BindingContext`. Bind the PDF viewer's [DocumentSource](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentSource) to the `PdfDocumentStream` property of the `PdfViewerViewModel` class. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - - - + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + + + - + -{% endhighlight %} -{% endtabs %} + {% endhighlight %} + {% endtabs %} -N> 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). -N> 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. + N> 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). + N> 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. ## Step 6: Running the Application @@ -564,3 +564,4 @@ Now that the PDF Viewer is running, you can explore the following features: * For migration from Xamarin to .NET MAUI, please follow the [Migration Guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/migration). +N> Looking for the full .NET MAUI PDF Viewer component overview, features, pricing, and documentation? Visit the [.NET MAUI PDF Viewer](https://www.syncfusion.com/pdf-viewer-sdk/net-maui-pdf-viewer) page diff --git a/Document-Processing/PDF/PDF-Viewer/uwp/Getting-Started.md b/Document-Processing/PDF/PDF-Viewer/uwp/Getting-Started.md index 0e5ce48b6e..a88d07fdb0 100644 --- a/Document-Processing/PDF/PDF-Viewer/uwp/Getting-Started.md +++ b/Document-Processing/PDF/PDF-Viewer/uwp/Getting-Started.md @@ -95,7 +95,7 @@ UWP PDF Viewer control can be added to an application either through the designe 2. Open the Visual Studio **Tool** **box**. Navigate to "Syncfusion® Controls for UWP" tab and find the SfPdfViewerControl toolbox items. -![SfPdfViewerControl in visual studio toolbox](Getting-Started_images/Getting-Started_img1.jpeg) + ![SfPdfViewerControl in visual studio toolbox](Getting-Started_images/Getting-Started_img1.jpeg) 3. Drag the [`SfPdfViewerControl`](https://help.syncfusion.com/cr/uwp/Syncfusion.Windows.PdfViewer.SfPdfViewerControl.html) and drop it into the Designer area from the Toolbox. @@ -108,22 +108,22 @@ When you drag the SfPdfViewerControl toolbox item to the window, it automaticall The SfPdfViewerControl is available in the [`Syncfusion.Windows.PdfViewer`](https://help.syncfusion.com/cr/UWP/Syncfusion.Windows.PdfViewer.html) namespace and can be created using XAML or programmatically using C#. 1. Add the Syncfusion PDF Viewer namespace. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} -xmlns:syncfusion="using:Syncfusion.Windows.PdfViewer" -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + xmlns:syncfusion="using:Syncfusion.Windows.PdfViewer" + {% endhighlight %} + {% endtabs %} 2. Add SfPdfViewerControl -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + + {% endhighlight %} + {% endtabs %} -{% endtabcontent %} + {% endtabcontent %} -{% endtabcontents %} + {% endtabcontents %} ## Load a PDF document @@ -133,55 +133,54 @@ After adding the `SfPdfViewerControl`, you can load a PDF document using data bi 2. Create a simple class (`PdfReport.cs`) that provides the PDF stream. -N> Replace `PdfViewerExample` in the manifest resource path below with your project's default namespace. + N> Replace `PdfViewerExample` in the manifest resource path below with your project's default namespace. -{% tabs %} + {% tabs %} {% highlight c# tabtitle="PdfReport.cs" %} -using System.Reflection; -using System.IO; + using System.Reflection; + using System.IO; -internal class PdfReport : INotifyPropertyChanged -{ - private Stream docStream; + internal class PdfReport : INotifyPropertyChanged + { + private Stream docStream; - public event PropertyChangedEventHandler PropertyChanged; + public event PropertyChangedEventHandler PropertyChanged; - /// - /// Stream object to be bound to the ItemsSource of the PDF Viewer - /// - public Stream DocumentStream - { - get + /// + /// Stream object to be bound to the ItemsSource of the PDF Viewer + /// + public Stream DocumentStream { - return docStream; + get + { + return docStream; + } + set + { + docStream = value; + OnPropertyChanged(new PropertyChangedEventArgs("DocumentStream")); + } } - set + + public PdfReport() { - docStream = value; - OnPropertyChanged(new PropertyChangedEventArgs("DocumentStream")); - } - } + // Loads the stream from the embedded resource. + Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly; - public PdfReport() - { - // Loads the stream from the embedded resource. - Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly; + // Replace 'PdfViewerExample' with your project's namespace in resource path + docStream = assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); + } - // Replace 'PdfViewerExample' with your project's namespace in resource path - docStream = assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); + public void OnPropertyChanged(PropertyChangedEventArgs e) + { + if (PropertyChanged != null) + PropertyChanged(this, e); + } } - - public void OnPropertyChanged(PropertyChangedEventArgs e) - { - if (PropertyChanged != null) - PropertyChanged(this, e); - } -} - {% endhighlight %} -{% highlight vbnet %} -Class PdfReport + {% highlight vbnet %} + Class PdfReport Implements INotifyPropertyChanged Private docStream As Stream @@ -210,34 +209,34 @@ Class PdfReport RaiseEvent PropertyChanged(Me, e) End Sub -End Class -{% endhighlight %} -{% endtabs %} + End Class + {% endhighlight %} + {% endtabs %} 3. Open the `MainPage.xaml` file again and add the namespace `PdfViewerExample` as local. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - xmlns:local="using:PdfViewerExample" -{% endhighlight %} -{% endtabs %} + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + xmlns:local="using:PdfViewerExample" + {% endhighlight %} + {% endtabs %} 4. Set an instance of the `PdfReport` class as the `DataContext`. Bind the PDF viewer's [ItemSource] to the `DocumentStream` property of the `PdfReport` class. -{% tabs %} -{% highlight xaml tabtitle="MainPage.xaml" %} - - - - - - -{% endhighlight %} -{% endtabs %} - -You can load and display PDF documents using various approaches such as loading from a stream, StorageFile, PdfLoadedDocument, data binding, or FileOpenPicker. - -For detailed information and code examples, refer to [Viewing Pdf](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/uwp/concepts-and-features/viewing-pdf). + {% tabs %} + {% highlight xaml tabtitle="MainPage.xaml" %} + + + + + + + {% endhighlight %} + {% endtabs %} + + You can load and display PDF documents using various approaches such as loading from a stream, StorageFile, PdfLoadedDocument, data binding, or FileOpenPicker. + + For detailed information and code examples, refer to [Viewing Pdf](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/uwp/concepts-and-features/viewing-pdf). ## Run the application