How to convert PDF to CSV in C#, Delphi, VB.NET and VBScript using PDF Extractor SDK - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to convert PDF to CSV in C#, Delphi, VB.NET and VBScript using PDF Extractor SDK

  • Home
  • /
  • Articles
  • /
  • How to convert PDF to CSV in C#, Delphi, VB.NET and VBScript using PDF Extractor SDK

Check the samples below to learn how to convert a PDF file to CSV in C#, Delphi, VB.NET, and VBScript using ByteScout PDF Extractor SDK.

You may also find useful to check how to convert a PDF file to XML or XLS

Select your programming language:

How to convert PDF to CSV in C#

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");
        }
    }
}

How to convert PDF to CSV in Delphi

program Project1;

{$APPTYPE CONSOLE}

{
 IMPORTANT:
  To work with Bytescout PDF Extractor SDK you need to import this as a component into Delphi
IMPORTANT: for Delphi 2009 and higher see "Delphi (late binding)" sample
 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)
 For Delphi 5,6,7,8 / C++ Builder 5,6,7,8 (for 2006 or higher versions please see above)
1) Start Delphi (or C++ Builder)
2) Select Component menu and "Import ActiveX control.."
3) Find the library in the list of available ActiveX/COM objects
4) Select this library and click "Install" 
5) Create a new package for this library imported (for example, TPDFExtractorSDKActiveX)
6) Click OK
7) Answer "Yes" when Delphi (or C++ Builder) asks to rebuild the package
8) The IDE will rebuild the package and will inform that the control has been installed. Close the package and answer "Yes" to save changes
9) The library object is now available on "ActiveX" tab on Tools Pallete. You can simply drag and drop it into the form in your application and use it
}

uses
  SysUtils,
  ActiveX,
  Bytescout_PDFExtractor_TLB in 'c:\program files\borland\bds\4.0\Imports\Bytescout_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.

How to convert PDF to CSV in Delphi (LateBinding)

program Project1;

{$APPTYPE CONSOLE}

{
 IMPORTANT:
  To work with Bytescout PDF Extractor SDK you may also use Late Binding
}

uses
  SysUtils,
  ActiveX;

var
 extractor: Variant;
begin
 CoInitialize(nil);

// Create Bytescout.PDFExtractor.CSVExtractor object using CoCSVExtractor class
extractor := CreateOleObject('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');

 // destroy the extractor object
 extractor := nil;

end.

How to convert PDF to CSV in Visual Basic .NET

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

How to convert PDF to CSV in VBScript (Visual Basic 6)

' 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."

Tutorials:

prev
next