Skip to content

Commit

Permalink
Merge pull request #100 from SureshGanesanSF4645/master
Browse files Browse the repository at this point in the history
Update GitHub for FT samples
  • Loading branch information
MohanaselvamJothi authored Nov 29, 2024
2 parents 6209edf + d16ca46 commit bf09118
Show file tree
Hide file tree
Showing 35 changed files with 227 additions and 70 deletions.
Binary file not shown.
25 changes: 25 additions & 0 deletions Charts/Create-simple-pie-chart/.NET/Create-simple-pie-chart.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.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-simple-pie-chart", "Create-simple-pie-chart\Create-simple-pie-chart.csproj", "{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC263D1D-3AA3-4B8E-B158-B02C0FF627CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C73989D0-3A0F-40E1-9FAA-E04EB4173B7A}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Create_simple_pie_chart</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Presentation.NET" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Syncfusion.OfficeChart;
using Syncfusion.Presentation;

//Create an instance of presentation.
using IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a chart to the slide with position and size.
IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);
//Select the chart type.
chart.ChartType = OfficeChartType.Pie;
//Assign data range.
chart.DataRange = chart.ChartData[1, 1, 6, 2];
chart.IsSeriesInRows = false;
//Set the values for the chart data.
chart.ChartData.SetValue(1, 1, "Food");
chart.ChartData.SetValue(2, 1, "Fruits");
chart.ChartData.SetValue(3, 1, "Vegetables");
chart.ChartData.SetValue(4, 1, "Dairy");
chart.ChartData.SetValue(5, 1, "Protein");
chart.ChartData.SetValue(6, 1, "Grains");
chart.ChartData.SetValue(1, 2, "Percentage");
chart.ChartData.SetValue(2, 2, 36);
chart.ChartData.SetValue(3, 2, 14);
chart.ChartData.SetValue(4, 2, 13);
chart.ChartData.SetValue(5, 2, 28);
chart.ChartData.SetValue(6, 2, 9);
//Set data labels.
chart.Series[0].DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
//Save the presentation.
using FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
presentation.Save(outputStream);
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ static void Main(string[] args)
//Open the existing PowerPoint presentation.
using (IPresentation pptxDoc = Presentation.Open(fileStream))
{
//Initialize the PresentationRenderer to perform image conversion.
//Initialize PresentationRenderer.
pptxDoc.PresentationRenderer = new PresentationRenderer();
//Convert PowerPoint to image as stream.
Stream[] images = pptxDoc.RenderAsImages(ExportImageFormat.Jpeg);
//Saves the images to file system
foreach (Stream stream in images)
//Save the images to file.
for (int i = 0; i < images.Length; i++)
{
//Create the output image file stream
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath("Output/Output" + Guid.NewGuid().ToString() + ".jpg")))
using (Stream stream = images[i])
{
//Copy the converted image stream into created output stream
stream.CopyTo(fileStreamOutput);
//Save the image stream to a file.
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath("Output/Output" + i + ".jpg")))
{
stream.CopyTo(fileStreamOutput);
}
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;

//Load or open an PowerPoint Presentation.
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing PowerPoint presentation.
using IPresentation pptxDoc = Presentation.Open(inputStream);
//Initialize the PresentationRenderer to perform image conversion.
pptxDoc.PresentationRenderer = new PresentationRenderer();
//Convert PowerPoint slide to image as stream.
using Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg);
//Create the output image file stream.
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg"));
//Copy the converted image stream into created output stream.
stream.CopyTo(fileStreamOutput);
//Open an existing presentation.
using (FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
//Load the presentation.
using (IPresentation pptxDoc = Presentation.Open(inputStream))
{
//Initialize PresentationRenderer.
pptxDoc.PresentationRenderer = new PresentationRenderer();
//Convert the PowerPoint slide as an image stream.
using (Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg))
{
//Save the image stream to a file.
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg")))
{
stream.CopyTo(fileStreamOutput);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,25 @@ Step 4: Add the following code snippet in Program.cs file to convert a PowerPoin

```csharp
//Load or open an PowerPoint Presentation.
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing PowerPoint presentation.
using IPresentation pptxDoc = Presentation.Open(inputStream);
//Initialize the PresentationRenderer to perform image conversion.
pptxDoc.PresentationRenderer = new PresentationRenderer();
//Convert PowerPoint slide to image as stream.
using Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg);
//Create the output image file stream.
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg"));
//Copy the converted image stream into created output stream.
stream.CopyTo(fileStreamOutput);
using (FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
//Open an existing PowerPoint presentation.
using (IPresentation pptxDoc = Presentation.Open(inputStream))
{
//Initialize the PresentationRenderer to perform image conversion.
pptxDoc.PresentationRenderer = new PresentationRenderer();
//Convert the PowerPoint slide as an image stream .
using (Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg))
{
//Create the output image file stream.
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpg")))
{
//Copy the converted image stream into created output stream.
stream.CopyTo(fileStreamOutput);
}
}
}
}
```

More information about PPTX to Image conversion can be found in this [documentation](https://help.syncfusion.com/document-processing/powerpoint/conversions/powerpoint-to-image/net/presentation-to-image) section.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;

//Load or open an PowerPoint Presentation.
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing PowerPoint presentation.
using IPresentation pptxDoc = Presentation.Open(inputStream);
//Create the MemoryStream to save the converted PDF.
using MemoryStream pdfStream = new();
//Convert the PowerPoint document to PDF document.
using PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc);
//Save the converted PDF document to MemoryStream.
pdfDocument.Save(pdfStream);
pdfStream.Position = 0;
//Create the output PDF file stream.
using FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/PPTXToPDF.pdf"));
//Copy the converted PDF stream into created output PDF stream.
pdfStream.CopyTo(fileStreamOutput);
//Open the PowerPoint file stream.
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
//Load an existing PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open(fileStream))
{
//Convert PowerPoint into PDF document.
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
{
//Save the PDF file to file system.
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/PPTXToPDF.pdf"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
pdfDocument.Save(outputStream);
}
}
}
}
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.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple-text-and-paragraph-formatting", "Simple-text-and-paragraph-formatting\Simple-text-and-paragraph-formatting.csproj", "{AAA91223-CD0E-4333-BC4C-F98D29CC228A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAA91223-CD0E-4333-BC4C-F98D29CC228A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {879355F6-5C8B-4DE1-9A87-B35CF94F090B}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Syncfusion.Presentation;

//Load PowerPoint Presentation.
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing PowerPoint presentation.
using IPresentation pptxDoc = Presentation.Open(inputStream);
//Retrieve the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape.
IShape shape = slide.Shapes[0] as IShape;
//Retrieve the first paragraph of the shape.
IParagraph paragraph = shape.TextBody.Paragraphs[0];
//Set center alignment for the paragraph.
paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
//Retrieve the first TextPart of the shape.
ITextPart textPart = paragraph.TextParts[0];
//Set bold for the text.
textPart.Font.Bold = true;
//Save the PowerPoint Presentation.
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
pptxDoc.Save(outputStream);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Simple_text_and_paragraph_formatting</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

<ItemGroup>
<None Update="Data\Template.pptx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
</ItemGroup>

<ItemGroup>
<None Update="Data\Template.pptx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using Syncfusion.Presentation;

//Load or open an PowerPoint Presentation.
using IPresentation presentation = Presentation.Create();
//Add slide to Presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add textbox to slide.
IShape shape = slide.Shapes.AddTextBox(100, 30, 200, 300);
//Add a paragraph with text content.
IParagraph paragraph = shape.TextBody.AddParagraph("Password Protected.");
//Protects the file with password.
presentation.Encrypt("PASSWORD!@1#$");
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
//Open an existing presentation.
using FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read);
using IPresentation presentation = Presentation.Open(inputStream);
//Encrypt the presentation with a password.
presentation.Encrypt("syncfusion");
using FileStream outputStream = new (Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
presentation.Save(outputStream);
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@ Step 3: Include the following namespaces in the Program.cs file.

```csharp
using Syncfusion.Presentation;
using System.IO;
```

Step 4: Add the following code snippet in Program.cs file to encrypt the PowerPoint Presentation.

```csharp
//Load or open an PowerPoint Presentation.
using IPresentation presentation = Presentation.Create();
//Add slide to Presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add textbox to slide.
IShape shape = slide.Shapes.AddTextBox(100, 30, 200, 300);
//Add a paragraph with text content.
IParagraph paragraph = shape.TextBody.AddParagraph("Password Protected.");
//Protects the file with password.
presentation.Encrypt("PASSWORD!@1#$");
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
//Open an existing presentation.
using FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read);
using IPresentation presentation = Presentation.Open(inputStream);
//Encrypt the presentation with a password.
presentation.Encrypt("syncfusion");
using FileStream outputStream = new (Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
presentation.Save(outputStream);
```

Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//Load or open an PowerPoint Presentation.
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing Presentation from file system and it can be decrypted by using the provided password.
using IPresentation presentation = Presentation.Open(inputStream, "PASSWORD!@1#$");
using IPresentation presentation = Presentation.Open(inputStream, "syncfusion");
//Decrypt the document.
presentation.RemoveEncryption();
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Step 3: Include the following namespaces in the Program.cs file.

```csharp
using Syncfusion.Presentation;
using System.IO;
```

Step 4: Add the following code snippet in Program.cs file to decrypt the PowerPoint Presentation.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit bf09118

Please sign in to comment.