diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF.sln b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF.sln new file mode 100644 index 00000000..a25bd324 --- /dev/null +++ b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36127.28 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertExcelToPDF", "ConvertExcelToPDF\ConvertExcelToPDF.csproj", "{25CF80BC-DCE7-447F-8458-1C207B68A31F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {25CF80BC-DCE7-447F-8458-1C207B68A31F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25CF80BC-DCE7-447F-8458-1C207B68A31F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25CF80BC-DCE7-447F-8458-1C207B68A31F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25CF80BC-DCE7-447F-8458-1C207B68A31F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EBA15DC6-9DD6-455E-94E3-13C920C3DB5F} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/App.config b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/App.config new file mode 100644 index 00000000..94e88573 --- /dev/null +++ b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/ConvertExcelToPDF.csproj b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/ConvertExcelToPDF.csproj new file mode 100644 index 00000000..c747b1dd --- /dev/null +++ b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/ConvertExcelToPDF.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {25CF80BC-DCE7-447F-8458-1C207B68A31F} + Exe + ConvertExcelToPDF + ConvertExcelToPDF + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Syncfusion.Compression.Base.100.2.38\lib\net462\Syncfusion.Compression.Base.dll + + + ..\packages\Syncfusion.ExcelToPdfConverter.WinForms.29.2.11\lib\net462\Syncfusion.ExcelToPdfConverter.Base.dll + + + ..\packages\Syncfusion.Licensing.29.2.11\lib\net462\Syncfusion.Licensing.dll + + + ..\packages\Syncfusion.Pdf.WinForms.29.2.11\lib\net462\Syncfusion.Pdf.Base.dll + + + ..\packages\Syncfusion.XlsIO.WinForms.29.2.11\lib\net462\Syncfusion.XlsIO.Base.dll + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Data/Sample.xlsx b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Data/Sample.xlsx new file mode 100644 index 00000000..e94fa38b Binary files /dev/null and b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Data/Sample.xlsx differ diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Output/.gitkeep b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs new file mode 100644 index 00000000..d6ab461c --- /dev/null +++ b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs @@ -0,0 +1,33 @@ +using Syncfusion.ExcelToPdfConverter; +using Syncfusion.Pdf; +using Syncfusion.XlsIO; +using System.IO; + +namespace ConvertExcelToPDF +{ + class Program + { + public static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); + IWorkbook workbook = application.Workbooks.Open(excelStream); + + //Initialize ExcelToPdfConverter + ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); + + //Initialize PDF document + PdfDocument pdfDocument = new PdfDocument(); + + //Convert Excel document to PDF document + pdfDocument = converter.Convert(); + + //Save the converted PDF document + pdfDocument.Save("Sample.pdf"); + } + } + } +} diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Properties/AssemblyInfo.cs b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..bc0b75b8 --- /dev/null +++ b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConvertExcelToPDF")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConvertExcelToPDF")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("25cf80bc-dce7-447f-8458-1c207b68a31f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/packages.config b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/packages.config new file mode 100644 index 00000000..828c1968 --- /dev/null +++ b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF.sln b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF.sln new file mode 100644 index 00000000..4d198542 --- /dev/null +++ b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36127.28 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertExcelToPDF", "ConvertExcelToPDF\ConvertExcelToPDF.csproj", "{A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {333E4BFE-C711-4343-889E-73D015273596} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/ConvertExcelToPDF.csproj b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/ConvertExcelToPDF.csproj new file mode 100644 index 00000000..bc3f0add --- /dev/null +++ b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/ConvertExcelToPDF.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + Always + + + + diff --git a/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Data/Sample.xlsx b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Data/Sample.xlsx new file mode 100644 index 00000000..e94fa38b Binary files /dev/null and b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Data/Sample.xlsx differ diff --git a/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Output/.gitkeep b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs new file mode 100644 index 00000000..77d6161d --- /dev/null +++ b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs @@ -0,0 +1,40 @@ +using Syncfusion.Pdf; +using Syncfusion.XlsIO; +using Syncfusion.XlsIORenderer; +using System.IO; + +namespace ConvertExcelToPDF +{ + class Program + { + public static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Load existing Excel file + FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Sample.xlsx"), FileMode.Open, FileAccess.Read); + IWorkbook workbook = application.Workbooks.Open(inputStream); + + //Convert to PDF + XlsIORenderer renderer = new XlsIORenderer(); + PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); + + //Create the MemoryStream to save the converted PDF + MemoryStream pdfStream = new MemoryStream(); + + #region Save + //Saving the workbook + FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.pdf"), FileMode.Create, FileAccess.Write); + pdfDocument.Save(outputStream); + #endregion + + //Dispose streams + outputStream.Dispose(); + inputStream.Dispose(); + } + } + } +} \ No newline at end of file