00001
00002
00003
00004
00005
00006 #ifndef H_CPPPDFDoc
00007 #define H_CPPPDFDoc
00008
00009 #include <FDF/FDFDoc.h>
00010 #include <PDF/PDFDocInfo.h>
00011 #include <PDF/PageLabel.h>
00012 #include <PDF/OCG/Config.h>
00013 #include <C/PDF/TRN_PDFDoc.h>
00014 #include <PDF/PDFDocViewPrefs.h>
00015 #include <SDF/SDFDoc.h>
00016 #include <PDF/Page.h>
00017 #include <PDF/PageSet.h>
00018 #include <Common/Iterator.h>
00019
00020 namespace pdftron {
00021 namespace PDF {
00022 namespace Struct{class STree;};
00023
00028 typedef Common::Iterator<Page> PageIterator;
00029
00034 typedef Common::Iterator<Field> FieldIterator;
00035
00036
00053 class PDFDoc
00054 {
00055 public:
00056
00060 PDFDoc ();
00061
00071 PDFDoc (SDF::SDFDoc& sdfdoc);
00072
00081 PDFDoc (const UString& filepath);
00082 PDFDoc (const char* filepath);
00083
00097 PDFDoc (Filters::Filter stream);
00098
00108 PDFDoc (const UChar* buf, size_t buf_size);
00109
00113 ~PDFDoc ();
00114
00118 void Close();
00119
00123 bool IsEncrypted();
00124
00150 bool InitSecurityHandler (
00151 #ifndef SWIG
00152 void* custom_data = 0
00153 #endif
00154 );
00155
00186 bool InitStdSecurityHandler (const char* password, int password_sz = 0);
00187
00202 SDF::SecurityHandler GetSecurityHandler ();
00203
00215 void SetSecurityHandler (SDF::SecurityHandler handler);
00216
00220 void RemoveSecurity();
00221
00226 PDFDocInfo GetDocInfo();
00227
00235 PDFDocViewPrefs GetViewPrefs();
00236
00243 bool IsModified () const;
00244
00264 bool IsLinearized() const;
00265
00287 void Save(const UString& path, UInt32 flags);
00288
00289 #ifndef SWIG
00290 void Save(const UString& path, UInt32 flags, Common::ProgressMonitor* progress);
00291 #endif
00292
00307 std::vector<unsigned char> Save(UInt32 flags);
00308
00309 #ifndef SWIG
00310 void Save(const char* &out_buf, size_t& out_buf_size, UInt32 flags, Common::ProgressMonitor* progress);
00311 #endif
00312
00328 PageIterator GetPageIterator(UInt32 page_number=1);
00329
00343 Page GetPage(UInt32 page_number);
00344
00350 void PageRemove(const PageIterator& page_itr);
00351
00352 enum InsertFlag {
00353 e_none,
00354 e_insert_bookmark
00355 };
00356
00367 void PageInsert(PageIterator& where, Page page);
00368
00381 void InsertPages(int insertBeforeThisPage
00382 , PDFDoc& sourceDoc
00383 , int startPage
00384 , int endPage
00385 , enum InsertFlag flag
00386 #ifndef SWIG
00387 , Common::ProgressMonitor * monitor = 0
00388 #endif
00389 );
00390
00402 void InsertPages(int insertBeforeThisPage
00403 , PDFDoc& sourceDoc
00404 , const PageSet& sourcePageSet
00405 , enum InsertFlag flag
00406 #ifndef SWIG
00407 , Common::ProgressMonitor * monitor = 0
00408 #endif
00409 );
00410
00411
00426 void MovePages(int moveBeforeThisPage
00427 , PDFDoc& sourceDoc
00428 , int startPage
00429 , int endPage
00430 , enum InsertFlag flag
00431 #ifndef SWIG
00432 , Common::ProgressMonitor * monitor = 0
00433 #endif
00434 );
00435
00436
00450 void MovePages(int moveBeforeThisPage
00451 , PDFDoc& sourceDoc
00452 , const PageSet& sourcePageSet
00453 , enum InsertFlag flag
00454 #ifndef SWIG
00455 , Common::ProgressMonitor * monitor = 0
00456 #endif
00457 );
00458
00464 void PagePushFront(Page page);
00465
00471 void PagePushBack(Page page);
00472
00489 std::vector<Page> ImportPages(const std::vector<Page>& pages, bool import_bookmarks = false);
00490
00556 Page PageCreate(const Rect& media_box = Rect(0, 0, 612, 792));
00557
00563 class Bookmark GetFirstBookmark();
00564
00570 void AddRootBookmark(class Bookmark root_bookmark);
00571
00575 SDF::Obj GetTrailer ();
00576
00581 SDF::Obj GetRoot();
00582
00586 SDF::Obj GetPages();
00587
00591 int GetPageCount ();
00592
00616 FieldIterator GetFieldIterator();
00617 FieldIterator GetFieldIterator(const UString& field_name);
00618
00635 Field GetField(const UString& field_name);
00636
00652 Field FieldCreate(const UString& field_name,
00653 Field::Type type,
00654 SDF::Obj field_value = 0,
00655 SDF::Obj def_field_value = 0);
00656
00657 Field FieldCreate(const UString& field_name,
00658 Field::Type type,
00659 const UString& field_value,
00660 const UString& def_field_value);
00661
00667 void RefreshFieldAppearances();
00668
00674 void FlattenAnnotations(bool forms_only = false);
00675
00679 SDF::Obj GetAcroForm();
00680
00684 FDF::FDFDoc FDFExtract();
00685
00690 void FDFMerge(FDF::FDFDoc& fdf_doc);
00691
00700 Action GetOpenAction();
00701
00709 void SetOpenAction(const Action& action);
00710
00728 void AddFileAttachment(const UString& file_key, FileSpec embedded_file);
00729
00738 PageLabel GetPageLabel(int page_num);
00739
00750 void SetPageLabel(int page_num, PageLabel& label);
00751
00761 void RemovePageLabel(int page_num);
00762
00766 bool IsTagged();
00767
00771 Struct::STree GetStructTree();
00772
00779 bool HasOC() const;
00780
00787 SDF::Obj GetOCGs() const;
00788
00793 OCG::Config GetOCGConfig() const;
00794
00806 void AddHighlights(const UString& hilite);
00807
00815 SDF::Obj CreateIndirectName(const char* name);
00816 SDF::Obj CreateIndirectArray();
00817 SDF::Obj CreateIndirectBool(bool value);
00818 SDF::Obj CreateIndirectDict();
00819 SDF::Obj CreateIndirectNull();
00820 SDF::Obj CreateIndirectNumber(double value);
00821 SDF::Obj CreateIndirectString(const UChar* value, UInt32 size);
00822 SDF::Obj CreateIndirectString(const UString& str);
00823 SDF::Obj CreateIndirectStream(Filters::FilterReader& data, Filters::Filter filter_chain=Filters::Filter(0,false));
00824 SDF::Obj CreateIndirectStream(const char* data, const size_t data_size, Filters::Filter filter_chain = Filters::Filter (0,false));
00825
00829 SDF::SDFDoc& GetSDFDoc ();
00830
00835 operator SDF::SDFDoc& () { return GetSDFDoc(); }
00836
00837
00843 void Lock();
00844
00848 void Unlock();
00849
00853 bool IsLocked();
00854
00859 bool TryLock( int milliseconds = 0 );
00860
00866 UString GetFileName() const;
00867
00869 #ifndef SWIGHIDDEN
00870 TRN_PDFDoc mp_doc;
00871 #endif
00873 private:
00874 PDFDoc (const PDFDoc&);
00875 PDFDoc& operator= (const PDFDoc&);
00876 };
00877
00878 };
00879 };
00880
00881
00882 #include <Impl/PDFDoc.inl>
00883 #endif
00884