PDFView.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------------------
00002 // Copyright (c) 2001-2008 by PDFTron Systems Inc. All Rights Reserved.
00003 // Consult legal.txt regarding legal and license information.
00004 //---------------------------------------------------------------------------------------
00005 
00006 #ifndef   H_CPPPDFView
00007 #define   H_CPPPDFView
00008 
00009 #include <PDF/PDFDoc.h>
00010 #include <PDF/PDFRasterizer.h>
00011 #include <PDF/OCG/Context.h>
00012 #include <C/PDF/TRN_PDFView.h>
00013 
00014 namespace pdftron {
00015         namespace PDF {
00016 
00030 class PDFView
00031 {
00032 public:
00033 
00038          PDFView();
00039          ~PDFView();
00040 
00046          void SetDoc(PDFDoc& doc);
00047 
00051          PDFDoc* GetDoc();
00052 
00060         enum PageViewMode
00061         {
00062                 e_fit_page = 0,
00063                 e_fit_width,
00064                 e_zoom
00065         };
00066 
00073          void SetPageViewMode(PageViewMode mode);
00074 
00078          PageViewMode GetPageViewMode();
00079 
00089         enum PagePresentationMode
00090         {
00091                 e_single_page = 1,
00092                 e_single_continuous,
00093                 e_facing,
00094                 e_facing_continuous
00095         };
00096 
00103          void SetPagePresentationMode(PagePresentationMode mode);
00104 
00108          PagePresentationMode GetPagePresentationMode();
00109 
00113          int GetCurrentPage();
00114 
00118          int GetPageCount();
00119 
00125          bool GotoFirstPage();
00126 
00132          bool GotoLastPage();
00133 
00139          bool GotoNextPage();
00140 
00146          bool GotoPreviousPage();
00147 
00153          bool SetCurrentPage(int page_num);
00154 
00160          double GetZoom();
00161 
00169          bool SetZoom(double zoom);
00170 
00183          bool SetZoom(int x, int y, double zoom);
00184 
00188          void RotateClockwise();
00189 
00193          void RotateCounterClockwise();
00194 
00200          int GetPageNumberFromScreenPt(double x, double y);
00201 
00205          void ConvScreenPtToCanvasPt(double& x, double& y);
00206 
00210          void ConvCanvasPtToScreenPt(double& x, double& y);
00211 
00219          void ConvCanvasPtToPagePt(double& x, double& y, int page_num = -1);
00220 
00228          void ConvPagePtToCanvasPt(double& x, double& y, int page_num = -1);
00229 
00237          void ConvScreenPtToPagePt(double& x, double& y, int page_num = -1);
00238 
00246          void ConvPagePtToScreenPt(double& x, double& y, int page_num = -1);
00247 
00263          Common::Matrix2D GetDeviceTransform(int page_num = -1);
00264 
00272          void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void* data);
00273 
00282         typedef void (*CurrentPageProc) (int current_page, int num_pages, void* data);
00283 
00292          void SetCurrentPageProc(CurrentPageProc curr_pagenum_proc, void* data);
00293 
00297          double GetCanvasWidth();
00298 
00302          double GetCanvasHeight();
00303 
00309          double GetHScrollPos();
00310 
00316          double GetVScrollPos();
00317 
00324          void OnScroll(int pix_dx, int pix_dy);
00325 
00333          void SetHScrollPos(double pos);
00334 
00342          void SetVScrollPos(double pos);
00343 
00357          void OnSize(int width, int height, int stride);
00358 
00363          bool IsFinishedRendering();
00364 
00369          void CancelRendering();
00370 
00374          void Update();
00375 
00383          const char* GetBuffer();
00384 
00389          int GetBufferWidth();
00390 
00395          int GetBufferHeight();
00396 
00401          int GetBufferStride();
00402 
00408          void InvalidateRect(const Rect* rect = 0);
00409 
00416          void SetDrawAnnotations(bool render_annots);
00417 
00427          void SetAntiAliasing(bool enable_aa);
00428 
00442          void SetImageSmoothing(bool smoothing_enabled = true);
00443 
00450          void SetCaching(bool enabled);
00451 
00460          void SetRasterizerType (PDFRasterizer::Type type);
00461 
00474         void SetGamma(double exp);
00475 
00491         void SetOCGContext(const OCG::Context& ctx);
00492 
00500         OCG::Context GetOCGContext();
00501 
00508         typedef void (*RenderBeginEventProc) (void* data);
00509 
00521         typedef void (*RenderFinishEventProc) (void* data, bool canceled);
00522 
00535          void SetRenderBeginProc(RenderBeginEventProc proc, void* data);
00536 
00549          void SetRenderFinishProc(RenderFinishEventProc proc, void* data);
00550 
00555         enum ToolMode 
00556         {
00557                 e_pan = 1,                // Pan tool
00558                 e_text_rect_select,       // Rectangular text selection tool
00559                 e_text_struct_select,     // HTML Style text selection tool
00560                 e_custom                  // Custom tool
00561         };
00562 
00567          void SetToolMode(ToolMode mode);
00568 
00572          ToolMode GetToolMode();
00573 
00577         class Selection {
00578         public:
00582                  int GetPageNum();
00583 
00597                  int GetRects(double* &rects);
00598 
00602                  void GetAsUnicode(UString& out_str);
00603 
00610                  const char* GetAsHtml();
00611 
00613                  Selection();
00614                  Selection(const Selection&);
00615                  Selection& operator=(const Selection&);
00616                  Selection(TRN_PDFViewSelection impl);
00617         private:
00618                 TRN_PDFViewSelection mp_selection;
00620         };
00621 
00629          bool SelectByRect(double x1, double y1, double x2, double y2);
00630 
00639          bool SelectByStruct(double x1, double y1, double x2, double y2);
00640 
00650         bool FindText(const UString& search_str, bool match_case = false, bool match_whole_word = false, bool search_up = false);
00651 
00655          void SelectAll();
00656 
00660          bool HasSelection();
00661 
00665          void ClearSelection();
00666 
00670          PDFView::Selection GetSelection();
00671 
00676         void SetPageBorderVisibility(bool border_visible);
00677 
00682         void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b);
00683 
00688         void SetBackgroundColor(UInt8 r, UInt8 g, UInt8 b);
00689 
00699         void SetHorizontalAlign(int align);
00700 
00710         void SetVerticalAlign(int align);
00711 
00712 private:
00713         TRN_PDFView mp_view;
00714         TRN_PDFDoc temp_doc;
00715 };
00716 
00717 
00718 
00719 #include <Impl/PDFView.inl>
00720 
00721         };      // namespace PDF
00722 };      // namespace pdftron
00723 
00724 #endif
00725 

© 2002-2008 PDFTron Systems Inc.