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 TXT

Overview

When you need to extract the text content in the PDF file, in order for data analysis, text mining, information retrieval, etc. Using ComPDF Conversion SDK, you can easily extract the text in the PDF into the TXT file.

Preserving Table Format

The SDK supports an option called txtTableFormat that preserves the table format when writing the TXT file, meaning that the original table structure is maintained. It is generally recommended to enable this option, especially useful for data extraction scenarios.

Sample

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

php
$option = new ConvertOption();
$option->txtTableFormat = true;
// PDF to TXT.
Conversion::convert('Txt', 'txt.pdf', 'password', 'output.txt', $option);