No announcement yet.

GetChunk of PDF IFilter is not working

  • Time
  • Show
Clear All
new posts

  • Bug GetChunk of PDF IFilter is not working

    Hi All,

    I am facing issue while using Foxit PDF IFilter for 64 bit, the section of code mentioned below is used to load IFilter for PDF IFilter 64 bit using IPersist interface.

    LibHndl = LoadLibrary(strDLLName.c_str());

    FnPtr_DllGetClassObject fnDLCO = NULL;
    // Add to the load list.
    fnDLCO = (FnPtr_DllGetClassObject)GetProcAddress(LibHndl, "DllGetClassObject");
    if(NULL != fnDLCO)
    IClassFactory* pICF = NULL;
    hrslt = fnDLCO(objChachedIFilterNode.m_iidFilterPersistanc e, IID_IClassFactory, (LPVOID *)&pICF);
    if( ( S_OK == hrslt ) && (NULL != pICF) )

    IFilter *pobjIfilter = NULL;

    hrslt = pICF->CreateInstance(pUnkOuter, IID_IFilter, (void**)&(pObjIfiter));

    if( ( S_OK == hrslt ) && (NULL != pObjIfiter) )
    IPersistStream* persistStream = NULL;
    hrslt = pObjIfiter->QueryInterface(IID_IPersistStream, (void**)&persistStream);





    with this pointers to IFilter and IPersistStream for Foxit PDF filter 64 bit have been obtained then the code section below is used to load the IFilter

    size_t dwReadSize = 0;
    pFile = fopen(pszFileName, "rb"); //pszFileName: complete path of pdf file
    if(NULL != pFile)
    if(0 == fseek(pFile, 0L, SEEK_END))
    dwSize = ftell(pFile);
    dwFileSize = dwSize;
    fseek(pFile, 0L, SEEK_SET);

    m_pbyDataBuffer = (unsigned char *)GlobalAlloc(GPTR, dwSize);
    bool bolReadFile = false;

    if(NULL != m_pbyDataBuffer)
    dwReadSize = fread(m_pbyDataBuffer, 1, dwSize, pFile);
    hStreamResult = CreateStreamOnHGlobal(NULL, TRUE, &m_pIStreamBuffer); //m_pIStreamBuffer: is pointer to IStream
    if(NULL != m_pIStreamBuffer)
    LARGE_INTEGER iLarge = {0};
    m_pIStreamBuffer->Seek(iLarge, STREAM_SEEK_SET, NULL);
    ULARGE_INTEGER uInt = {0};
    ULONG dwBytesWritten = 0;
    if(NULL != m_pbySecDataBuffer)
    hStreamResult = m_pIStreamBuffer->Write((void const*)m_pbySecDataBuffer, (ULONG)dwSize, &dwBytesWritten);
    hStreamResult = m_pIStreamBuffer->Write((void const*)m_pbyDataBuffer, (ULONG)dwSize, &dwBytesWritten);
    pFile = NULL;
    if(S_OK == hStreamResult)
    if((NULL != objCIFilterExNode.m_pObjIfiter) &&\
    (NULL != objCIFilterExNode.m_pObjIPersistStream))
    m_pGenericFilter = objCIFilterExNode.m_pObjIfiter;

    m_pPersistStream = objCIFilterExNode.m_pObjIPersistStream;

    if(NULL != m_pIStreamBuffer)
    hReturnValue = m_pPersistStream->Load(m_pIStreamBuffer);
    Then based on the file extension Flag for the m_pGenericFilter->Init() function is set and then the Init() function is called with that flag.
    Once loading is completed successfully SCODE hReturnValue = m_pGenericFilter->GetChunk(&m_stChunk); is called in a loop to get the file content in chunks where m_stChunk is of type STAT_CHUNK.
    The execution of GetChunk() function is not returning success i.e. file content cannot be extracted and hence I am not able to apply content filtering for PDF files.
    Kindly help me resolving the issue or to identify what can be cause of the same.


  • #2
    Dear sheelagusain,

    If you want to use the Foxit PDF IFilter's IFilter interfaces you will need a key. Please contact [email protected] and ask them for a evaluation license key for Foxit PDF IFilter. For the latest version of Foxit PDF IFilter, you will need to provide a mac address of the machine you are developing on. After you receive the key run the IFilterActivation tool in the install directory it will walk you through the steps on how to apply the key.