using System;
using System.IO;
using System.Text.RegularExpressions;
using SautinSoft;
using SautinSoft.Pdf;
using SautinSoft.Pdf.Content;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
string pdfFile = Path.GetFullPath(@"..\..\..\Item.pdf");
string csv = "";
using (var document = PdfDocument.Load(pdfFile))
{
var tables = document.Pages[0].Content.FindTables();
int col = -1;
double sum = 0;
foreach (var table in tables)
{
foreach (var row in table.Rows)
{
for (int i = 0; i 〈 row.Cells.Count; i++)
{
csv += row.Cells[i].ToString() + ';';
}
csv += "\n";
}
csv += "Total;;;" + sum.ToString();
sum = 0;
col = -1;
csv += "\n";
}
}
var stream = new FileStream("Output.csv", FileMode.Create);
stream.Close();
File.WriteAllText("Output.csv", csv);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("Output.csv") { UseShellExecute = true });
}
}
}
The PDF .Net product includes a code example for exporting data from tables within a PDF document to a CSV file. This example demonstrates how to use the library to programmatically extract table data from a PDF and save it as a CSV file.
The product supports various platforms, including Windows, Linux, macOS, and Docker, and is compatible with .NET 8, 7, 6, 5, Standard 2, Core 2x & 3x, and Framework 4.6.2+.