#include <File.hh>
the PDF file class contains a list of PDF referenced objects. objects are added to the file to register an object identifier and become a referenced object. the main purpose of this class is to generate identifier number of the objects.
|
|
just shortcut
|
|
|
immutable iterator
|
|
|
shortcut
|
|
|
constructor do nothing
00041 {
00042 }
|
|
|
destructor also do nothing
00047 {
00048 }
|
|
|
this function will register an identifier to an object and add it to the file. the identifier is base on the number of object added. the reference to the object is returned.
|
|
||||||||||||||||
|
write the whole PDF file into a output stream. this function will write all the PDF file header, the PDF objects it contains and the PDF trailer to the file.
00080 {
00081 using namespace std ;
00082
00083 // PDF version string
00084 file << "%PDF-1.4" << endl ;
00085
00086 // write a 4 byte binary data comment
00087 char comment[] = "%\xfa\xce\xbe\xad" ;
00088 file << comment << endl ;
00089
00090 std::vector<int> offsets ;
00091
00092 for ( iterator i = m_objects.begin( ) ; i != m_objects.end( ) ; ++i )
00093 {
00094 streampos p = file.tellp( ) ;
00095
00096 // if we tellp( ) fails, throw exception
00097 if ( p == streampos( -1 ) )
00098 throw util::CFileError( "cannot get offset of output file" ) ;
00099
00100 // save the file position
00101 offsets.push_back( p ) ;
00102
00103 // write the object to the file
00104 file << **i ;
00105 }
00106
00107 streampos xref_offset = file.tellp( ) ;
00108 if ( xref_offset == streampos( -1 ) )
00109 throw util::CFileError( "cannot get offset of output file" ) ;
00110
00111 file << "xref\n0 " << offsets.size( ) + 1
00112 << "\n0000000000 65535 f \n" ;
00113
00114 for ( std::vector<int>::iterator i = offsets.begin( ) ;
00115 i != offsets.end( ) ; ++i )
00116 {
00117 file << setw( 10 ) << setfill( '0' ) << *i
00118 << " 00000 n \n" ;
00119 }
00120
00121 CDictionary trailer ;
00122 trailer.AddPair( "Size", new CNumber( offsets.size( ) + 1 ) ) ;
00123 trailer.AddPair( "Root", catalog.Dup( ) ) ;
00124
00125 if ( doc_info != 0 )
00126 trailer.AddPair( "Info", doc_info->Dup( ) ) ;
00127
00128 file << "trailer\n" << trailer << endl ;
00129
00130 file << "startxref" << endl
00131 << xref_offset << endl
00132 << "%%EOF" << endl ;
00133
00134 return file ;
00135 }
|
|
|
access to the contained objects via its identifier.
|
|
|
access to the contained objects via its identifier.
|
|
|
the list of objects
|
1.2.16