Skip to content

Commit 7491fe5

Browse files
Merge pull request #95 from Suriya-Balamurugan/master
Update the AWS Lambda with latest solution of .NET80
2 parents 734ccf0 + 358cfe5 commit 7491fe5

File tree

19 files changed

+97
-31
lines changed

19 files changed

+97
-31
lines changed

PPTX-to-Image-conversion/Convert-PowerPoint-presentation-to-Image/AWS/AWS_Elastic_Beanstalk/Convert-PowerPoint-Presentation-to-Image/Convert-PowerPoint-Presentation-to-Image.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.6" />
11+
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.8" />
1212
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
1313
</ItemGroup>
1414

PPTX-to-Image-conversion/Convert-PowerPoint-presentation-to-Image/AWS/AWS_Lambda/Convert-PowerPoint-Presentation-to-Image/Convert-PowerPoint-Presentation-to-Image.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net8.0</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@@ -17,12 +17,17 @@
1717
<EmbeddedResource Include="Data\Input.pptx">
1818
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1919
</EmbeddedResource>
20+
<EmbeddedResource Include="Data\calibri.ttf">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</EmbeddedResource>
23+
<EmbeddedResource Include="Data\times.ttf">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</EmbeddedResource>
2026
</ItemGroup>
2127
<ItemGroup>
2228
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
2329
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
24-
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0" />
25-
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.6" />
30+
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.8" />
2631
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
2732
</ItemGroup>
2833
</Project>

PPTX-to-Image-conversion/Convert-PowerPoint-presentation-to-Image/AWS/AWS_Lambda/Convert-PowerPoint-Presentation-to-Image/Function.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Amazon.Lambda.Core;
22
using Syncfusion.Presentation;
33
using Syncfusion.PresentationRenderer;
4+
using Syncfusion.Drawing;
5+
46
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
57
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
68

@@ -17,14 +19,31 @@ public class Function
1719
/// <returns></returns>
1820
public string FunctionHandler(string input, ILambdaContext context)
1921
{
22+
//Path to the original library file.
23+
string originalLibraryPath = "/lib64/libdl.so.2";
24+
25+
//Path to the symbolic link where the library will be copied.
26+
string symlinkLibraryPath = "/tmp/libdl.so";
27+
28+
//Check if the original library file exists.
29+
if (File.Exists(originalLibraryPath))
30+
{
31+
//Copy the original library file to the symbolic link path, overwriting if it already exists.
32+
File.Copy(originalLibraryPath, symlinkLibraryPath, true);
33+
}
34+
2035
string filePath = Path.GetFullPath(@"Data/Input.pptx");
2136
//Open the existing PowerPoint presentation with loaded stream.
2237
using (IPresentation pptxDoc = Presentation.Open(filePath))
2338
{
39+
//Hooks the font substitution event.
40+
pptxDoc.FontSettings.SubstituteFont += FontSettings_SubstituteFont;
2441
//Initialize the PresentationRenderer to perform image conversion.
2542
pptxDoc.PresentationRenderer = new PresentationRenderer();
2643
//Convert PowerPoint slide to image as stream.
2744
Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg);
45+
//Unhooks the font substitution event after converting to image file.
46+
pptxDoc.FontSettings.SubstituteFont -= FontSettings_SubstituteFont;
2847
//Reset the stream position.
2948
stream.Position = 0;
3049
// Create a memory stream to save the image file.
@@ -33,4 +52,13 @@ public string FunctionHandler(string input, ILambdaContext context)
3352
return Convert.ToBase64String(memoryStream.ToArray());
3453
}
3554
}
55+
56+
//Set the alternate font when a specified font is not installed in the production environment.
57+
private void FontSettings_SubstituteFont(object sender, SubstituteFontEventArgs args)
58+
{
59+
if (args.OriginalFontName == "Calibri" && args.FontStyle == FontStyle.Regular)
60+
args.AlternateFontStream = new FileStream(Path.GetFullPath(@"Data/calibri.ttf"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
61+
else
62+
args.AlternateFontStream = new FileStream(Path.GetFullPath(@"Data/times.ttf"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
63+
}
3664
}

PPTX-to-Image-conversion/Convert-PowerPoint-presentation-to-Image/AWS/AWS_Lambda/Convert-PowerPoint-Presentation-to-Image/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"Mock Lambda Test Tool": {
44
"commandName": "Executable",
55
"commandLineArgs": "--port 5050",
6-
"workingDirectory": ".\\bin\\$(Configuration)\\net6.0",
7-
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-6.0.exe"
6+
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
7+
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-8.0.exe"
88
}
99
}
1010
}

PPTX-to-Image-conversion/Convert-PowerPoint-presentation-to-Image/AWS/AWS_Lambda/Convert-PowerPoint-Presentation-to-Image/aws-lambda-tools-defaults.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
"dotnet lambda help",
77
"All the command line options for the Lambda command can be specified in this file."
88
],
9-
"profile" : "default",
9+
"profile" : "AWSLAMBDA",
1010
"region" : "us-east-1",
1111
"configuration" : "Release",
1212
"function-architecture" : "x86_64",
13-
"function-runtime" : "dotnet6",
14-
"function-memory-size" : 256,
13+
"function-runtime" : "dotnet8",
14+
"function-memory-size" : 640,
1515
"function-timeout" : 30,
1616
"function-handler" : "Convert-PowerPoint-Presentation-to-Image::Convert_PowerPoint_Presentation_to_Image.Function::FunctionHandler",
17-
"framework" : "net6.0",
17+
"framework" : "net8.0",
1818
"function-name" : "PPTXtoImageConversion",
1919
"function-description" : "",
2020
"package-type" : "Zip",
21-
"function-role" : "arn:aws:iam::142887710098:role/LambdaRole",
21+
"function-role" : "arn:aws:iam::142887710098:role/ck_lambda_basic_execution",
2222
"function-subnets" : "",
2323
"function-security-groups" : "",
2424
"tracing-mode" : "PassThrough",
25-
"environment-variables" : "",
25+
"environment-variables" : "\"LD_LIBRARY_PATH\"=\"/var/task:/tmp:/lib64:/usr/lib64\"",
2626
"image-tag" : ""
2727
}

PPTX-to-Image-conversion/Convert-PowerPoint-presentation-to-Image/GCP/Google_App_Engine/Convert-PPTX-to-image/Convert-PPTX-to-image.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.6" />
18-
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0" />
17+
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.8" />
18+
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0.2" />
1919
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
2020
</ItemGroup>
2121
</Project>

PPTX-to-PDF-conversion/Convert-PowerPoint-presentation-to-PDF/AWS/AWS_Elastic_Beanstalk/Convert-PowerPoint-Presentation-to-PDF/Convert-PowerPoint-Presentation-to-PDF.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.6" />
11+
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.8" />
1212
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="*" />
1313
</ItemGroup>
1414

0 commit comments

Comments
 (0)