Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.14.36127.28 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert CSV to PDF", "Convert CSV to PDF\Convert CSV to PDF.csproj", "{B689DDBB-3C27-4E5C-A31C-6D5E2995F4E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B689DDBB-3C27-4E5C-A31C-6D5E2995F4E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B689DDBB-3C27-4E5C-A31C-6D5E2995F4E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B689DDBB-3C27-4E5C-A31C-6D5E2995F4E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B689DDBB-3C27-4E5C-A31C-6D5E2995F4E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {270E78FD-B073-44CF-9B9A-06D8ACE3262A}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Product ID,Product Name,Category,Quantity,Price
1001,Apple,Fruit,10,0.99
1002,Banana,Fruit,20,0.59
1003,Carrot,Vegetable,15,0.49
1004,Tomato,Vegetable,12,0.79
1005,Milk,Dairy,5,1.49
1006,Bread,Bakery,8,2.99
1007,Orange,Fruit,18,0.89
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Syncfusion.Pdf;
using Syncfusion.XlsIO;
using Syncfusion.XlsIORenderer;

namespace Convert_CSV_to_PDF
{
class Program
{
public static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream("Data/Sample.csv", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet sheet = workbook.Worksheets[0];

//Auto-fit all columns in the used range to prevent cropping
sheet.UsedRange.AutofitColumns();

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

//Convert CSV document into PDF document
PdfDocument pdfDocument = renderer.ConvertToPDF(sheet);

//Saving the PDF document
FileStream outputStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
pdfDocument.Save(outputStream);

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
}
}
}