Skip to content
Guides

Convert PDF to CSV

Overview

ComPDFKit Conversion SDK supports converting PDF documents to CSV (Comma-Separated Values). Converting PDF to CSV is a common need, usually used to extract tabular or structured data from PDF documents and convert them into CSV files.

Notice

  • When the IsMergeCSV option is set, the tables in the original PDF document will be merged into the same CSV file.

Sample

This sample demonstrates how to convert from a PDF to CSV file.

c#
string inputFilePath = "***";
string outputFolderPath = "***";
string outputFileName = "***";

CPDFConverterCsv converter = CPDFConvertFactroy.CreateConverter(CPDFConvertType.CPDFConvertTypeCsv, inputFilePath) as CPDFConverterCsv;

CPDFConvertCsvOptions csvOptions = new CPDFConvertCsvOptions();
csvOptions.IsMergeCSV = false;

int pageCount = converter.GetPagesCount();
int[] pageArray = new int[pageCount];
for (int i = 0; i < pageArray.Length; i++)
{
    pageArray[i] = i + 1;
}

ConvertError error = ConvertError.ERR_UNKNOWN;
converter.Convert(outputFolderPath, ref outputFileName, csvOptions, pageArray, ref error, getPorgress);