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

void PoDoFo::PdfWriter::FillTrailerObject ( PdfObject pTrailer,
pdf_long  lSize,
bool  bPrevEntry,
bool  bOnlySizeKey 
) const

Add required keys to a trailer object

Parameters:
pTraileradd keys to this object
lSizenumber of objects in the PDF file
bPrevEntryif true a prev entry is added to the trailer object with a value of 0
bOnlySizeKeywrite only the size key

Definition at line 452 of file PdfWriter.cpp.

References PoDoFo::PdfDictionary::AddKey(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfDictionary::GetKey(), PoDoFo::PdfDictionary::HasKey(), m_pEncryptObj, PoDoFo::PdfArray::push_back(), and PoDoFo::PdfObject::Reference().

Referenced by PoDoFo::PdfXRefStream::EndWrite(), PoDoFo::PdfImmediateWriter::Finish(), and Write().

{
    // this will be overwritten later with valid data
    PdfVariant place_holder( PdfData( LINEARIZATION_PADDING ) );

    pTrailer->GetDictionary().AddKey( PdfName::KeySize, static_cast<pdf_int64>(lSize) );

    if( !bOnlySizeKey ) 
    {
        if( m_pTrailer->GetDictionary().HasKey( "Root" ) )
            pTrailer->GetDictionary().AddKey( "Root", m_pTrailer->GetDictionary().GetKey( "Root" ) );
        /*
          DominikS: It makes no sense to simple copy an encryption key
                    Either we have no encryption or we encrypt again by ourselves
        if( m_pTrailer->GetDictionary().HasKey( "Encrypt" ) )
            pTrailer->GetDictionary().AddKey( "Encrypt", m_pTrailer->GetDictionary().GetKey( "Encrypt" ) );
        */
        if( m_pTrailer->GetDictionary().HasKey( "Info" ) )
            pTrailer->GetDictionary().AddKey( "Info", m_pTrailer->GetDictionary().GetKey( "Info" ) );


        if( m_pEncryptObj ) 
            pTrailer->GetDictionary().AddKey( PdfName("Encrypt"), m_pEncryptObj->Reference() );

        // maybe only call this function if bPrevEntry is false
        PdfArray array;
        // The ID is the same unless the PDF was incrementally updated
        array.push_back( m_identifier );
        array.push_back( m_identifier );

        // finally add the key to the trailer dictionary
        pTrailer->GetDictionary().AddKey( "ID", array );

        if( bPrevEntry )
        {
            pTrailer->GetDictionary().AddKey( "Prev", place_holder );
        }
    }
}

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