Convert pages to text and write to a file.
int pdfConvertToTextFile(PDFHandle pdf, int firstPage, int lastPage, char *textFileName)
This function converts the specified range of pages (firstPage through lastPage) to text, and writes the text to a file on disk (textFileName).

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

pdfConvertToTextFile returns 1 if successful, or 0 if the file could not be created or if text extraction is prohibited by this PDF file.

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

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

if (!pdfConvertToTextFile(pdf, 1, n, "file.txt")) { /* handle the error */ }