How to convert PDF file to CSV by pages in C#, VB.NET and VBScript using PDF Extractor SDK - ByteScout

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

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

These sample source codes can be used to convert a PDF file to CSV by pages in C#, VB.NET and VBScript using ByteScout PDF Extractor SDK.

Select your programming language:

How to convert PDF to CSV by pages 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

    		// Get page count
		int pageCount = extractor.GetPageCount();

		for (int i = 0; i < pageCount; i++)
		{
		    string fileName = "page" + i + ".csv";				

      		    // Save extracted page text to file
	      	    extractor.SavePageCSVToFile(i, fileName);
		}



            Console.WriteLine();
            Console.WriteLine("Data has been extracted to separate files for pages.");
            Console.WriteLine();
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();

            //Process.Start("page0.csv");
        }
    }
}

How to convert PDF to CSV by pages 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

		' Get page count
		Dim pageCount As Integer = extractor.GetPageCount()

		For i As Integer = 0 To pageCount - 1
			Dim fileName As String = "page" & i & ".csv"

			' Save extracted page text to file
			extractor.SavePageCSVToFile(i, fileName)
		Next

            Console.WriteLine()
            Console.WriteLine("Press any key to continue and open CSV in default CSV viewer (or Excel)...")
            Console.ReadKey()

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

How to convert PDF to CSV by pages 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

' Get page count
pageCount = extractor.GetPageCount()
		
For i = 0 To pageCount - 1
	fileName = "page" & i & ".csv"

	' Save extracted page text to file
	extractor.SavePageCSVToFile i, fileName
Next

MsgBox "Data has been extracted to 'page0.csv' and other files."

Tutorials:

prev
next