Skip to content

Commit

Permalink
Merge pull request #28 from Venkateshmuruganandam/master
Browse files Browse the repository at this point in the history
Sample added for PPTX to PDF for all platform
  • Loading branch information
MohanaselvamJothi authored Oct 10, 2023
2 parents f32864a + 2022381 commit 0887db6
Show file tree
Hide file tree
Showing 455 changed files with 196,012 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Convert-PowerPoint-Presentation-to-PDF", "Convert-PowerPoint-Presentation-to-PDF\Convert-PowerPoint-Presentation-to-PDF.csproj", "{DC3283BF-B613-48D7-9B82-1B8A41ED48AA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DC3283BF-B613-48D7-9B82-1B8A41ED48AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC3283BF-B613-48D7-9B82-1B8A41ED48AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC3283BF-B613-48D7-9B82-1B8A41ED48AA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{DC3283BF-B613-48D7-9B82-1B8A41ED48AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC3283BF-B613-48D7-9B82-1B8A41ED48AA}.Release|Any CPU.Build.0 = Release|Any CPU
{DC3283BF-B613-48D7-9B82-1B8A41ED48AA}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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:Convert_PowerPoint_Presentation_to_PDF"
x:Class="Convert_PowerPoint_Presentation_to_PDF.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Convert_PowerPoint_Presentation_to_PDF;

public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="Convert_PowerPoint_Presentation_to_PDF.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Convert_PowerPoint_Presentation_to_PDF"
Shell.FlyoutBehavior="Disabled">

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

</Shell>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Convert_PowerPoint_Presentation_to_PDF;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.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);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>Convert_PowerPoint_Presentation_to_PDF</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>Convert-PowerPoint-Presentation-to-PDF</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.convert_powerpoint_presentation_to_pdf</ApplicationId>
<ApplicationIdGuid>fea8b7ef-8927-4708-b772-dec9b09b21d1</ApplicationIdGuid>

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

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.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.svg" BaseSize="168,208" />

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

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

<ItemGroup>
<None Remove="Assets\Input.pptx" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Assets\Input.pptx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.PresentationRenderer.NET" Version="*" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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"
x:Class="Convert_PowerPoint_Presentation_to_PDF.MainPage">

<ScrollView>
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,*"
Padding="{OnPlatform iOS='30,60,30,30', Default='30'}">
<Button
Text="Convert PPTX to PDF"
FontAttributes="Bold"
Grid.Row="0"
SemanticProperties.Hint="Convert PPTX to PDF"
Clicked="ConvertPPTXtoPDF"
HorizontalOptions="Center" />
</Grid>
</ScrollView>

</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;
using Syncfusion.Pdf;
using System.Reflection;
using Convert_PowerPoint_Presentation_to_PDF.SaveServices;

namespace Convert_PowerPoint_Presentation_to_PDF;

public partial class MainPage : ContentPage
{
int count = 0;

public MainPage()
{
InitializeComponent();
}

private void ConvertPPTXtoPDF(object sender, EventArgs e)
{
//Loading an existing PowerPoint presentation
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
//Open the existing PowerPoint presentation with loaded stream.
using (IPresentation pptxDoc = Presentation.Open(assembly.GetManifestResourceStream("Convert_PowerPoint_Presentation_to_PDF.Assets.Input.pptx")))
{
//Convert the PowerPoint document to PDF document.
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
{
//Save the converted PDF document to MemoryStream.
MemoryStream pdfStream = new MemoryStream();
pdfDocument.Save(pdfStream);
pdfStream.Position = 0;
//save and Launch the PDF document
SaveService saveService = new();
saveService.SaveAndView("Sample.pdf", "application/pdf", pdfStream);
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Convert_PowerPoint_Presentation_to_PDF;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

return builder.Build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.convert_PPTX_to_PDF">

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />

<application android:label="Convert_PowerPoint_Presentation_to_PDF.Android" android:theme="@style/MainTheme">

<provider android:name="androidx.core.content.FileProvider"

android:authorities="${applicationId}.provider"

android:exported="false"

android:grantUriPermissions="true">

<meta-data android:name="android.support.FILE_PROVIDER_PATHS"

android:resource="@xml/provider_paths" />

</provider>

</application>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace Convert_PowerPoint_Presentation_to_PDF;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Android.App;
using Android.Runtime;

namespace Convert_PowerPoint_Presentation_to_PDF;

[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>

<paths xmlns:android="http://schemas.android.com/apk/res/android">

<external-path name="external_files" path="."/>

</paths>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Android.Content;
using Android.OS;
using Java.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Convert_PowerPoint_Presentation_to_PDF.SaveServices
{
public partial class SaveService
{
public partial void SaveAndView(string filename, string contentType, MemoryStream stream)
{
string exception = string.Empty;
string? root = null;

if (Android.OS.Environment.IsExternalStorageEmulated)
{
root = Android.App.Application.Context!.GetExternalFilesDir(Android.OS.Environment.DirectoryDownloads)!.AbsolutePath;
}
else
root = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);

Java.IO.File myDir = new(root + "/Syncfusion");
myDir.Mkdir();

Java.IO.File file = new(myDir, filename);

if (file.Exists())
{
file.Delete();
}

try
{
FileOutputStream outs = new(file);
outs.Write(stream.ToArray());

outs.Flush();
outs.Close();
}
catch (Exception e)
{
exception = e.ToString();
}
if (file.Exists())
{
Android.Net.Uri path = Android.Net.Uri.FromFile(file);

string extension = Android.Webkit.MimeTypeMap.GetFileExtensionFromUrl(Android.Net.Uri.FromFile(file).ToString());

string mimeType = Android.Webkit.MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension);

Intent intent = new Intent(Intent.ActionView);

intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask);

path = FileProvider.GetUriForFile(Android.App.Application.Context, Android.App.Application.Context.PackageName + ".provider", file);

intent.SetDataAndType(path, mimeType);

intent.AddFlags(ActivityFlags.GrantReadUriPermission);

Android.App.Application.Context.StartActivity(intent);

}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Foundation;

namespace Convert_PowerPoint_Presentation_to_PDF;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Loading

0 comments on commit 0887db6

Please sign in to comment.