diff --git a/MultiTabbedPDFViewer/App.xaml b/MultiTabbedPDFViewer/App.xaml new file mode 100644 index 0000000..2185ff8 --- /dev/null +++ b/MultiTabbedPDFViewer/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/MultiTabbedPDFViewer/App.xaml.cs b/MultiTabbedPDFViewer/App.xaml.cs new file mode 100644 index 0000000..7c8d59c --- /dev/null +++ b/MultiTabbedPDFViewer/App.xaml.cs @@ -0,0 +1,16 @@ +namespace MultiTabbedPDFViewer +{ + public partial class App : Application + { + public App() + { + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Add Valid License"); + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new AppShell()); + } + } +} \ No newline at end of file diff --git a/MultiTabbedPDFViewer/AppShell.xaml b/MultiTabbedPDFViewer/AppShell.xaml new file mode 100644 index 0000000..70a3c90 --- /dev/null +++ b/MultiTabbedPDFViewer/AppShell.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/MultiTabbedPDFViewer/AppShell.xaml.cs b/MultiTabbedPDFViewer/AppShell.xaml.cs new file mode 100644 index 0000000..846cfe5 --- /dev/null +++ b/MultiTabbedPDFViewer/AppShell.xaml.cs @@ -0,0 +1,10 @@ +namespace MultiTabbedPDFViewer +{ + public partial class AppShell : Shell + { + public AppShell() + { + InitializeComponent(); + } + } +} diff --git a/MultiTabbedPDFViewer/Assets/Annotations.pdf b/MultiTabbedPDFViewer/Assets/Annotations.pdf new file mode 100644 index 0000000..e949846 Binary files /dev/null and b/MultiTabbedPDFViewer/Assets/Annotations.pdf differ diff --git a/MultiTabbedPDFViewer/Assets/PDF_Succinctly.pdf b/MultiTabbedPDFViewer/Assets/PDF_Succinctly.pdf new file mode 100644 index 0000000..a5d6396 Binary files /dev/null and b/MultiTabbedPDFViewer/Assets/PDF_Succinctly.pdf differ diff --git a/MultiTabbedPDFViewer/Assets/restrictedDocument.pdf b/MultiTabbedPDFViewer/Assets/restrictedDocument.pdf new file mode 100644 index 0000000..d7fefac Binary files /dev/null and b/MultiTabbedPDFViewer/Assets/restrictedDocument.pdf differ diff --git a/MultiTabbedPDFViewer/MainPage.xaml b/MultiTabbedPDFViewer/MainPage.xaml new file mode 100644 index 0000000..92ba641 --- /dev/null +++ b/MultiTabbedPDFViewer/MainPage.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + diff --git a/MultiTabbedPDFViewer/MainPage.xaml.cs b/MultiTabbedPDFViewer/MainPage.xaml.cs new file mode 100644 index 0000000..583c8a8 --- /dev/null +++ b/MultiTabbedPDFViewer/MainPage.xaml.cs @@ -0,0 +1,50 @@ +using Syncfusion.Maui.PdfViewer; + +namespace MultiTabbedPDFViewer +{ + public partial class MainPage : ContentPage + { + // Create three instances of SfPdfViewer for displaying PDF documents + SfPdfViewer pdfViewer1 = new SfPdfViewer(); + SfPdfViewer pdfViewer2 = new SfPdfViewer(); + SfPdfViewer pdfViewer3 = new SfPdfViewer(); + + public MainPage() + { + InitializeComponent(); + + // Set the zoom mode of three PDF viewers to fit the width of the container + pdfViewer1.ZoomMode = ZoomMode.FitToWidth; + pdfViewer2.ZoomMode = ZoomMode.FitToWidth; + pdfViewer3.ZoomMode = ZoomMode.FitToWidth; + } + + private void SfTabView_Loaded(System.Object sender, System.EventArgs e) + { + // Ensure the viewModel is not null before proceeding + if (viewModel?.PDFDocuments != null) + { + // Check if the first tab's header matches "doc 1" + if (tab1.Header.Equals("doc 1")) + { + pdfViewer1.DocumentSource = viewModel.PDFDocuments[0]; // Assign the stream to the "DocumentSource" property of the PdfViewer control + tab1.Content = pdfViewer1; // Set the content of tab1 to the pdfViewer1. + } + + // Check if the second tab's header matches "doc 2" + if (tab2.Header.Equals("doc 2")) + { + pdfViewer2.DocumentSource = viewModel.PDFDocuments[1]; // Assign the stream to the "DocumentSource" property of the PdfViewer control + tab2.Content = pdfViewer2; // Set the content of tab2 to the pdfViewer2. + } + + // Check if the third tab's header matches "doc 3" + if (tab3.Header.Equals("doc 3")) + { + pdfViewer3.DocumentSource = viewModel.PDFDocuments[2]; // Assign the stream to the "DocumentSource" property of the PdfViewer control + tab3.Content = pdfViewer3; // Set the content of tab3 to the pdfViewer3. + } + } + } + } +} diff --git a/MultiTabbedPDFViewer/MauiProgram.cs b/MultiTabbedPDFViewer/MauiProgram.cs new file mode 100644 index 0000000..d89f8cf --- /dev/null +++ b/MultiTabbedPDFViewer/MauiProgram.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.Logging; +using Syncfusion.Maui.Core.Hosting; + +namespace MultiTabbedPDFViewer +{ + public static class MauiProgram + { + public static MauiApp CreateMauiApp() + { + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .ConfigureSyncfusionCore() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); + }); + +#if DEBUG + builder.Logging.AddDebug(); +#endif + + return builder.Build(); + } + } +} diff --git a/MultiTabbedPDFViewer/MultiTabbedPDFViewer.csproj b/MultiTabbedPDFViewer/MultiTabbedPDFViewer.csproj new file mode 100644 index 0000000..bb949d5 --- /dev/null +++ b/MultiTabbedPDFViewer/MultiTabbedPDFViewer.csproj @@ -0,0 +1,81 @@ + + + + net9.0-android;net9.0-ios;net9.0-maccatalyst + $(TargetFrameworks);net9.0-windows10.0.19041.0 + + + + + + + Exe + MultiTabbedPDFViewer + true + true + enable + enable + + + MultiTabbedPDFViewer + + + com.companyname.multitabbedpdfviewer + + + 1.0 + 1 + + + None + + 15.0 + 15.0 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MultiTabbedPDFViewer/MultiTabbedPDFViewer.sln b/MultiTabbedPDFViewer/MultiTabbedPDFViewer.sln new file mode 100644 index 0000000..7b86aa8 --- /dev/null +++ b/MultiTabbedPDFViewer/MultiTabbedPDFViewer.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36203.30 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiTabbedPDFViewer", "MultiTabbedPDFViewer.csproj", "{6119F92A-82CA-4073-860B-B0FEBAA36FA4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6119F92A-82CA-4073-860B-B0FEBAA36FA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6119F92A-82CA-4073-860B-B0FEBAA36FA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6119F92A-82CA-4073-860B-B0FEBAA36FA4}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {6119F92A-82CA-4073-860B-B0FEBAA36FA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6119F92A-82CA-4073-860B-B0FEBAA36FA4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DECAFE2E-7A6F-4AAF-BCEA-E7908101E682} + EndGlobalSection +EndGlobal diff --git a/MultiTabbedPDFViewer/Platforms/Android/AndroidManifest.xml b/MultiTabbedPDFViewer/Platforms/Android/AndroidManifest.xml new file mode 100644 index 0000000..e9937ad --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Android/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Platforms/Android/MainActivity.cs b/MultiTabbedPDFViewer/Platforms/Android/MainActivity.cs new file mode 100644 index 0000000..b733d4a --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Android/MainActivity.cs @@ -0,0 +1,11 @@ +using Android.App; +using Android.Content.PM; +using Android.OS; + +namespace MultiTabbedPDFViewer +{ + [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] + public class MainActivity : MauiAppCompatActivity + { + } +} diff --git a/MultiTabbedPDFViewer/Platforms/Android/MainApplication.cs b/MultiTabbedPDFViewer/Platforms/Android/MainApplication.cs new file mode 100644 index 0000000..4998843 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Android/MainApplication.cs @@ -0,0 +1,16 @@ +using Android.App; +using Android.Runtime; + +namespace MultiTabbedPDFViewer +{ + [Application] + public class MainApplication : MauiApplication + { + public MainApplication(IntPtr handle, JniHandleOwnership ownership) + : base(handle, ownership) + { + } + + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + } +} diff --git a/MultiTabbedPDFViewer/Platforms/Android/Resources/values/colors.xml b/MultiTabbedPDFViewer/Platforms/Android/Resources/values/colors.xml new file mode 100644 index 0000000..c04d749 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Android/Resources/values/colors.xml @@ -0,0 +1,6 @@ + + + #512BD4 + #2B0B98 + #2B0B98 + \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Platforms/MacCatalyst/AppDelegate.cs b/MultiTabbedPDFViewer/Platforms/MacCatalyst/AppDelegate.cs new file mode 100644 index 0000000..dfb452b --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/MacCatalyst/AppDelegate.cs @@ -0,0 +1,10 @@ +using Foundation; + +namespace MultiTabbedPDFViewer +{ + [Register("AppDelegate")] + public class AppDelegate : MauiUIApplicationDelegate + { + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + } +} diff --git a/MultiTabbedPDFViewer/Platforms/MacCatalyst/Entitlements.plist b/MultiTabbedPDFViewer/Platforms/MacCatalyst/Entitlements.plist new file mode 100644 index 0000000..de4adc9 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/MacCatalyst/Entitlements.plist @@ -0,0 +1,14 @@ + + + + + + + com.apple.security.app-sandbox + + + com.apple.security.network.client + + + + diff --git a/MultiTabbedPDFViewer/Platforms/MacCatalyst/Info.plist b/MultiTabbedPDFViewer/Platforms/MacCatalyst/Info.plist new file mode 100644 index 0000000..7268977 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/MacCatalyst/Info.plist @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + UIDeviceFamily + + 2 + + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + XSAppIconAssets + Assets.xcassets/appicon.appiconset + + diff --git a/MultiTabbedPDFViewer/Platforms/MacCatalyst/Program.cs b/MultiTabbedPDFViewer/Platforms/MacCatalyst/Program.cs new file mode 100644 index 0000000..dca0cc4 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/MacCatalyst/Program.cs @@ -0,0 +1,16 @@ +using ObjCRuntime; +using UIKit; + +namespace MultiTabbedPDFViewer +{ + public class Program + { + // This is the main entry point of the application. + static void Main(string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, typeof(AppDelegate)); + } + } +} diff --git a/MultiTabbedPDFViewer/Platforms/Tizen/Main.cs b/MultiTabbedPDFViewer/Platforms/Tizen/Main.cs new file mode 100644 index 0000000..bce8ce7 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Tizen/Main.cs @@ -0,0 +1,17 @@ +using System; +using Microsoft.Maui; +using Microsoft.Maui.Hosting; + +namespace MultiTabbedPDFViewer +{ + internal class Program : MauiApplication + { + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + } +} diff --git a/MultiTabbedPDFViewer/Platforms/Tizen/tizen-manifest.xml b/MultiTabbedPDFViewer/Platforms/Tizen/tizen-manifest.xml new file mode 100644 index 0000000..f77521a --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Tizen/tizen-manifest.xml @@ -0,0 +1,15 @@ + + + + + + maui-appicon-placeholder + + + + + http://tizen.org/privilege/internet + + + + \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Platforms/Windows/App.xaml b/MultiTabbedPDFViewer/Platforms/Windows/App.xaml new file mode 100644 index 0000000..085c5b0 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Windows/App.xaml @@ -0,0 +1,8 @@ + + + diff --git a/MultiTabbedPDFViewer/Platforms/Windows/App.xaml.cs b/MultiTabbedPDFViewer/Platforms/Windows/App.xaml.cs new file mode 100644 index 0000000..7d0ee23 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Windows/App.xaml.cs @@ -0,0 +1,25 @@ +using Microsoft.UI.Xaml; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace MultiTabbedPDFViewer.WinUI +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + public partial class App : MauiWinUIApplication + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + } + + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + } + +} diff --git a/MultiTabbedPDFViewer/Platforms/Windows/Package.appxmanifest b/MultiTabbedPDFViewer/Platforms/Windows/Package.appxmanifest new file mode 100644 index 0000000..0c20e3d --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Windows/Package.appxmanifest @@ -0,0 +1,46 @@ + + + + + + + + + $placeholder$ + User Name + $placeholder$.png + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MultiTabbedPDFViewer/Platforms/Windows/app.manifest b/MultiTabbedPDFViewer/Platforms/Windows/app.manifest new file mode 100644 index 0000000..0700e83 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/Windows/app.manifest @@ -0,0 +1,15 @@ + + + + + + + + true/PM + PerMonitorV2, PerMonitor + + + diff --git a/MultiTabbedPDFViewer/Platforms/iOS/AppDelegate.cs b/MultiTabbedPDFViewer/Platforms/iOS/AppDelegate.cs new file mode 100644 index 0000000..dfb452b --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/iOS/AppDelegate.cs @@ -0,0 +1,10 @@ +using Foundation; + +namespace MultiTabbedPDFViewer +{ + [Register("AppDelegate")] + public class AppDelegate : MauiUIApplicationDelegate + { + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + } +} diff --git a/MultiTabbedPDFViewer/Platforms/iOS/Info.plist b/MultiTabbedPDFViewer/Platforms/iOS/Info.plist new file mode 100644 index 0000000..0004a4f --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/iOS/Info.plist @@ -0,0 +1,32 @@ + + + + + LSRequiresIPhoneOS + + UIDeviceFamily + + 1 + 2 + + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + XSAppIconAssets + Assets.xcassets/appicon.appiconset + + diff --git a/MultiTabbedPDFViewer/Platforms/iOS/Program.cs b/MultiTabbedPDFViewer/Platforms/iOS/Program.cs new file mode 100644 index 0000000..dca0cc4 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/iOS/Program.cs @@ -0,0 +1,16 @@ +using ObjCRuntime; +using UIKit; + +namespace MultiTabbedPDFViewer +{ + public class Program + { + // This is the main entry point of the application. + static void Main(string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, typeof(AppDelegate)); + } + } +} diff --git a/MultiTabbedPDFViewer/Platforms/iOS/Resources/PrivacyInfo.xcprivacy b/MultiTabbedPDFViewer/Platforms/iOS/Resources/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..24ab3b4 --- /dev/null +++ b/MultiTabbedPDFViewer/Platforms/iOS/Resources/PrivacyInfo.xcprivacy @@ -0,0 +1,51 @@ + + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryDiskSpace + NSPrivacyAccessedAPITypeReasons + + E174.1 + + + + + + diff --git a/MultiTabbedPDFViewer/Properties/launchSettings.json b/MultiTabbedPDFViewer/Properties/launchSettings.json new file mode 100644 index 0000000..4f85793 --- /dev/null +++ b/MultiTabbedPDFViewer/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Windows Machine": { + "commandName": "Project", + "nativeDebugging": false + } + } +} \ No newline at end of file diff --git a/MultiTabbedPDFViewer/README.md b/MultiTabbedPDFViewer/README.md new file mode 100644 index 0000000..a6d5ccc --- /dev/null +++ b/MultiTabbedPDFViewer/README.md @@ -0,0 +1,211 @@ +# How to use SfPdfViewer inside SfTabView? + +This project demonstrates how to initialize a .NET MAUI PdfViewer inside the SfTabView control. + +## Prerequisites + +1. A .NET MAUI project set up. +2. The [Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) package is installed. + +## Steps + +### 1.Install Required NuGet Package + +To get started, create a new [Maui App](https://dotnet.microsoft.com/en-us/learn/maui/first-app-tutorial/create) and ensure the following package is installed in your .NET MAUI project: + +[Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) + +You can install this package using the NuGet Package Manager or the NuGet CLI. + +### 2. Initialize the TabView in XAML + +Start by adding the Syncfusion TabView control to your XAML file. + +**a. Add the Syncfusion namespace in your MainPage.xaml:** + +Define the XAML namespace to enable access to the TabView. + +**XAML:** + +```xaml + xmlns:tabView="clr-namespace:Syncfusion.Maui.TabView;assembly=Syncfusion.Maui.TabView" +``` + +**b. Add the TabView control to your layout:** + +Initialize the TabView in the XAML file. This will display the TabView with three tab item in your app. + +**XAML:** + +```xaml + + + + + + + + + + +``` + +### 3. Initialize the PdfViewer. + +**a. Add the Syncfusion namespace in your MainPage.xaml:** + +Define the XAML namespace to enable access to the PdfViewer. + +**XAML:** + +```xaml + xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" +``` + +**b. Create instance of PdfViewer control in you MainPage.cs:** + +**C#:** + +```csharp + // Create three instances of SfPdfViewer for displaying PDF documents + SfPdfViewer pdfViewer1 = new SfPdfViewer(); + SfPdfViewer pdfViewer2 = new SfPdfViewer(); + SfPdfViewer pdfViewer3 = new SfPdfViewer(); +``` + +### 4. Set the ZoomMode for the two PdfViewer instance in the `MainPage.cs` file. + +In the MainPage constructor, set the [ZoomMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#fields) for the two PdfViewer instance as [ZoomMode.FitToWidth](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#Syncfusion_Maui_PdfViewer_ZoomMode_FitToWidth). + +**C#:** + +```csharp + // Set the zoom mode of three PDF viewers to fit the width of the container + pdfViewer1.ZoomMode = ZoomMode.FitToWidth; + pdfViewer2.ZoomMode = ZoomMode.FitToWidth; + pdfViewer3.ZoomMode = ZoomMode.FitToWidth; +``` + +### 5. PdfViewerViewModel class + +**C#:** + +```csharp + public class PdfViewerViewModel : INotifyPropertyChanged + { + private ObservableCollection? _pdfDocuments; + + /// + /// Constructor of the view model class + /// + public PdfViewerViewModel() + { + // Initialize the collection + PDFDocuments = new ObservableCollection(); + + //Accessing the PDF document that is added as embedded resource as stream. + Stream? documentSource1 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.PDF_Succinctly.pdf"); + Stream? documentSource2 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.rotated_document.pdf"); + Stream? documentSource3 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.Annotations.pdf"); + // Add the PDF streams to the collection if they are successfully retrieved + if (documentSource1 != null) + PDFDocuments.Add(documentSource1); + if (documentSource2 != null) + PDFDocuments.Add(documentSource2); + if (documentSource3 != null) + PDFDocuments.Add(documentSource3); + } + + /// + /// Collection of PDF document streams. + /// + public ObservableCollection? PDFDocuments + { + get => _pdfDocuments; + set + { + _pdfDocuments = value; + OnPropertyChanged(nameof(PDFDocuments)); + } + } + + /// + /// An event to detect the change in the value of a property. + /// + public event PropertyChangedEventHandler? PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +``` + +### 6. Loading the pdfViewer in different tabs using the SfTabView Loaded event handler. + +In the SfTabView `Loaded` event handler, evaluate the header text of each SfTabItem. Based on the header, assign the appropriate PDF stream to the [DocumentSource](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentSource) property of the corresponding SfPdfViewer instance. Then, set that PdfViewer instance as the content of the respective SfTabItem + +**C#:** + +```csharp + private void SfTabView_Loaded(System.Object sender, System.EventArgs e) + { + // Ensure the viewModel is not null before proceeding + if (viewModel?.PDFDocuments != null) + { + // Check if the first tab's header matches "doc 1" + if (tab1.Header.Equals("doc 1")) + { + pdfViewer1.DocumentSource = viewModel.PDFDocuments[0]; // Assign the stream to the "DocumentSource" property of the PdfViewer control + tab1.Content = pdfViewer1; // Set the content of tab1 to the pdfViewer1. + } + + // Check if the second tab's header matches "doc 2" + if (tab2.Header.Equals("doc 2")) + { + pdfViewer2.DocumentSource = viewModel.PDFDocuments[1]; // Assign the stream to the "DocumentSource" property of the PdfViewer control + tab2.Content = pdfViewer2; // Set the content of tab2 to the pdfViewer2. + } + + // Check if the third tab's header matches "doc 3" + if (tab3.Header.Equals("doc 3")) + { + pdfViewer3.DocumentSource = viewModel.PDFDocuments[2]; // Assign the stream to the "DocumentSource" property of the PdfViewer control + tab3.Content = pdfViewer3; // Set the content of tab3 to the pdfViewer3. + } + } + } +``` + +### 6. Subscription of TabView Loaded event. + +For to load the pdf document in the TabView, wire the Loaded event + +**XAML:** + +```xaml + + + + + + + + + + +``` + +## Run the App + +1. Build and run the application in all the platforms. +2. Switch the tabs. +3. Add some annotations in all PdfViewer tabs. +4. Make some text selection in all PdfViewer tabs. +5. Do search process in all PdfViewer tabs. \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Resources/AppIcon/appicon.svg b/MultiTabbedPDFViewer/Resources/AppIcon/appicon.svg new file mode 100644 index 0000000..9d63b65 --- /dev/null +++ b/MultiTabbedPDFViewer/Resources/AppIcon/appicon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Resources/AppIcon/appiconfg.svg b/MultiTabbedPDFViewer/Resources/AppIcon/appiconfg.svg new file mode 100644 index 0000000..21dfb25 --- /dev/null +++ b/MultiTabbedPDFViewer/Resources/AppIcon/appiconfg.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Resources/Fonts/OpenSans-Regular.ttf b/MultiTabbedPDFViewer/Resources/Fonts/OpenSans-Regular.ttf new file mode 100644 index 0000000..33b3e0d Binary files /dev/null and b/MultiTabbedPDFViewer/Resources/Fonts/OpenSans-Regular.ttf differ diff --git a/MultiTabbedPDFViewer/Resources/Fonts/OpenSans-Semibold.ttf b/MultiTabbedPDFViewer/Resources/Fonts/OpenSans-Semibold.ttf new file mode 100644 index 0000000..a1f8571 Binary files /dev/null and b/MultiTabbedPDFViewer/Resources/Fonts/OpenSans-Semibold.ttf differ diff --git a/MultiTabbedPDFViewer/Resources/Images/dotnet_bot.png b/MultiTabbedPDFViewer/Resources/Images/dotnet_bot.png new file mode 100644 index 0000000..1d1b981 Binary files /dev/null and b/MultiTabbedPDFViewer/Resources/Images/dotnet_bot.png differ diff --git a/MultiTabbedPDFViewer/Resources/Raw/AboutAssets.txt b/MultiTabbedPDFViewer/Resources/Raw/AboutAssets.txt new file mode 100644 index 0000000..89dc758 --- /dev/null +++ b/MultiTabbedPDFViewer/Resources/Raw/AboutAssets.txt @@ -0,0 +1,15 @@ +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories). Deployment of the asset to your application +is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. + + + +These files will be deployed with your package and will be accessible using Essentials: + + async Task LoadMauiAsset() + { + using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); + using var reader = new StreamReader(stream); + + var contents = reader.ReadToEnd(); + } diff --git a/MultiTabbedPDFViewer/Resources/Splash/splash.svg b/MultiTabbedPDFViewer/Resources/Splash/splash.svg new file mode 100644 index 0000000..21dfb25 --- /dev/null +++ b/MultiTabbedPDFViewer/Resources/Splash/splash.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Resources/Styles/Colors.xaml b/MultiTabbedPDFViewer/Resources/Styles/Colors.xaml new file mode 100644 index 0000000..30307a5 --- /dev/null +++ b/MultiTabbedPDFViewer/Resources/Styles/Colors.xaml @@ -0,0 +1,45 @@ + + + + + + + #512BD4 + #ac99ea + #242424 + #DFD8F7 + #9880e5 + #2B0B98 + + White + Black + #D600AA + #190649 + #1f1f1f + + #E1E1E1 + #C8C8C8 + #ACACAC + #919191 + #6E6E6E + #404040 + #212121 + #141414 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MultiTabbedPDFViewer/Resources/Styles/Styles.xaml b/MultiTabbedPDFViewer/Resources/Styles/Styles.xaml new file mode 100644 index 0000000..86f574d --- /dev/null +++ b/MultiTabbedPDFViewer/Resources/Styles/Styles.xaml @@ -0,0 +1,451 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MultiTabbedPDFViewer/ViewModel/PdfViewerViewModel.cs b/MultiTabbedPDFViewer/ViewModel/PdfViewerViewModel.cs new file mode 100644 index 0000000..bec86cd --- /dev/null +++ b/MultiTabbedPDFViewer/ViewModel/PdfViewerViewModel.cs @@ -0,0 +1,54 @@ +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Reflection; + +namespace MultiTabbedPDFViewer +{ + public class PdfViewerViewModel : INotifyPropertyChanged + { + private ObservableCollection? _pdfDocuments; + + /// + /// Constructor of the view model class + /// + public PdfViewerViewModel() + { + // Initialize the collection + PDFDocuments = new ObservableCollection(); + + //Accessing the PDF document that is added as embedded resource as stream. + Stream? documentSource1 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.PDF_Succinctly.pdf"); + Stream? documentSource2 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.restrictedDocument.pdf"); + Stream? documentSource3 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.Annotations.pdf"); + // Add the PDF streams to the collection if they are successfully retrieved + if (documentSource1 != null) + PDFDocuments.Add(documentSource1); + if (documentSource2 != null) + PDFDocuments.Add(documentSource2); + if (documentSource3 != null) + PDFDocuments.Add(documentSource3); + } + + /// + /// Collection of PDF document streams. + /// + public ObservableCollection? PDFDocuments + { + get => _pdfDocuments; + set + { + _pdfDocuments = value; + OnPropertyChanged(nameof(PDFDocuments)); + } + } + + /// + /// An event to detect the change in the value of a property. + /// + public event PropertyChangedEventHandler? PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +}