Skip to content

Commit

Permalink
Merge pull request #59 from SyncfusionExamples/842218-CreateExcel-Docker
Browse files Browse the repository at this point in the history
842224 - Add the samples for the conversion of Excel to PDF in Docker
  • Loading branch information
Mohan2401 authored Oct 11, 2023
2 parents bf321cf + ef667ff commit 0901ba6
Show file tree
Hide file tree
Showing 28 changed files with 448 additions and 0 deletions.
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.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Excel-to-PDF", "Convert-Excel-to-PDF\Convert-Excel-to-PDF.csproj", "{3C0F53AF-5189-4A52-8CE4-C08FFF0D6190}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C0F53AF-5189-4A52-8CE4-C08FFF0D6190}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C0F53AF-5189-4A52-8CE4-C08FFF0D6190}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C0F53AF-5189-4A52-8CE4-C08FFF0D6190}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C0F53AF-5189-4A52-8CE4-C08FFF0D6190}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E0207BB-0167-420A-853D-B02542FCF3CB}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Convert_Excel_to_PDF</RootNamespace>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.5" />
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="23.1.36" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:3.1-alpine3.12 AS base
RUN apk update && apk upgrade && apk add fontconfig
RUN apk add --update ttf-dejavu fontconfig
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine3.12 AS build
WORKDIR /src
COPY ["Convert-Excel-to-PDF.csproj", "."]
RUN dotnet restore "./Convert-Excel-to-PDF.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Convert-Excel-to-PDF.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Convert-Excel-to-PDF.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Convert-Excel-to-PDF.dll"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Syncfusion.Pdf;
using Syncfusion.XlsIO;
using System;
using System.IO;
using Syncfusion.XlsIORenderer;

namespace Convert_Excel_to_PDF
{
internal class Program
{
static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream excelStream = new FileStream("Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(excelStream);

//Initialize XlsIO renderer.
XlsIORenderer renderer = new XlsIORenderer();

//Convert Excel document into PDF document
PdfDocument pdfDocument = renderer.ConvertToPDF(workbook);

//Create the FileStream to save the converted PDF.
FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
pdfDocument.Save(pdfStream);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"Convert-Excel-to-PDF": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}
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.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Excel-to-PDF", "Convert-Excel-to-PDF\Convert-Excel-to-PDF.csproj", "{35079D1C-422A-48FE-B150-23BBAC13BB3D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{35079D1C-422A-48FE-B150-23BBAC13BB3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35079D1C-422A-48FE-B150-23BBAC13BB3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35079D1C-422A-48FE-B150-23BBAC13BB3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35079D1C-422A-48FE-B150-23BBAC13BB3D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {242C9AAD-E4C9-433F-B032-AF674C1AC1C1}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Convert_Excel_to_PDF</RootNamespace>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.5" />
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="23.1.36" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim AS base
RUN apt-get update -y && apt-get install fontconfig -y
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:3.1-buster-slim AS build
WORKDIR /src
COPY ["Convert-Excel-to-PDF.csproj", "."]
RUN dotnet restore "./Convert-Excel-to-PDF.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Convert-Excel-to-PDF.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Convert-Excel-to-PDF.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Convert-Excel-to-PDF.dll"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Syncfusion.Pdf;
using Syncfusion.XlsIO;
using System;
using System.IO;
using Syncfusion.XlsIORenderer;
using static System.Net.Mime.MediaTypeNames;

namespace Convert_Excel_to_PDF
{
internal class Program
{
static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream excelStream = new FileStream("Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(excelStream);

//Initialize XlsIO renderer.
XlsIORenderer renderer = new XlsIORenderer();

//Convert Excel document into PDF document
PdfDocument pdfDocument = renderer.ConvertToPDF(workbook);

//Create the FileStream to save the converted PDF.
FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
pdfDocument.Save(pdfStream);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"Convert-Excel-to-PDF": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}
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.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Excel-to-PDF", "Convert-Excel-to-PDF\Convert-Excel-to-PDF.csproj", "{AAEA8DE9-60DE-4C94-84C6-B326724AE0BD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AAEA8DE9-60DE-4C94-84C6-B326724AE0BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAEA8DE9-60DE-4C94-84C6-B326724AE0BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAEA8DE9-60DE-4C94-84C6-B326724AE0BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAEA8DE9-60DE-4C94-84C6-B326724AE0BD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB0DECF5-AE91-4839-ADEC-E016FCB408D9}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Convert_Excel_to_PDF</RootNamespace>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.5" />
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="23.1.36" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM registry.access.redhat.com/ubi8/dotnet-31-runtime AS base
USER root
RUN yum -y install fontconfig --disablerepo=epel
WORKDIR /

FROM registry.access.redhat.com/ubi8/dotnet-31 AS build
WORKDIR /src
COPY ["Convert-Excel-to-PDF.csproj", ""]
RUN dotnet restore "./Convert-Excel-to-PDF.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Convert-Excel-to-PDF.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Convert-Excel-to-PDF.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Convert-Excel-to-PDF.dll"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Syncfusion.Pdf;
using Syncfusion.XlsIO;
using System;
using System.IO;
using Syncfusion.XlsIORenderer;
using static System.Net.Mime.MediaTypeNames;

namespace Convert_Excel_to_PDF
{
internal class Program
{
static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream excelStream = new FileStream("Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(excelStream);

//Initialize XlsIO renderer.
XlsIORenderer renderer = new XlsIORenderer();

//Convert Excel document into PDF document
PdfDocument pdfDocument = renderer.ConvertToPDF(workbook);

//Create the FileStream to save the converted PDF.
FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
pdfDocument.Save(pdfStream);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"Convert-Excel-to-PDF": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}
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.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Excel-to-PDF", "Convert-Excel-to-PDF\Convert-Excel-to-PDF.csproj", "{675724F6-6A41-4466-B452-5760018C4FEA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{675724F6-6A41-4466-B452-5760018C4FEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{675724F6-6A41-4466-B452-5760018C4FEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{675724F6-6A41-4466-B452-5760018C4FEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{675724F6-6A41-4466-B452-5760018C4FEA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {73025860-39DA-4DF6-8CC3-D9D7A29408E2}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 0901ba6

Please sign in to comment.