Convert PDF to Excel CSV in C#, VB.NET, VBScript, Delphi using PDF Extractor SDK, Read from an Excel File - ByteScout

Convert PDF to Excel CSV in C#, VB.NET, VBScript, Delphi using PDF Extractor SDK, Read from an Excel File

  • Home
  • /
  • Articles
  • /
  • Convert PDF to Excel CSV in C#, VB.NET, VBScript, Delphi using PDF Extractor SDK, Read from an Excel File

Check the samples below to learn how to convert tables in PDF to CSV file for MS Excel using Bytescout PDF Extractor SDK.

Select your programming language:

In these screenshots you can see input PDF table and output CSV file with data extracted from the table.

Input PDF table to be converted to XML file Input PDF file
Output CSV file with data extracted from PDF table Output CSV file in Excel

C#

[vb]using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.PDFExtractor;
using System.Diagnostics;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// Create Bytescout.PDFExtractor.CSVExtractor instance
CSVExtractor extractor = new CSVExtractor();
extractor.RegistrationName = "demo";
extractor.RegistrationKey = "demo";

// Load sample PDF document
extractor.LoadDocumentFromFile("sample3.pdf");

//extractor.CSVSeparatorSymbol = ","; // you can change CSV separator symbol (if needed) from "," symbol to another if needed for non-US locales

extractor.SaveCSVToFile("output.csv");

Console.WriteLine();
Console.WriteLine("Data has been extracted to ‘output.csv’ file.");
Console.WriteLine();
Console.WriteLine("Press any key to continue and open CSV in default CSV viewer (or Excel)…");
Console.ReadKey();

Process.Start("output.csv");
}
}
}

[/vb]

Delphi

[vb]program Project1;

{$APPTYPE CONSOLE}

{
IMPORTANT:
To work with Bytescout PDF Extractor SDK you need to import this as a component into Delphi

To import Bytescout PDF Extractor SDK into Delphi 2006 or higher do the following:
1) Click Component | Import Component..
2) Select Type Library and click Next
3) Find and select Bytescout PDF Extractor SDK in the list of available type libraries and
4) Click Next
5) Click Next on next screen
6) Select "Add Bytescout_PDFExtractor_TLB.pas" into Project" and click Finish

This will add Bytescout_PDFExtractor_TLB.pas into your project and now you can use TextExtractor, InfoExtractor, CSVExtractor, XMLExtractor, ImageExtractor object interfaces (_TextExtractor, _InfoExtractor, _CSVExtractor, _XMLExtractor, _ImageExtractor classes)

}

uses
SysUtils,
ActiveX,
Bytescout_PDFExtractor_TLB in ‘c:program filesborlandbds4.0ImportsBytescout_PDFExtractor_TLB.pas’;

var
extractor: _CSVExtractor;
begin
CoInitialize(nil);

// Create Bytescout.PDFExtractor.CSVExtractor object using CoCSVExtractor class
extractor := CoCSVExtractor.Create();

extractor.RegistrationName := ‘demo’;
extractor.RegistrationKey := ‘demo’;

// Load sample PDF document
extractor.LoadDocumentFromFile (‘../../sample3.pdf’);

// extractor.CSVSeparatorSymbol = ‘,’; // you can change CSV separator symbol (if needed) from "," symbol to another if needed for non-US locales

extractor.SaveCSVToFile (‘output.csv’);

// destroy the extractor object
extractor := nil;

end.
[/vb]

VB.NET

[vb]Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Bytescout.PDFExtractor
Imports System.Diagnostics

Namespace ConsoleApplication1
Class Program
Shared Sub Main(ByVal args As String())
‘ Create Bytescout.PDFExtractor.CSVExtractor instance
Dim extractor As New CSVExtractor()
extractor.RegistrationName = "demo"
extractor.RegistrationKey = "demo"

‘ Load sample PDF document
extractor.LoadDocumentFromFile("sample3.pdf")

‘extractor.CSVSeparatorSymbol = "," // you can change CSV separator symbol (if needed) from "," symbol to another if needed for non-US locales

extractor.SaveCSVToFile("output.csv")

Console.WriteLine()
Console.WriteLine("Data has been extracted to ‘output.csv’ file.")
Console.WriteLine()
Console.WriteLine("Press any key to continue and open CSV in default CSV viewer (or Excel)…")
Console.ReadKey()

Process.Start("output.csv")
End Sub
End Class
End Namespace

[/vb]

VBScript (Visual Basic 6)

[vb]’ Create Bytescout.PDFExtractor.CSVExtractor object
Set extractor = CreateObject("Bytescout.PDFExtractor.CSVExtractor")

extractor.RegistrationName = "demo"
extractor.RegistrationKey = "demo"

‘ Load sample PDF document
extractor.LoadDocumentFromFile "../../sample3.pdf"

‘extractor.CSVSeparatorSymbol = "," ‘ you can change CSV separator symbol (if needed) from "," symbol to another if needed for non-US locales

extractor.SaveCSVToFile "output.csv"

MsgBox "Data has been extracted to ‘output.csv’ file."

[/vb]

Tutorials:

prev
next