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