00001
00002
00003
00004
00005
00006 #ifndef H_CPPPDFAnnot
00007 #define H_CPPPDFAnnot
00008
00009 #include <SDF/Obj.h>
00010 #include <PDF/Date.h>
00011 #include <SDF/SDFDoc.h>
00012 #include <PDF/Rect.h>
00013 #include <PDF/ColorSpace.h>
00014 #include <PDF/FileSpec.h>
00015 #include <C/PDF/TRN_Annot.h>
00016 #include <vector>
00017
00018 namespace pdftron {
00019 namespace PDF {
00020
00038 class Annot
00039 {
00040 public:
00041
00042
00047 enum Type
00048 {
00049 e_Text,
00050 e_Link,
00051 e_FreeText,
00052 e_Line,
00053 e_Square,
00054 e_Circle,
00055 e_Polygon,
00056 e_Polyline,
00057 e_Highlight,
00058 e_Underline,
00059 e_Squiggly,
00060 e_StrikeOut,
00061 e_Stamp,
00062 e_Caret,
00063 e_Ink,
00064 e_Popup,
00065 e_FileAttachment,
00066 e_Sound,
00067 e_Movie,
00068 e_Widget,
00069 e_Screen,
00070 e_PrinterMark,
00071 e_TrapNet,
00072 e_Watermark,
00073 e_3D,
00074 e_Unknown
00075 };
00076
00090 static Annot Create(SDF::SDFDoc& doc, Type type, const Rect& pos);
00091
00102 static Annot CreateLink(SDF::SDFDoc& doc, const Rect& pos, const class Action& action);
00103
00121 static Annot CreateText(SDF::SDFDoc& doc, const Rect& pos, const UString& contents);
00122
00142 static Annot CreateStamp(SDF::SDFDoc& doc, const Rect& pos, const char* name = "Draft");
00143
00160 static Annot CreateWidget(SDF::SDFDoc& doc, const Rect& pos, class Field field);
00161
00179 static Annot CreateFileAttachment(SDF::SDFDoc& doc, const Rect& pos, const char* path, const char* icon_name = "PushPin");
00180
00186 Annot (SDF::Obj d = 0);
00187
00191 Annot (const Annot& d);
00192
00196 Annot& operator=(const Annot& d);
00197
00202 bool operator==(const Annot& d);
00203
00209 bool IsValid() const;
00210
00214 Type GetType() const;
00215
00219 SDF::Obj GetSDFObj () const;
00220
00229 Rect GetRect() const;
00230
00240 void SetRect(const Rect& pos);
00241
00283 enum Flag
00284 {
00285 e_invisible,
00286 e_hidden,
00287 e_print,
00288 e_no_zoom,
00289 e_no_rotate,
00290 e_no_view,
00291 e_read_only,
00292 e_locked,
00293 e_toggle_no_view
00294 };
00295
00300 bool GetFlag(Flag flag) const;
00301
00308 void SetFlag(Flag flag, bool value);
00309
00315 Date GetDate() const;
00316
00320 void SetDate(const Date& date);
00321
00327 SDF::Obj GetUniqueID() const;
00328
00335 void SetUniqueID(const char* id, int id_buf_sz = 0);
00336
00350 ColorPt GetColor() const;
00351
00362 void SetColor(const ColorPt& rgb);
00363
00368 class BorderStyle
00369 {
00370 public:
00371
00372
00373 enum Style {
00374 e_solid,
00375 e_dashed,
00376 e_beveled,
00377 e_inset,
00378 e_underline
00379 };
00380
00394 BorderStyle(Style s, int b_width, int b_hr, int b_vr);
00395 BorderStyle(Style s, int b_width, int b_hr, int b_vr, const std::vector<double>& b_dash);
00396 BorderStyle(const BorderStyle&);
00397 ~BorderStyle();
00398
00399 Style GetStyle();
00400 void SetStyle(Style style);
00401
00402 int GetHR();
00403 void SetHR(int hr);
00404
00405 int GetVR();
00406 void SetVR(int vr);
00407
00408 int GetWidth();
00409 void SetWidth(int width);
00410
00411 std::vector<double> GetDash();
00412 void SetDash(std::vector<double> dash);
00413
00414 BorderStyle(TRN_AnnotBorderStyle impl);
00415 private:
00416 friend class PDF::Annot;
00417 BorderStyle& operator=(const BorderStyle&);
00418 TRN_AnnotBorderStyle mp_bs;
00419 };
00420
00426 BorderStyle GetBorderStyle() const;
00427
00433 void SetBorderStyle(const BorderStyle& bs);
00434
00447 enum AnnotationState
00448 {
00449 e_normal,
00450 e_rollover,
00451 e_down
00452 };
00453
00471 SDF::Obj GetAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
00472
00487 void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state = e_normal, const char* app_state = 0);
00488
00489
00490
00491
00499 class Action GetLinkAction() const;
00500
00506 void SetLinkAction(const class Action& action);
00507
00512 void RemoveLinkAction();
00513
00514
00515
00516
00523 void SetTextContents(const UString& contents);
00524
00534 SDF::Obj GetTextContents() const;
00535
00549 const char* GetTextIcon() const;
00550
00564 void SetTextIcon(const char* icon_name);
00565
00580 bool IsTextAnnotOpen() const;
00581
00590 void SetTextAnnotOpen(bool is_open);
00591
00592
00593
00594
00604 const char* GetStampName() const;
00605
00618 void SetStampName(const char* name);
00619
00620
00621
00622
00630 class Field GetWidgetField() const;
00631
00632
00633
00634
00644 FileSpec GetFileAttachment() const;
00645
00653 void SetFileAttachment(const FileSpec& file);
00654
00671 bool FileAttachmentExport(const UString& save_as = "") const;
00672
00674 Annot(TRN_Annot annot);
00675 TRN_Annot mp_annot;
00677 };
00678
00679 };
00680 };
00681
00682
00683
00684 #include <Impl/Page.inl>
00685 #endif
00686