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, ULong 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, ULong flags, Common::ProgressMonitor* progress);
00278
00293 void Save(const char* &out_buf, ULong& out_buf_size, ULong flags, Common::ProgressMonitor* progress);
00294
00310 PageIterator GetPageIterator(UInt page_number=1);
00311
00325 Page GetPage(UInt 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
00394 Page PageCreate(const Rect& media_box = Rect(0, 0, 612, 792));
00395
00401 class Bookmark GetFirstBookmark();
00402
00408 void AddRootBookmark(class Bookmark root_bookmark);
00409
00413 SDF::Obj GetTrailer ();
00414
00419 SDF::Obj GetRoot();
00420
00424 SDF::Obj GetPages();
00425
00429 int GetPageCount ();
00430
00454 FieldIterator GetFieldIterator();
00455 FieldIterator GetFieldIterator(const UString& field_name);
00456
00473 Field GetField(const UString& field_name);
00474
00490 Field FieldCreate(const UString& field_name,
00491 Field::Type type,
00492 SDF::Obj field_value = 0,
00493 SDF::Obj def_field_value = 0);
00494
00495 Field FieldCreate(const UString& field_name,
00496 Field::Type type,
00497 const UString& field_value,
00498 const UString& def_field_value);
00499
00505 void RefreshFieldAppearances();
00506
00512 void FlattenFields();
00513
00517 SDF::Obj GetAcroForm();
00518
00522 FDF::FDFDoc FDFExtract();
00523
00528 void FDFMerge(FDF::FDFDoc& fdf_doc);
00529
00538 Action GetOpenAction();
00539
00547 void SetOpenAction(const Action& action);
00548
00566 void AddFileAttachment(const char* file_key, FileSpec embedded_file);
00567
00576 PageLabel GetPageLabel(int page_num);
00577
00588 void SetPageLabel(int page_num, PageLabel& label);
00589
00599 void RemovePageLabel(int page_num);
00600
00604 Struct::STree GetStructTree();
00605
00612 bool HasOC() const;
00613
00620 SDF::Obj GetOCGs() const;
00621
00626 OCG::Config GetOCGConfig() const;
00627
00635 SDF::Obj CreateIndirectName(const char* name);
00636 SDF::Obj CreateIndirectArray();
00637 SDF::Obj CreateIndirectBool(bool value);
00638 SDF::Obj CreateIndirectDict();
00639 SDF::Obj CreateIndirectNull();
00640 SDF::Obj CreateIndirectNumber(double value);
00641 SDF::Obj CreateIndirectString(const UChar* value, UInt size);
00642 SDF::Obj CreateIndirectString(const UString& str);
00643 SDF::Obj CreateIndirectStream(Filters::FilterReader& data, Filters::Filter filter_chain=Filters::Filter(0,false));
00644 SDF::Obj CreateIndirectStream(const char* data, const ULong data_size, Filters::Filter filter_chain = Filters::Filter (0,false));
00645 SDF::Obj CreateIndirectRect(int x1,int y1,int x2,int y2);
00646 SDF::Obj CreateIndirectMatrix(Common::Matrix2D& mtx);
00647
00648
00652 SDF::SDFDoc& GetSDFDoc ();
00653
00658 operator SDF::SDFDoc& () { return GetSDFDoc(); }
00659
00660
00666 void Lock();
00667
00671 void Unlock();
00672
00676 bool IsLocked();
00677
00678
00680 TRN_PDFDoc mp_doc;
00682 private:
00683 PDFDoc (const PDFDoc&);
00684 PDFDoc& operator= (const PDFDoc&);
00685 };
00686
00687 };
00688 };
00689
00690
00691 #include <Impl/PDFDoc.inl>
00692 #endif
00693