On this page
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 CompDF Convert SDK, you can easily extract the text in the PDF into the TXT file.
Notice
- The current version of SDK will ignore the rotated PDF text.
Sample
This sample demonstrates how to convert from a PDF to TXT file.
c#
string inputFilePath = "***";
string outputFolderPath = "***";
string outputFileName = "***";
CPDFConverterTxt converter = CPDFConvertFactroy.CreateConverter(CPDFConvertType.CPDFConvertTypeTxt, inputFilePath) as CPDFConverterTxt;
CPDFConvertTxtOptions txtOptions = new CPDFConvertTxtOptions();
txtOptions.IsAllowOCR = 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,txtOptions, pageArray, ref error, getPorgress);