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.

Note

  • When the setCsvMerge 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 PDFs to CSV files.

java
        CPDFConvert cpdfConvertCSV = new CPDFConvertCSV();
        CPDFConvertCsvOptions cpdfConvertCsvOptions = new CPDFConvertCsvOptions();
        String inputPath = rootDir + input_file + "excel.pdf";
        List<Integer> pageCounts = getPageCounts(cpdfConvertCSV.getPageCount(inputPath, password));
        ConvertResult convert = cpdfConvertCSV.convert(inputPath, rootDir + output_file, "", cpdfConvertCsvOptions, pageCounts, password, page -> {
        });
        cpdfConvertCsvOptions.setCsvMerge(true);
        ConvertResult convertMerge = cpdfConvertCSV.convert(inputPath, rootDir + output_file, "", cpdfConvertCsvOptions, pageCounts, password, page -> {
        });