00001
00002
00003
00004
00005
00006 #ifndef H_CPPPDFView
00007 #define H_CPPPDFView
00008
00009 #include <PDF/PDFDoc.h>
00010 #include <PDF/PDFRasterizer.h>
00011 #include <PDF/Highlights.h>
00012 #include <PDF/OCG/Context.h>
00013 #include <C/PDF/TRN_PDFView.h>
00014
00015 namespace pdftron {
00016 namespace PDF {
00017
00031 class PDFView
00032 {
00033 public:
00034
00039 PDFView();
00040 ~PDFView();
00041
00047 void SetDoc(PDFDoc& doc);
00048
00052 void CloseDoc();
00053
00057 PDFDoc* GetDoc();
00058
00067 enum PageViewMode
00068 {
00069 e_fit_page = 0,
00070 e_fit_width,
00071 e_fit_height,
00072 e_zoom
00073 };
00074
00081 void SetPageViewMode(PageViewMode mode);
00082
00086 PageViewMode GetPageViewMode() const;
00087
00091 enum PagePresentationMode
00092 {
00093 e_single_page = 1,
00094 e_single_continuous,
00095 e_facing,
00096 e_facing_continuous,
00097 e_facing_cover,
00098 e_facing_continuous_cover
00099 };
00100
00107 void SetPagePresentationMode(PagePresentationMode mode);
00108
00112 PagePresentationMode GetPagePresentationMode() const;
00113
00117 int GetCurrentPage() const;
00118
00122 int GetPageCount() const;
00123
00129 bool GotoFirstPage();
00130
00136 bool GotoLastPage();
00137
00143 bool GotoNextPage();
00144
00150 bool GotoPreviousPage();
00151
00157 bool SetCurrentPage(int page_num);
00158
00166 bool ShowRect( int page_num, const Rect& rect );
00167
00173 double GetZoom() const;
00174
00182 bool SetZoom(double zoom);
00183
00196 bool SetZoom(int x, int y, double zoom);
00197
00201 void RotateClockwise();
00202
00206 void RotateCounterClockwise();
00207
00211 Page::Rotate GetRotation() const;
00212
00218 int GetPageNumberFromScreenPt(double x, double y) const;
00219
00223 void ConvScreenPtToCanvasPt(double& x, double& y) const;
00224
00228 void ConvCanvasPtToScreenPt(double& x, double& y) const;
00229
00237 void ConvCanvasPtToPagePt(double& x, double& y, int page_num = -1) const;
00238
00246 void ConvPagePtToCanvasPt(double& x, double& y, int page_num = -1) const;
00247
00255 void ConvScreenPtToPagePt(double& x, double& y, int page_num = -1) const;
00256
00264 void ConvPagePtToScreenPt(double& x, double& y, int page_num = -1) const;
00265
00281 Common::Matrix2D GetDeviceTransform(int page_num = -1) const;
00282
00290 void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void* data);
00291
00300 typedef void (*CurrentPageProc) (int current_page, int num_pages, void* data);
00301
00310 void SetCurrentPageProc(CurrentPageProc curr_pagenum_proc, void* data);
00311
00315 double GetCanvasWidth() const;
00316
00320 double GetCanvasHeight() const;
00321
00327 double GetHScrollPos() const;
00328
00334 double GetVScrollPos() const;
00335
00342 void OnScroll(int pix_dx, int pix_dy);
00343
00351 void SetHScrollPos(double pos);
00352
00360 void SetVScrollPos(double pos);
00361
00369 void OnSize(int width, int height);
00370
00375 bool IsFinishedRendering() const;
00376
00381 void CancelRendering();
00382
00386 void Update();
00387
00392 void Update(const Rect& update);
00393
00399 void Update(const Annot& annot, int page_num);
00400
00407 void UpdatePageLayout();
00408
00416 const char* GetBuffer() const;
00417
00422 int GetBufferWidth() const;
00423
00428 int GetBufferHeight() const;
00429
00434 int GetBufferStride() const;
00435
00442 void SetDrawAnnotations(bool render_annots);
00443
00453 void SetAntiAliasing(bool enable_aa);
00454
00468 void SetImageSmoothing(bool smoothing_enabled = true);
00469
00477 void SetCaching(bool enabled);
00478
00487 void SetRasterizerType (PDFRasterizer::Type type);
00488
00501 void SetGamma(double exp);
00502
00518 void SetOCGContext(const OCG::Context& ctx);
00519
00527 OCG::Context GetOCGContext();
00528
00535 typedef void (*RenderBeginEventProc) (void* data);
00536
00548 typedef void (*RenderFinishEventProc) (void* data, bool canceled);
00549
00562 void SetRenderBeginProc(RenderBeginEventProc proc, void* data);
00563
00576 void SetRenderFinishProc(RenderFinishEventProc proc, void* data);
00577
00578
00579
00583 class Selection {
00584 public:
00588 int GetPageNum() const;
00589
00612 int GetQuads(const double* &quads) const;
00613
00617 void GetAsUnicode(UString& out_str) const;
00618
00625 const char* GetAsHtml() const;
00626
00628 Selection();
00629 Selection(const Selection&);
00630 Selection& operator=(const Selection&);
00631 Selection(TRN_PDFViewSelection impl);
00632 private:
00633 TRN_PDFViewSelection mp_selection;
00635 };
00636
00644 bool SelectByRect(double x1, double y1, double x2, double y2);
00645
00654 bool SelectByStruct(double x1, double y1, double x2, double y2);
00655
00662 bool SelectByHighlights(const Highlights& highlights);
00663
00674 bool FindText(const UString& search_str, bool match_case = false, bool match_whole_word = false, bool search_up = false, bool reg_exp = false);
00675
00679 void SelectAll();
00680
00684 bool HasSelection() const;
00685
00689 void ClearSelection();
00690
00694 PDFView::Selection GetSelection( int pagenum = -1 ) const;
00695
00700 int GetSelectionBeginPage() const ;
00701
00706 int GetSelectionEndPage() const;
00707
00712 bool HasSelectionOnPage( int ipage ) const;
00713
00714
00719 void SetPageBorderVisibility(bool border_visible);
00720
00725 void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b);
00726
00731 void SetBackgroundColor(UInt8 r, UInt8 g, UInt8 b);
00732
00742 void SetHorizontalAlign(int align);
00743
00753 void SetVerticalAlign(int align);
00754
00764 void SetPageSpacing(int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad);
00765
00766 private:
00767 TRN_PDFView mp_view;
00768 TRN_PDFDoc temp_doc;
00769 };
00770
00771
00772
00773 #include <Impl/PDFView.inl>
00774
00775 };
00776 };
00777
00778 #endif
00779