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

void PoDoFo::PdfMemDocument::InitFromParser ( PdfParser pParser ) [private]

Internal method to load all objects from a PdfParser object. The objects will be removed from the parser and are now owned by the PdfMemDocument.

Definition at line 100 of file PdfMemDocument.cpp.

References PoDoFo::PdfDictionary::AddKey(), PoDoFo::PdfError::DebugEnabled(), PoDoFo::eLogSeverity_Information, PoDoFo::ePdfError_NoObject, PoDoFo::PdfRefCountedBuffer::GetBuffer(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfParser::GetEncrypted(), PoDoFo::PdfObject::GetIndirectKey(), PoDoFo::PdfElement::GetObject(), PoDoFo::PdfDocument::GetObjects(), PoDoFo::PdfParser::GetPdfVersion(), PoDoFo::PdfRefCountedBuffer::GetSize(), PoDoFo::PdfParser::GetTrailer(), PoDoFo::PdfParser::IsLinearized(), PoDoFo::PdfError::LogMessage(), PODOFO_RAISE_ERROR_INFO, PoDoFo::PdfObject::Reference(), PoDoFo::PdfDocument::SetCatalog(), PoDoFo::PdfDocument::SetInfo(), PoDoFo::PdfDocument::SetTrailer(), PoDoFo::PdfParser::TakeEncrypt(), PoDoFo::PdfOutputDevice::Write(), and PoDoFo::PdfVariant::Write().

Referenced by Load(), and SetPassword().

{
    m_eVersion     = pParser->GetPdfVersion();
    m_bLinearized  = pParser->IsLinearized();

    PdfObject* pTrailer = new PdfObject( *(pParser->GetTrailer()) );
    this->SetTrailer ( pTrailer ); // Set immediately as trailer
                                   // so that pTrailer has an owner
                                   // and GetIndirectKey will work

    if(PdfError::DebugEnabled())
    {
        // OC 17.08.2010: Avoid using cout here:
     // PdfOutputDevice debug( &(std::cout) );
     // pTrailer->Write( &debug );
     // debug.Write("\n", 1); // OC 17.08.2010: Append Linefeed
        PdfRefCountedBuffer buf;
        PdfOutputDevice debug( &buf );
        pTrailer->Write( &debug, m_eWriteMode );
        debug.Write("\n", 1); // OC 17.08.2010: Append Linefeed
        size_t siz = buf.GetSize();
        char*  ptr = buf.GetBuffer();
        PdfError::LogMessage(eLogSeverity_Information, "%.*s", siz, ptr);
    }

    PdfObject* pCatalog = pTrailer->GetIndirectKey( "Root" );
    if( !pCatalog )
    {
        PODOFO_RAISE_ERROR_INFO( ePdfError_NoObject, "Catalog object not found!" );
    }


    PdfObject* pInfo = pTrailer->GetIndirectKey( "Info" );
    PdfInfo*   pInfoObj;
    if( !pInfo ) 
    {
        pInfoObj = new PdfInfo( PdfDocument::GetObjects() );
        pTrailer->GetDictionary().AddKey( "Info", pInfoObj->GetObject()->Reference() );
    }
    else 
        pInfoObj = new PdfInfo( pInfo );

    if( pParser->GetEncrypted() ) 
    {
        // All PdfParserObjects have a pointer to the PdfEncrypt obkect
        // So we have to take ownership of it.
        delete m_pEncrypt;
        m_pEncrypt = pParser->TakeEncrypt();
    }

    this->SetCatalog ( pCatalog );
    this->SetInfo    ( pInfoObj );
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index