Skip to content
ComPDF
DemoFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Convert PDF to CSV

Overview

ComPDF 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.

In the PHP SDK, CSV output is produced through the Excel pipeline with excelCsvFormat = true.

Set Whether to Automatically Create Folders

When multiple CSV files may be output, you can control whether to automatically create folders to store the CSV files by setting the autoCreateFolder option. When this option is enabled, a folder with the same name as the output file will be automatically created in the output path to store the CSV files.

Sample

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

php
use ComPDFKit\Conversion\ExcelWorksheetOption;

$option = new ConvertOption();
$option->excelCsvFormat = true;
$option->autoCreateFolder = true;
Conversion::convert('Excel', 'csv.pdf', 'password', 'output.csv', $option);

// Merge all tables into one CSV file.
$option->excelWorksheetOption = ExcelWorksheetOption::FOR_DOCUMENT;
Conversion::convert('Excel', 'csv.pdf', 'password', 'output_all.csv', $option);