Convert PDF File to Excel using C# and VB.Net in Windows Application

Last Reply 6 months ago By pandeyism

Posted 6 months ago

Hi everyone!

I want read data from pdf file and convert to Excel(csv)?

I want using windows forms application

Posted 6 months ago
Hi @HonnikaNS,
Please try the following

Convert a PDF File to Excel File using iTextSharp using C# .Net

It might help you.

Cheers Andrea.

Posted 6 months ago

It s on web application i want it on windows form application


Posted 6 months ago

Hey HonnikaNS,

Please refer below link and sample .

https://www.aspforums.net/Threads/582579/Export-PDF-Tables-to-Excel-in-ASPNet-using-C-and-VBNet/

Namespaces

C#

using System.IO;
using SautinSoft;

VB.Net

Imports System.IO
Imports SautinSoft

Code

C#

private void ExportPdfToExcel(object sender, EventArgs e)
{
    using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
    {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            string fileName = openFileDialog1.FileName;
            byte[] bytes = File.ReadAllBytes(fileName);
                    
            SautinSoft.PdfFocus f = new PdfFocus();
            f.OpenPdf(fileName);
            if (f.PageCount > 0)
            {
                f.ToExcel(@"E:\File\Test.xls");
            }
        }
    }
}

VB.Net

Private Sub ExportPdfToExcel(ByVal sender As Object, ByVal e As EventArgs)
    Using openFileDialog1 As OpenFileDialog = New OpenFileDialog()

        If openFileDialog1.ShowDialog() = DialogResult.OK Then
            Dim fileName As String = openFileDialog1.FileName
            Dim bytes As Byte() = File.ReadAllBytes(fileName)
            Dim f As SautinSoft.PdfFocus = New PdfFocus()
            f.OpenPdf(fileName)
            If f.PageCount > 0 Then
                f.ToExcel("E:\File\Test.xls")
            End If
        End If
    End Using
End Sub