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 #ifdef SWIG
00015 #include <PDF/Callback.h>
00016 #endif
00017
00018 namespace pdftron {
00019 namespace PDF {
00020
00065 class PDFView
00066 {
00067 public:
00068
00073 PDFView();
00074 ~PDFView();
00075
00081 void SetDoc(PDFDoc& doc);
00082
00086 void CloseDoc();
00087
00091 PDFDoc* GetDoc();
00092
00101 enum PageViewMode
00102 {
00103 e_fit_page = 0,
00104 e_fit_width,
00105 e_fit_height,
00106 e_zoom
00107 };
00108
00115 void SetPageViewMode(PageViewMode mode);
00116
00120 PageViewMode GetPageViewMode() const;
00121
00125 enum PagePresentationMode
00126 {
00127 e_single_page = 1,
00128 e_single_continuous,
00129 e_facing,
00130 e_facing_continuous,
00131 e_facing_cover,
00132 e_facing_continuous_cover
00133 };
00134
00141 void SetPagePresentationMode(PagePresentationMode mode);
00142
00146 PagePresentationMode GetPagePresentationMode() const;
00147
00151 int GetCurrentPage() const;
00152
00156 int GetPageCount() const;
00157
00163 bool GotoFirstPage();
00164
00170 bool GotoLastPage();
00171
00177 bool GotoNextPage();
00178
00184 bool GotoPreviousPage();
00185
00191 bool SetCurrentPage(int page_num);
00192
00200 bool ShowRect( int page_num, const Rect& rect );
00201
00207 double GetZoom() const;
00208
00216 bool SetZoom(double zoom);
00217
00245 bool SetZoom(int x, int y, double zoom);
00246
00250 void RotateClockwise();
00251
00255 void RotateCounterClockwise();
00256
00260 Page::Rotate GetRotation() const;
00261
00267 int GetPageNumberFromScreenPt(double x, double y) const;
00268
00272 Point ConvScreenPtToCanvasPt(const Point& pt) const;
00273
00274 #ifndef SWIG
00275 void ConvScreenPtToCanvasPt(double& x, double& y) const;
00276 #endif
00277
00281 Point ConvCanvasPtToScreenPt(const Point& pt) const;
00282
00283 #ifndef SWIG
00284 void ConvCanvasPtToScreenPt(double& x, double& y) const;
00285 #endif
00286
00294 Point ConvCanvasPtToPagePt(const Point& pt, int page_num = -1) const;
00295
00296 #ifndef SWIG
00297 void ConvCanvasPtToPagePt(double& x, double& y, int page_num = -1) const;
00298 #endif
00299
00307 Point ConvPagePtToCanvasPt(const Point& pt, int page_num = -1) const;
00308
00309 #ifndef SWIG
00310 void ConvPagePtToCanvasPt(double& x, double& y, int page_num = -1) const;
00311 #endif
00312
00320 Point ConvScreenPtToPagePt(const Point& pt, int page_num = -1) const;
00321
00322 #ifndef SWIG
00323 void ConvScreenPtToPagePt(double& x, double& y, int page_num = -1) const;
00324 #endif
00325
00333 Point ConvPagePtToScreenPt(const Point& pt, int page_num = -1) const;
00334
00335 #ifndef SWIG
00336 void ConvPagePtToScreenPt(double& x, double& y, int page_num = -1) const;
00337 #endif
00338
00354 Common::Matrix2D GetDeviceTransform(int page_num = -1) const;
00355
00363 #ifdef SWIG
00364 void SetErrorReportProc(Callback* instance);
00365 #else
00366 void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void* data);
00367 #endif
00368
00377 typedef void (*CurrentPageProc) (int current_page, int num_pages, void* data);
00378
00387 #ifdef SWIG
00388 void SetCurrentPageProc(Callback* instance);
00389 #else
00390 void SetCurrentPageProc(CurrentPageProc curr_pagenum_proc, void* data);
00391 #endif
00392
00400 typedef void (*CurrentZoomProc) (double curr_zoom_proc, void* data);
00401
00410 #ifdef SWIG
00411 void SetCurrentZoomProc(Callback* instance);
00412 #else
00413 void SetCurrentZoomProc(CurrentZoomProc curr_zoom_proc, void* data);
00414 #endif
00415
00419 double GetCanvasWidth() const;
00420
00424 double GetCanvasHeight() const;
00425
00429 double GetHScrollPos() const;
00430
00434 double GetVScrollPos() const;
00435
00442 void OnScroll(int pix_dx, int pix_dy);
00443
00450 void SetHScrollPos(double pos);
00451
00474 void SetVScrollPos(double pos);
00475
00483 void OnSize(int width, int height);
00484
00489 bool IsFinishedRendering() const;
00490
00495 void CancelRendering();
00496
00500 void Update();
00501
00506 void Update(const Rect& update);
00507
00513 void Update(const Annot& annot, int page_num);
00514
00521 void UpdatePageLayout();
00522
00528 #ifdef SWIG
00529 std::vector<unsigned char> GetBuffer() const;
00530 #else
00531 const char* GetBuffer() const;
00532 #endif
00533
00546 void UpdateBuffer();
00547
00552 int GetBufferWidth() const;
00553
00558 int GetBufferHeight() const;
00559
00564 int GetBufferStride() const;
00565
00572 void SetDrawAnnotations(bool render_annots);
00573
00579 void SetHighlightFields(bool highlight_fields);
00580
00590 void SetAntiAliasing(bool enable_aa);
00591
00600 void SetPathHinting(bool path_hinting);
00601
00612 void SetThinLineAdjustment(bool pixel_grid_fit, bool stroke_adjust);
00613
00627 void SetImageSmoothing(bool smoothing_enabled = true);
00628
00636 void SetCaching(bool enabled);
00637
00646 void SetRasterizerType (PDFRasterizer::Type type);
00647
00660 void SetGamma(double exp);
00661
00671 void SetOverprint(PDFRasterizer::OverprintPreviewMode op);
00672
00688 void SetOCGContext(const OCG::Context& ctx);
00689
00697 OCG::Context GetOCGContext();
00698
00705 typedef void (*RenderBeginEventProc) (void* data);
00706
00718 typedef void (*RenderFinishEventProc) (void* data, bool canceled);
00719
00732 #ifdef SWIG
00733 void SetRenderBeginProc(Callback* instance);
00734 #else
00735 void SetRenderBeginProc(RenderBeginEventProc proc, void* data);
00736 #endif
00737
00750 #ifdef SWIG
00751 void SetRenderFinishProc(Callback* instance);
00752 #else
00753 void SetRenderFinishProc(RenderFinishEventProc proc, void* data);
00754 #endif
00755
00756
00757
00761 class Selection {
00762 public:
00766 int GetPageNum() const;
00767
00792 std::vector<QuadPoint> GetQuads() const;
00793
00794 #ifndef SWIG
00795 int GetQuads(const double* &quads) const;
00796 #endif
00797
00801 UString GetAsUnicode() const;
00802
00803 #ifndef SWIG
00804 void GetAsUnicode(UString& out_str) const;
00805 #endif
00806
00813 const char* GetAsHtml() const;
00814
00816 #ifndef SWIGHIDDEN
00817 Selection();
00818 Selection(const Selection&);
00819 Selection& operator=(const Selection&);
00820 Selection(TRN_PDFViewSelection impl);
00821 private:
00822 TRN_PDFViewSelection mp_selection;
00823 #endif
00825 };
00826
00827
00828
00829
00830
00831
00832
00833 enum TextSelectionMode {
00834 e_structural,
00835 e_rectangular
00836 };
00837
00842 void SetTextSelectionMode(TextSelectionMode tm);
00843
00851 bool Select(double x1, double y1, double x2, double y2);
00852
00860 bool Select(double x1, double y1, int page1, double x2, double y2, int page2);
00861
00868 bool Select(const Highlights& highlights);
00869
00880 bool FindText(const UString& search_str, bool match_case = false, bool match_whole_word = false, bool search_up = false, bool reg_exp = false);
00881
00885 void SelectAll();
00886
00890 bool HasSelection() const;
00891
00895 void ClearSelection();
00896
00900 PDFView::Selection GetSelection( int pagenum = -1 ) const;
00901
00906 int GetSelectionBeginPage() const ;
00907
00912 int GetSelectionEndPage() const;
00913
00918 bool HasSelectionOnPage( int ipage ) const;
00919
00924 void SetPageBorderVisibility(bool border_visible);
00925
00931 void SetPageTransparencyGrid(bool trans_grid_visible);
00932
00937 void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b);
00938
00943 void SetBackgroundColor(UInt8 r, UInt8 g, UInt8 b);
00944
00954 void SetHorizontalAlign(int align);
00955
00965 void SetVerticalAlign(int align);
00966
00976 void SetPageSpacing(int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad);
00977
00981 void Destroy();
00982
00991 Annot GetAnnotationAt(int x, int y);
00992
00993
00995 #if defined(__iOS__) || defined(__ANDROID__)
00996
00997 void PushViewingStates();
00998 void PopViewingStates(bool restore);
00999
01000 void SetFreezeTile(bool freeze);
01001
01002 void SetThumbRenderEnabled(bool enable);
01003
01004 int GetCurCanvasId() const;
01005
01006 void GetPageRects(const Rect& rect, std::vector<double>& page_rects_info) const;
01007
01008 void DoProgressiveRender();
01009
01010 int GetCellSideLength() const;
01011
01012 double GetPageVGap() const;
01013 double GetPageHGap() const;
01014
01015 void RequestRender();
01016
01017 bool IsValidTile(int canvasNumber, int cellNumber);
01018
01019 void PurgeMemory();
01020 void SetMemInfo(double total_mem, double mem_cap);
01021
01027 void ExecuteAction(Action& action);
01028
01029 typedef void (*CreateTileProc)(void* pdfview, char* buffer, int originX, int originY, int width, int height,
01030 int page_num, int cellNumber, bool finalRender, bool predictionRender, int tiles_remaining,
01031 bool first_tile, int canvas_width, int canvas_height, int cell_side_length, int cell_per_row, int cell_per_col,
01032 int thumb_nail_id);
01033
01034 typedef void (*RemoveTileProc)(void* callingObject, int canvasNumber, int cellNumber, int thumb_nail_id);
01035
01036 #ifdef SWIG
01037 void SetWrapperCreateTileProc(Callback* instance);
01038 void SetWrapperRemoveTileProc(Callback* instance);
01039 #else
01040 void SetWrapperCreateTileProc(CreateTileProc wrapperCreateTileProc, void* callingObject);
01041 void SetWrapperRemoveTileProc(RemoveTileProc wrapperRemoveTileProc, void* callingObject);
01042 #endif
01043
01044 #endif
01045
01046 private:
01047 TRN_PDFView mp_view;
01048 TRN_PDFDoc temp_doc;
01049 };
01050
01051
01052
01053 #include <Impl/PDFView.inl>
01054
01055 };
01056 };
01057
01058 #endif
01059