Skip to content
Guides

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 ComPDFKit Convert SDK, you can easily extract the text in the PDF into the TXT file.

Preserving Table Format

The SDK supports a function called setTableFormat() 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.

kotlin
val inputFilePath = "***";
val password = "***";
val outputFileName = "***";

val txtOptions = TxtOptions();
val error = ComPDFKitConverter.startPDFToTxt(inputFilePath, password, outputFileName, txtOptions);