pdfConvertToTextString

Convert pages to text and return a string.
char *pdfConvertToTextString(PDFHandle pdf, int firstPage, int lastPage, int *length)
This function converts the specified range of pages (firstPage through lastPage) to text, and returns the resulting text in a string.

If lastPage is -1, this function will convert up to the last page in the PDF file. (See also pdfGetNumPages.)

pdfConvertToTextString returns a string if successful, or NULL if text extraction is prohibited by this PDF file.

The string is returned, and *length is filled in with the string length. The string will be zero-terminated, but it may contain zero bytes, depending on the current text encoding (see pdfSetTextEncoding). The caller is responsible for freeing the string with the pdfFreeMemory function.

This function is identical to pdfConvertToTextFile except that it extracts to a string in memory rather than to a file on disk.

See the "Setting parameters" section in the function list for settings that affect text extraction.

C:
char *buf; int length; if (!(buf = pdfConvertToTextString(pdf, 1, n, &length))) { /* handle the error */ } ... pdfFreeMemory(buf);
pdfConvertToTextFile
pdfExtractTextFromRect
pdfExtractTextFromRect2
pdfFreeMemory