- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Callback.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFCallback
6 #define PDFTRON_H_CPPPDFCallback
7
8 #ifdef SWIG
9
10 #include <C/Common/TRN_Types.h>
11 #include <Common/BasicTypes.h>
12 #include <PDF/Selection.h>
13
14 namespace pdftron {
15 namespace PDF {
16
25 class Callback
26 {
27 public:
28 Callback() {}
29 virtual ~Callback() {
30 }
31
32 // PDFView Callbacks
33 virtual void RenderBeginEventProc(){}
34
35 static void StaticRenderBeginEventProc(void* data)
36 {
37 Callback* cb = (Callback*) data;
38 cb->RenderBeginEventProc();
39 }
40
41 virtual void RenderFinishEventProc(bool cancelled){}
42
43 static void StaticRenderFinishEventProc(void* data, bool cancelled)
44 {
45 Callback* cb = (Callback*) data;
46 cb->RenderFinishEventProc(cancelled);
47 }
48
49 virtual void ErrorReportProc (const char* message) {}
50
51 static void StaticErrorReportProc (const char* message, void* data)
52 {
53 Callback* cb = (Callback*) data;
54 cb->ErrorReportProc(message);
55 }
56
57 virtual void CurrentPageProc(int current_page, int num_pages) {}
58
59 static void StaticCurrentPageProc(int current_page, int num_pages, void* data)
60 {
61 Callback* cb = (Callback*) data;
62 cb->CurrentPageProc(current_page, num_pages);
63 }
64
65 virtual void JavaScriptEventProc(const char* event_type, const char* json) {}
66
67 static void StaticJavaScriptEventProc(const char* event_type, const char* json, void* data)
68 {
69 Callback* cb= (Callback*) data;
70 cb->JavaScriptEventProc(event_type,json);
71 }
72
73 virtual void CurrentZoomProc(double curr_zoom_proc) {}
74
75 static void StaticCurrentZoomProc(double curr_zoom_proc, void* data)
76 {
77 Callback* cb = (Callback*) data;
78 cb->CurrentZoomProc(curr_zoom_proc);
79 }
80
81 virtual void ConnectionErrorProc(const char* message, const int error_code, UChar switch_to_demo) {}
82
83 static void StaticConnectionErrorProc(const char* message, const int error_code, UChar switch_to_demo, void* data)
84 {
85 Callback* cb = (Callback*)data;
86 cb->ConnectionErrorProc(message, error_code, switch_to_demo);
87 }
88
89 virtual void ThumbAsyncHandler(int page_num, bool was_thumb_found, const char* thumb_buf, int thumb_width, int thumb_height) {}
90
91 static void StaticThumbAsyncHandler(int page_num, bool was_thumb_found, const char* thumb_buf, int thumb_width, int thumb_height, void* custom_data)
92 {
93 Callback* cb = (Callback*) custom_data;
94 cb->ThumbAsyncHandler(page_num, was_thumb_found, thumb_buf, thumb_width, thumb_height);
95 }
96
97 virtual void RequestRenderInWorkerThread() {}
98
99 static void StaticRequestRenderInWorkerThread(void* custom_data)
100 {
101 Callback* cb = (Callback*) custom_data;
102 cb->RequestRenderInWorkerThread();
103 }
104
105 virtual void FindTextHandler(bool success, PDF::Selection selection) {}
106
107 static void StaticFindTextHandler(bool success, PDF::Selection selection, void* custom_data)
108 {
109 Callback* cb = (Callback*) custom_data;
110 cb->FindTextHandler(success, selection);
111 }
112
113 virtual void CreateTileProc(
114 char* buffer, int originX, int originY, int width, int height,
115 int pagNum, long long cellNumber,
116 bool finalRender, bool predictionRender,
117 int tilesRemaining, bool firstTile,
118 int canvasWidth, int canvasHeight, int cellSideLength, int cellPerRow, int cellPerCol,
119 int thumbnailId
120 ) { }
121
122 static void StaticCreateTileProc(
123 void* customData,
124 char* buffer, int originX, int originY, int width, int height,
125 int pageNum, long long cellNumber,
126 bool finalRender, bool predictionRender,
127 int tilesRemaining, bool firstTile,
128 int canvasWidth, int canvasHeight, int cellSideLength, int cellPerRow, int cellPerCol,
129 int thumbnailId
130 )
131 {
132 Callback* cb = (Callback*) customData;
133 cb->CreateTileProc(
134 buffer, originX, originY, width, height,
135 pageNum, cellNumber,
136 finalRender, predictionRender,
137 tilesRemaining, firstTile,
138 canvasWidth, canvasHeight, cellSideLength, cellPerRow, cellPerCol,
139 thumbnailId
140 );
141 }
142
143 virtual void AnnotBitmapProc(int operation_type,
144 char* buffer, UInt32 width, UInt32 height, UInt32 stride,
145 UInt32 page_num, UInt32 annot_index, const void* annot_key,
146 Int64 x_in_page, Int64 y_in_page, int x_offset, int y_offset,
147 int remaining_tiles, int sequence_number, Int64 x_page_size, Int64 y_page_size) {}
148
149 static void StaticAnnotBitmapProc(void* me, int operation_type,
150 char* buffer, UInt32 width, UInt32 height, UInt32 stride,
151 UInt32 page_num, UInt32 annot_index, const void* annot_key,
152 Int64 x_in_page, Int64 y_in_page, int x_offset, int y_offset,
153 int remaining_tiles, int sequence_number, Int64 x_page_size, Int64 y_page_size)
154 {
155 Callback* cb = (Callback*) me;
156 cb->AnnotBitmapProc(operation_type, buffer,
157 width, height, stride,
158 page_num, annot_index, annot_key,
159 x_in_page, y_in_page, x_offset, y_offset,
160 remaining_tiles, sequence_number, x_page_size, y_page_size);
161 }
162
163
164 /* deluxe start */
165
166 virtual void DeluxeCreateTileProc(
167 char* buffer, unsigned int width, unsigned int height, unsigned int stride,
168 unsigned int page_num, UInt64 x_page_loc, UInt64 y_page_loc,
169 unsigned int zoomed_page_width, unsigned int zoomed_page_height,
170 unsigned int tile_id, unsigned int x_in_page, unsigned int y_in_page,
171 int canvas_id, int remaining_tiles, int tile_type,
172 int sequence_number
173 ) { }
174
175 static void StaticDeluxeCreateTileProc(
176 void* me,
177 char* buffer, unsigned int width, unsigned int height, unsigned int stride,
178 unsigned int page_num, UInt64 x_page_loc, UInt64 y_page_loc,
179 unsigned int zoomed_page_width, unsigned int zoomed_page_height,
180 unsigned int tile_id, unsigned int x_in_page, unsigned int y_in_page,
181 int canvas_id, int remaining_tiles, int tile_type,
182 int sequence_number
183 )
184 {
185 Callback* cb = (Callback*) me;
186 cb->DeluxeCreateTileProc(
187 buffer, width, height, stride,
188 page_num, x_page_loc, y_page_loc,
189 zoomed_page_width, zoomed_page_height,
190 tile_id, x_in_page, y_in_page,
191 canvas_id, remaining_tiles, tile_type,
192 sequence_number
193 );
194 }
195
196 /* deluxe end */
197
198 virtual void RemoveTileProc(int canvasNumber, Int64 cellNumber, int thumbnailId, int sequenceNumber) { }
199
200 static void StaticRemoveTileProc(void* customData, int canvasNumber, Int64 cellNumber, int thumbnailId, int sequenceNumber)
201 {
202 Callback* cb = (Callback*) customData;
203 cb->RemoveTileProc(canvasNumber, cellNumber, thumbnailId, sequenceNumber);
204 }
205
206 virtual void PartDownloadedProc(int dlType, TRN_PDFDoc doc, unsigned int pageNum, unsigned int objNum, const char* message) { }
207
208 static void StaticPartDownloadedProc(int dlType, TRN_PDFDoc doc, unsigned int pageNum, unsigned int objNum, const char* message, void* customData)
209 {
210 Callback* cb = (Callback*) customData;
211 cb->PartDownloadedProc(dlType, doc, pageNum, objNum, message);
212 }
213 };
214
215 }; // namespace PDF
216 }; // namespace pdftron
217
218 #endif // SWIG
219
220 #endif // PDFTRON_H_CPPPDFCallback
Selection.h
pdftron::Int64
TRN_Int64 Int64
Definition: BasicTypes.h:20
pdftron::UInt64
TRN_UInt64 UInt64
Definition: BasicTypes.h:21
pdftron::UInt32
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
pdftron::UChar
TRN_UChar UChar
Definition: BasicTypes.h:12
BasicTypes.h