Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

void ImageExtractor::Init ( const char *  pszInput,
const char *  pszOutput,
int *  pnNum = NULL 
)
Parameters:
pnNumpointer to an integer were the number of processed images can be stored or null if you do not want this information.

Definition at line 41 of file ImageExtractor.cpp.

References PoDoFo::PdfVecObjects::begin(), PoDoFo::PdfVecObjects::end(), PoDoFo::ePdfError_InvalidHandle, ExtractImage(), PoDoFo::PdfMemDocument::FreeObjectMemory(), PoDoFo::PdfVariant::GetArray(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfDictionary::GetKey(), PoDoFo::PdfName::GetName(), PoDoFo::PdfVariant::GetName(), PoDoFo::PdfMemDocument::GetObjects(), PoDoFo::PdfArray::GetSize(), PoDoFo::PdfVariant::IsArray(), PoDoFo::PdfVariant::IsName(), and PODOFO_RAISE_ERROR.

{
    PdfObject*  pObj  = NULL;

    if( !pszInput || !pszOutput )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }


    PdfMemDocument document( pszInput );

    m_pszOutputDirectory = const_cast<char*>(pszOutput);

    TCIVecObjects it = document.GetObjects().begin();

    if( pnNum )
        *pnNum = 0;

    while( it != document.GetObjects().end() )
    {
        if( (*it)->IsDictionary() )
        {            
            PdfObject* pObjType = (*it)->GetDictionary().GetKey( PdfName::KeyType );
            PdfObject* pObjSubType = (*it)->GetDictionary().GetKey( PdfName::KeySubtype );
            if( ( pObjType && pObjType->IsName() && ( pObjType->GetName().GetName() == "XObject" ) ) ||
                ( pObjSubType && pObjSubType->IsName() && ( pObjSubType->GetName().GetName() == "Image" ) ) )
            {
                pObj = (*it)->GetDictionary().GetKey( PdfName::KeyFilter );
                if( pObj && pObj->IsArray() && pObj->GetArray().GetSize() == 1 && 
                    pObj->GetArray()[0].IsName() && (pObj->GetArray()[0].GetName().GetName() == "DCTDecode") )
                    pObj = &pObj->GetArray()[0];

                if( pObj && pObj->IsName() && ( pObj->GetName().GetName() == "DCTDecode" ) )
                {
                    // The only filter is JPEG -> create a JPEG file
                    ExtractImage( *it, true );
                }
                else
                {
                    ExtractImage( *it, false );
                }
                
                document.FreeObjectMemory( *it );
            }
        }

        ++it;
    }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index