Skip to content

865752 - Create a blog sample for how to load and save files from AWS cloud storage #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Save/AutoSavePDFinAWS/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AutoSavePDFinAWS"
xmlns:converters="clr-namespace:AutoSavePDFinAWS"
x:Class="AutoSavePDFinAWS.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
</ResourceDictionary>
</Application.Resources>
</Application>
16 changes: 16 additions & 0 deletions Save/AutoSavePDFinAWS/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace AutoSavePDFinAWS
{
public partial class App : Application
{
public App()
{
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Add valid license key");
InitializeComponent();
}

protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new AppShell());
}
}
}
14 changes: 14 additions & 0 deletions Save/AutoSavePDFinAWS/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="AutoSavePDFinAWS.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AutoSavePDFinAWS"
Title="AutoSavePDFinAWS">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
10 changes: 10 additions & 0 deletions Save/AutoSavePDFinAWS/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace AutoSavePDFinAWS
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
69 changes: 69 additions & 0 deletions Save/AutoSavePDFinAWS/AutoSavePDFinAWS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net9.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>AutoSavePDFinAWS</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>AutoSavePDFinAWS</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.autosavepdfinaws</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
<WindowsPackageType>None</WindowsPackageType>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="*" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
<PackageReference Include="Syncfusion.Maui.PdfViewer" Version="*" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions Save/AutoSavePDFinAWS/AutoSavePDFinAWS.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

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}") = "AutoSavePDFinAWS", "AutoSavePDFinAWS.csproj", "{626306A7-D53A-409E-A65E-2D1D3714EC3F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{626306A7-D53A-409E-A65E-2D1D3714EC3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{626306A7-D53A-409E-A65E-2D1D3714EC3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{626306A7-D53A-409E-A65E-2D1D3714EC3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{626306A7-D53A-409E-A65E-2D1D3714EC3F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BADD224A-DD7D-497F-A2D1-4D59A4DC92AA}
EndGlobalSection
EndGlobal
51 changes: 51 additions & 0 deletions Save/AutoSavePDFinAWS/Converter/InverseBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoSavePDFinAWS
{
/// <summary>
/// Value converter that inverts boolean values for data binding scenarios.
/// Used in XAML to bind UI elements that need the opposite of a boolean property.
/// For example, enabling a Save button when Auto-Save is disabled.
/// </summary>
public class InverseBooleanConverter : IValueConverter
{
/// <summary>
/// Converts a boolean value to its inverse.
/// </summary>
/// <param name="value">The boolean value to convert</param>
/// <param name="targetType">The type of the binding target property (must be bool)</param>
/// <param name="parameter">Optional parameter for the converter (not used)</param>
/// <param name="culture">Culture information for the conversion (not used)</param>
/// <returns>The inverted boolean value</returns>
/// <exception cref="InvalidOperationException">Thrown when target type is not boolean</exception>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// Validate that the target type is boolean
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be a boolean");

// Return the inverse of the input boolean value
return value is bool boolValue ? !boolValue : false;
}

/// <summary>
/// Converts back from the inverted value to the original (not supported).
/// This converter is designed for one-way binding only.
/// </summary>
/// <param name="value">The value to convert back</param>
/// <param name="targetType">The type to convert to</param>
/// <param name="parameter">Optional parameter for the converter</param>
/// <param name="culture">Culture information for the conversion</param>
/// <returns>Not supported</returns>
/// <exception cref="NotSupportedException">Always thrown as this operation is not supported</exception>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException("InverseBooleanConverter does not support ConvertBack operation");
}
}
}
120 changes: 120 additions & 0 deletions Save/AutoSavePDFinAWS/MainPage.xaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorten the following XML comments

...

...

...

...

...

...

...

...

...

...

...

...

Shortened format

...

...

...

...

...

...

...

...

...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the xml comments

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pdfViewer="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer"
x:Class="AutoSavePDFinAWS.MainPage">

<!-- UI resource definitions -->
<ContentPage.Resources>
<ResourceDictionary>

<!-- Toolbar button style -->
<Style x:Key="ToolbarButtonStyle"
TargetType="Button">
<Setter Property="CornerRadius"
Value="6" />
<Setter Property="Padding"
Value="10,6" />
<Setter Property="Margin"
Value="5,0" />
<Setter Property="BackgroundColor"
Value="#3B82F6" />
<Setter Property="TextColor"
Value="White" />
<Setter Property="FontAttributes"
Value="Bold" />

<!-- Visual states for button -->
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup Name="CommonStates">
<!-- Normal state - default blue appearance -->
<VisualState Name="Normal" />

<!-- Disabled state - muted gray appearance -->
<VisualState Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="#E5E7EB" />
<Setter Property="TextColor"
Value="#1F2937" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ResourceDictionary>
</ContentPage.Resources>

<!-- Main layout grid -->
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<!-- Toolbar row - auto-sized -->
<RowDefinition Height="*" />
<!-- PDF viewer row - fills remaining space -->
</Grid.RowDefinitions>

<!-- Toolbar -->
<Border Grid.Row="0"
BackgroundColor="#F3F4F6"
Padding="12"
StrokeThickness="0">
<Grid ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<!-- Notification area - takes remaining space -->
<ColumnDefinition Width="Auto" />
<!-- Button area - auto-sized -->
</Grid.ColumnDefinitions>

<!-- Status notification label -->
<Label Grid.Column="0"
x:Name="NotificationLabel"
Text="{Binding NotificationText}"
HorizontalOptions="Start"
VerticalOptions="Center" />

<!-- Toolbar controls -->
<HorizontalStackLayout Grid.Column="1">

<!-- Save button (manual) -->
<Button x:Name="SaveButton"
FontSize="20"
Text="&#xe75f;"
VerticalOptions="Center"
FontFamily="MauiMaterialAssets"
ToolTipProperties.Text="Save PDF file manually"
Style="{StaticResource ToolbarButtonStyle}"
Command="{Binding SavePdfCommand}"
IsEnabled="{Binding IsAutoSaveEnabled, Converter={StaticResource InverseBooleanConverter}}"/>

<!-- Auto-save toggle -->
<Border StrokeThickness="1"
Padding="0,0,12,0"
Margin="4,0"
Stroke="LightGray"
VerticalOptions="Center">
<StackLayout Orientation="Horizontal" VerticalOptions="Center">
<CheckBox IsChecked="{Binding IsAutoSaveEnabled}" VerticalOptions="Center" />
<Label Text="Auto Save" VerticalOptions="Center" />
</StackLayout>
</Border>

</HorizontalStackLayout>
</Grid>
</Border>

<!-- PDF Viewer with event handlers -->
<pdfViewer:SfPdfViewer Grid.Row="1"
x:Name="PdfViewer"
DocumentLoaded="PdfViewer_DocumentLoaded"
DocumentUnloaded="PdfViewer_DocumentUnloaded"
AnnotationAdded="PdfViewer_AnnotationAdded"
AnnotationRemoved="PdfViewer_AnnotationRemoved"
AnnotationEdited="PdfViewer_AnnotationEdited"
FormFieldValueChanged="PdfViewer_FormFieldValueChanged" />
</Grid>

</ContentPage>
Loading