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

void PoDoFo::PdfWriter::Write ( PdfOutputDevice pDevice )

Writes the complete document to a PdfOutputDevice

Parameters:
pDevicewrite to the specified device

Definition at line 131 of file PdfWriter.cpp.

References PoDoFo::PdfError::AddToCallstack(), PoDoFo::PdfEncrypt::CreateEncryptionDictionary(), CreateFileIdentifier(), PoDoFo::PdfVecObjects::CreateObject(), PoDoFo::ePdfError_InvalidHandle, FillTrailerObject(), PoDoFo::PdfEncrypt::GenerateEncryptionKey(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfXRef::GetOffset(), PoDoFo::PdfXRef::GetSize(), m_pEncrypt, m_pEncryptObj, m_vecObjects, PODOFO_RAISE_ERROR, PoDoFo::PdfOutputDevice::Print(), PoDoFo::PdfXRef::Write(), WriteLinearized(), PoDoFo::PdfObject::WriteObject(), WritePdfHeader(), and WritePdfObjects().

{
    CreateFileIdentifier( m_identifier, m_pTrailer );

    if( !pDevice )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    // setup encrypt dictionary
    if( m_pEncrypt )
    {
        m_pEncrypt->GenerateEncryptionKey( m_identifier );

        // Add our own Encryption dictionary
        m_pEncryptObj = m_vecObjects->CreateObject();
        m_pEncrypt->CreateEncryptionDictionary( m_pEncryptObj->GetDictionary() );
    }

    if( m_bLinearized ) 
    {
        this->WriteLinearized( pDevice );
    }
    else
    {
        PdfXRef* pXRef = m_bXRefStream ? new PdfXRefStream( m_vecObjects, this ) : new PdfXRef();

        try {
            WritePdfHeader  ( pDevice );
            WritePdfObjects ( pDevice, *m_vecObjects, pXRef );

            pXRef->Write( pDevice );
            
            // XRef streams contain the trailer in the XRef
            if( !m_bXRefStream ) 
            {
                PdfObject  trailer;
                
                // if we have a dummy offset we write also a prev entry to the trailer
                FillTrailerObject( &trailer, pXRef->GetSize(), false, false );
                
                pDevice->Print("trailer\n");
                trailer.WriteObject( pDevice, m_eWriteMode, NULL ); // Do not encrypt the trailer dicionary!!!
            }
            
            pDevice->Print( "startxref\n%li\n%%%%EOF\n", pXRef->GetOffset() );
            delete pXRef;
        } catch( PdfError & e ) {
            // Make sure pXRef is always deleted
            delete pXRef;
            e.AddToCallstack( __FILE__, __LINE__ );
            throw e;
        }
    }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index