|
00001 //--------------------------------------------------------------------------------------- 00002 // Copyright (c) 2001-2012 by PDFTron Systems Inc. All Rights Reserved. 00003 // Consult legal.txt regarding legal and license information. 00004 //--------------------------------------------------------------------------------------- 00005 00006 #ifndef H_CPPFDFDoc 00007 #define H_CPPFDFDoc 00008 00009 00010 #include <SDF/SDFDoc.h> 00011 #include <FDF/FDFField.h> 00012 #include <Common/Iterator.h> 00013 #include <C/FDF/TRN_FDFDoc.h> 00014 #include <PDF/Field.h> 00015 00016 namespace pdftron { 00017 namespace FDF { 00018 00030 typedef Common::Iterator<FDFField> FDFFieldIterator; 00031 00041 class FDFDoc 00042 { 00043 public: 00044 00050 FDFDoc(TRN_FDFDoc impl = 0, bool owner = true); 00051 00059 FDFDoc(SDF::SDFDoc& sdfdoc); 00060 00066 FDFDoc (const char* filepath); 00067 FDFDoc (const UString& filepath); 00068 00082 FDFDoc (Filters::Filter stream); 00083 00093 FDFDoc (const char* buf, size_t buf_size); 00094 00098 ~FDFDoc (); 00099 00103 void Close(); 00104 00108 bool IsModified () const; 00109 00129 void Save(const UString& path); 00130 00141 std::vector<unsigned char> Save(); 00142 00143 #ifndef SWIG 00144 void Save(const char* &out_buf, size_t& out_buf_size); 00145 #endif 00146 00150 SDF::Obj GetTrailer (); 00151 00156 SDF::Obj GetRoot(); 00157 00161 SDF::Obj GetFDF(); 00162 00169 UString GetPDFFileName(); 00170 00177 void SetPDFFileName(const UString& filepath); 00178 00184 SDF::Obj GetID(); 00185 00191 void SetID(SDF::Obj id); 00192 00207 FDFFieldIterator GetFieldIterator(); 00208 FDFFieldIterator GetFieldIterator(const UString& field_name); 00209 00210 00218 FDFField GetField(const UString& field_name); 00219 00225 FDFField FieldCreate(const UString& field_name, PDF::Field::Type type, SDF::Obj field_value = 0); 00226 FDFField FieldCreate(const UString& field_name, PDF::Field::Type type, const UString& field_value); 00227 00231 SDF::SDFDoc& GetSDFDoc (); 00232 00237 static FDFDoc CreateFromXFDF( const UString& filepath ); 00238 void SaveAsXFDF( const UString& filepath ); 00239 FDFDoc(const FDFDoc& other); 00240 00242 #ifndef SWIGHIDDEN 00243 mutable TRN_FDFDoc mp_doc; 00244 #endif 00246 private: 00247 FDFDoc& operator=(const FDFDoc& other); 00248 mutable bool m_owner; 00249 }; 00250 00251 00252 #include <Impl/FDFDoc.inl> 00253 00254 }; // namespace FDF 00255 }; // namespace pdftron 00256 00257 #endif 00258