Back to Blog

    Developer Blog

    Can I extract text from PDF files using Foxit PDF SDK?

    Foxit PDF SDK 5.3

    Yes. Text extraction from a PDF can be done by calling the FSPDF_TextPage_ExportToFile function using C++.

    Download Foxit PDF SDK 4.1 and get the demo at: samples\simple_sample\pdf2text\pdf2text.cpp

    FS_RESULT FSPDF_TextPage_ExportToFile(FSPD_TEXTPAGE textPage, FSCRT_FILE file)
    
    Parameters:
    
    textPage - Handle to FSPD_TEXTPAGE object returned by function PSPDF_TextPage_Load
    
    file - Handle to a FSCRT_FILE object which can be a file object or memory buffer to export the text. This can be created by function FSCRT_File_Create or FCRT_File_CreateFromMemory.
    
    The function has the following Returns:
    
    FSCRT_ERRCODE_SUCCESS if successful.
    
    FSCRT_ERRCODE_PARAM if parameter textPage or file is a NULL pointer.
    
    FSCRT_ERRCODE_FILE if the function cannot access the file handle.
    
    FSCRT_ERRCODE_UNRECOVERABLE if the function can not be recovered.
    
    FSCRT_ERRCODE_ERROR if the function cannot export text to the file handle because of any other reason.
    
    

    Note: This article refers to a deprecated version of a Foxit Product. If you are still using Foxit PDF SDK 5.3 or older, please refer to your download package documents for Developer Guide and API Reference.

    Get a trial version of the new Foxit PDF SDK and see our latest generation SDK’s brand new features!