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/Struct/STree.h>
00013 #include <PDF/OCG/Config.h>
00014 #include <C/PDF/TRN_PDFDoc.h>
00015 #include <PDF/PDFDocViewPrefs.h>
00016 #include <SDF/SDFDoc.h>
00017 #include <PDF/Page.h>
00018 #include <Common/Iterator.h>
00019
00020 namespace pdftron {
00021 namespace PDF {
00022
00027 typedef Common::Iterator<Page> PageIterator;
00028
00033 typedef Common::Iterator<Field> FieldIterator;
00034
00035
00052 class PDFDoc
00053 {
00054 public:
00055
00059 PDFDoc ();
00060
00070 PDFDoc (SDF::SDFDoc& sdfdoc);
00071
00080 PDFDoc (const UString& filepath);
00081 PDFDoc (const char* filepath);
00082
00096 PDFDoc (Filters::Filter stream);
00097
00107 PDFDoc (const char* buf, size_t buf_size);
00108
00112 ~PDFDoc ();
00113
00117 bool IsEncrypted();
00118
00144 bool InitSecurityHandler (void* custom_data = 0);
00145
00176 bool InitStdSecurityHandler (const char* password, int password_sz = 0);
00177
00192 SDF::SecurityHandler GetSecurityHandler ();
00193
00205 void SetSecurityHandler (SDF::SecurityHandler handler);
00206
00210 void RemoveSecurity();
00211
00216 PDFDocInfo GetDocInfo();
00217
00225 PDFDocViewPrefs GetViewPrefs();
00226
00233 bool IsModified () const;
00234
00254 bool IsLinearized() const;
00255
00277 void Save(const UString& path, UInt32 flags, Common::ProgressMonitor* progress);
00278
00293 void Save(const char* &out_buf, size_t& out_buf_size, UInt32 flags, Common::ProgressMonitor* progress);
00294
00310 PageIterator GetPageIterator(UInt32 page_number=1);
00311
00325 Page GetPage(UInt32 page_number);
00326
00332 void PageRemove(const PageIterator& page_itr);
00333
00344 void PageInsert(PageIterator& where, Page page);
00345
00351 void PagePushFront(Page page);
00352
00358 void PagePushBack(Page page);
00359
00376 std::vector<Page> ImportPages(const std::vector<Page>& pages, bool import_bookmarks = false);
00377
00443 Page PageCreate(const Rect& media_box = Rect(0, 0, 612, 792));
00444
00450 class Bookmark GetFirstBookmark();
00451
00457 void AddRootBookmark(class Bookmark root_bookmark);
00458
00462 SDF::Obj GetTrailer ();
00463
00468 SDF::Obj GetRoot();
00469
00473 SDF::Obj GetPages();
00474
00478 int GetPageCount ();
00479
00503 FieldIterator GetFieldIterator();
00504 FieldIterator GetFieldIterator(const UString& field_name);
00505
00522 Field GetField(const UString& field_name);
00523
00539 Field FieldCreate(const UString& field_name,
00540 Field::Type type,
00541 SDF::Obj field_value = 0,
00542 SDF::Obj def_field_value = 0);
00543
00544 Field FieldCreate(const UString& field_name,
00545 Field::Type type,
00546 const UString& field_value,
00547 const UString& def_field_value);
00548
00554 void RefreshFieldAppearances();
00555
00561 void FlattenFields();
00562
00566 SDF::Obj GetAcroForm();
00567
00571 FDF::FDFDoc FDFExtract();
00572
00577 void FDFMerge(FDF::FDFDoc& fdf_doc);
00578
00587 Action GetOpenAction();
00588
00596 void SetOpenAction(const Action& action);
00597
00615 void AddFileAttachment(const char* file_key, FileSpec embedded_file);
00616
00625 PageLabel GetPageLabel(int page_num);
00626
00637 void SetPageLabel(int page_num, PageLabel& label);
00638
00648 void RemovePageLabel(int page_num);
00649
00653 bool IsTagged();
00654
00658 Struct::STree GetStructTree();
00659
00666 bool HasOC() const;
00667
00674 SDF::Obj GetOCGs() const;
00675
00680 OCG::Config GetOCGConfig() const;
00681
00693 void AddHighlights(const UString& hilite);
00694
00702 SDF::Obj CreateIndirectName(const char* name);
00703 SDF::Obj CreateIndirectArray();
00704 SDF::Obj CreateIndirectBool(bool value);
00705 SDF::Obj CreateIndirectDict();
00706 SDF::Obj CreateIndirectNull();
00707 SDF::Obj CreateIndirectNumber(double value);
00708 SDF::Obj CreateIndirectString(const UChar* value, UInt32 size);
00709 SDF::Obj CreateIndirectString(const UString& str);
00710 SDF::Obj CreateIndirectStream(Filters::FilterReader& data, Filters::Filter filter_chain=Filters::Filter(0,false));
00711 SDF::Obj CreateIndirectStream(const char* data, const size_t data_size, Filters::Filter filter_chain = Filters::Filter (0,false));
00712
00716 SDF::SDFDoc& GetSDFDoc ();
00717
00722 operator SDF::SDFDoc& () { return GetSDFDoc(); }
00723
00724
00730 void Lock();
00731
00735 void Unlock();
00736
00740 bool IsLocked();
00741
00746 bool TryLock( int milliseconds = 0 );
00747
00753 UString GetFileName() const;
00754
00756 TRN_PDFDoc mp_doc;
00758 private:
00759 PDFDoc (const PDFDoc&);
00760 PDFDoc& operator= (const PDFDoc&);
00761 };
00762
00763 };
00764 };
00765
00766
00767 #include <Impl/PDFDoc.inl>
00768 #endif
00769