Skip to content

Commit 90037ca

Browse files
committed
Code updated regarding the export DataGridImageColumn to pdf.
1 parent cfab357 commit 90037ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1784
-2
lines changed

DataGridSample/DataGridSample.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.9.34728.123
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGridSample", "DataGridSample\DataGridSample.csproj", "{2D8BA5CA-60AD-4F01-9527-081D794FE3E2}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{2D8BA5CA-60AD-4F01-9527-081D794FE3E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2D8BA5CA-60AD-4F01-9527-081D794FE3E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2D8BA5CA-60AD-4F01-9527-081D794FE3E2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{2D8BA5CA-60AD-4F01-9527-081D794FE3E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{2D8BA5CA-60AD-4F01-9527-081D794FE3E2}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{2D8BA5CA-60AD-4F01-9527-081D794FE3E2}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {405DD3AB-A21A-4F11-BC7F-EF43EC326F70}
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:DataGridSample"
5+
x:Class="DataGridSample.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace DataGridSample
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Ngo9BigBOggjHTQxAR8/V1NDaF5cWWtCf1FpRHxbf1x0ZFdMZV5bQX9PMyBoS35RckRiWXpeeHRWRmZaU0R+");
9+
10+
MainPage = new AppShell();
11+
}
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="DataGridSample.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:DataGridSample"
7+
Shell.FlyoutBehavior="Disabled"
8+
Title="DataGridSample">
9+
10+
<ShellContent
11+
Title="Home"
12+
ContentTemplate="{DataTemplate local:MainPage}"
13+
Route="MainPage" />
14+
15+
</Shell>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace DataGridSample
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
8+
9+
<!-- Note for MacCatalyst:
10+
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
11+
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
12+
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
13+
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
14+
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
15+
16+
<OutputType>Exe</OutputType>
17+
<RootNamespace>DataGridSample</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
22+
23+
<!-- Display name -->
24+
<ApplicationTitle>DataGridSample</ApplicationTitle>
25+
26+
<!-- App Identifier -->
27+
<ApplicationId>com.companyname.datagridsample</ApplicationId>
28+
29+
<!-- Versions -->
30+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
31+
<ApplicationVersion>1</ApplicationVersion>
32+
33+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
34+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
35+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
36+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
37+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
38+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
39+
</PropertyGroup>
40+
41+
<ItemGroup>
42+
<!-- App Icon -->
43+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
44+
45+
<!-- Splash Screen -->
46+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
47+
48+
<!-- Images -->
49+
<MauiImage Include="Resources\Images\*" />
50+
51+
<!-- Custom Fonts -->
52+
<MauiFont Include="Resources\Fonts\*" />
53+
54+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
55+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
56+
</ItemGroup>
57+
58+
<ItemGroup>
59+
<MauiImage Remove="Resources\Images\dotnet_bot.png" />
60+
<MauiImage Remove="Resources\Images\image0.png" />
61+
</ItemGroup>
62+
63+
<ItemGroup>
64+
<None Remove="Resources\Images\image0.png" />
65+
</ItemGroup>
66+
67+
<ItemGroup>
68+
<EmbeddedResource Include="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
69+
<EmbeddedResource Include="Resources\Images\image0.png" />
70+
</ItemGroup>
71+
72+
<ItemGroup>
73+
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.92" />
74+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.92" />
75+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
76+
<PackageReference Include="Syncfusion.Maui.DataGrid" Version="27.1.56" />
77+
<PackageReference Include="Syncfusion.Maui.DataGridExport" Version="27.1.56" />
78+
</ItemGroup>
79+
80+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
5+
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
6+
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
7+
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
8+
<DefaultDevice>pixel_6a_-_api_30</DefaultDevice>
9+
</PropertyGroup>
10+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
11+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
12+
</PropertyGroup>
13+
<ItemGroup>
14+
<None Update="App.xaml">
15+
<SubType>Designer</SubType>
16+
</None>
17+
<None Update="AppShell.xaml">
18+
<SubType>Designer</SubType>
19+
</None>
20+
<None Update="MainPage.xaml">
21+
<SubType>Designer</SubType>
22+
</None>
23+
<None Update="Platforms\Windows\App.xaml">
24+
<SubType>Designer</SubType>
25+
</None>
26+
<None Update="Platforms\Windows\Package.appxmanifest">
27+
<SubType>Designer</SubType>
28+
</None>
29+
<None Update="Resources\Styles\Colors.xaml">
30+
<SubType>Designer</SubType>
31+
</None>
32+
<None Update="Resources\Styles\Styles.xaml">
33+
<SubType>Designer</SubType>
34+
</None>
35+
</ItemGroup>
36+
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:syncfusion="clr-namespace:Syncfusion.Maui.DataGrid;assembly=Syncfusion.Maui.DataGrid"
5+
xmlns:local="clr-namespace:DataGridSample"
6+
x:Class="DataGridSample.MainPage">
7+
8+
<ContentPage.BindingContext>
9+
<local:EmployeeViewModel/>
10+
</ContentPage.BindingContext>
11+
12+
<StackLayout>
13+
<syncfusion:SfDataGrid x:Name="dataGrid" VerticalOptions="FillAndExpand" AutoGenerateColumnsMode="None" ColumnWidthMode="Auto"
14+
ItemsSource="{Binding Employees}">
15+
<syncfusion:SfDataGrid.Columns>
16+
<syncfusion:DataGridNumericColumn MappingName="EmployeeID"
17+
Format="#"
18+
HeaderText="Employee ID" />
19+
<syncfusion:DataGridTextColumn MappingName="Name"
20+
HeaderText="Employee Name" />
21+
22+
<syncfusion:DataGridImageColumn MappingName="EmpImage" Width="75"
23+
HeaderText= "Image" />
24+
25+
</syncfusion:SfDataGrid.Columns>
26+
</syncfusion:SfDataGrid>
27+
<Button Text="ExportToPdf" Clicked="Button_Clicked"> </Button>
28+
</StackLayout>
29+
30+
</ContentPage>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Syncfusion.Maui.DataGrid.Exporting;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Graphics;
4+
5+
namespace DataGridSample
6+
{
7+
public partial class MainPage : ContentPage
8+
{
9+
public MainPage()
10+
{
11+
InitializeComponent();
12+
}
13+
14+
private void Button_Clicked(object sender, EventArgs e)
15+
{
16+
MemoryStream stream = new MemoryStream();
17+
DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();
18+
DataGridPdfExportingOption option = new DataGridPdfExportingOption();
19+
option.CanExportColumnWidth = true;
20+
var pdfDoc = new PdfDocument();
21+
pdfDoc = pdfExport.ExportToPdf(this.dataGrid, option);
22+
pdfDoc.Save(stream);
23+
pdfDoc.Close(true);
24+
SaveService saveService = new();
25+
saveService.SaveAndView("ExportFeature.pdf", "application/pdf", stream); ;
26+
}
27+
}
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
4+
namespace DataGridSample
5+
{
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.UseMauiApp<App>()
13+
.ConfigureFonts(fonts =>
14+
{
15+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
16+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
17+
});
18+
19+
#if DEBUG
20+
builder.Logging.AddDebug();
21+
#endif
22+
builder.ConfigureSyncfusionCore();
23+
return builder.Build();
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)