Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 364 lines (290 sloc) 7.951 kB
a45418e @c9s init import
authored
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4 #include "ppport.h"
5
6 #include "perl-poppler.h"
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
7
6de95ff @c9s outputdevdata structure.
authored
8
a45418e @c9s init import
authored
9 #include <poppler.h>
10 #include <poppler/glib/poppler.h>
11 #include <poppler/glib/poppler-page.h>
12
7c6c3dd @c9s bless poppler document to perl object
authored
13
dd44df9 @c9s - save poppler document handler in perl object
authored
14 #define FAIL(msg) \
15 do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
7c6c3dd @c9s bless poppler document to perl object
authored
16
17
dd44df9 @c9s - save poppler document handler in perl object
authored
18 typedef struct {
19 PopplerDocument *handle;
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
20 } hPopplerDocument;
7c6c3dd @c9s bless poppler document to perl object
authored
21
dd44df9 @c9s - save poppler document handler in perl object
authored
22 typedef struct {
23 PopplerPage *handle;
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
24 } hPopplerPage;
a45418e @c9s init import
authored
25
2e51a1b @c9s page dimension object for page get size function
authored
26 typedef struct {
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
27 PopplerAttachment *handle;
28 } hPopplerAttachment;
29
6de95ff @c9s outputdevdata structure.
authored
30 typedef struct {
31 unsigned char *cairo_data;
32 cairo_surface_t *surface;
33 cairo_t *cairo;
34 } OutputDevData;
87e246f @c9s poppler_attachment:save method
authored
35
36
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
37 typedef struct {
2e51a1b @c9s page dimension object for page get size function
authored
38 double w;
39 double h;
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
40 } hPageDimension;
2e51a1b @c9s page dimension object for page get size function
authored
41
dd44df9 @c9s - save poppler document handler in perl object
authored
42 MODULE = Poppler PACKAGE = Poppler::Document
43
72ea60c @c9s fix makefile
authored
44 BOOT:
45 g_type_init();
46
dd44df9 @c9s - save poppler document handler in perl object
authored
47 PROTOTYPES: ENABLE
48
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
49 hPopplerDocument*
dd44df9 @c9s - save poppler document handler in perl object
authored
50 new_from_file( class , filename )
51 char * class;
52 char * filename;
7c6c3dd @c9s bless poppler document to perl object
authored
53 PREINIT:
54 PopplerDocument *document;
a45418e @c9s init import
authored
55 CODE:
dd44df9 @c9s - save poppler document handler in perl object
authored
56 g_type_init();
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
57 Newz(0, RETVAL, 1, hPopplerDocument );
7c6c3dd @c9s bless poppler document to perl object
authored
58 document = poppler_document_new_from_file( filename , NULL , NULL );
dd44df9 @c9s - save poppler document handler in perl object
authored
59 if( document == NULL ) {
60 fprintf( stderr , filename );
61 FAIL("poppler_document_new_from_file fail"); // XXX: show path usage
62 }
63 RETVAL->handle = document;
a45418e @c9s init import
authored
64 OUTPUT:
65 RETVAL
66
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
67 int
68 hPopplerDocument::save( uri )
69 char * uri;
70 PREINIT:
71 gboolean ret;
72 GError **error;
73 CODE:
74 ret = poppler_document_save( THIS->handle , uri , error );
75 RETVAL = ( ret == TRUE ) ? 1 : 0;
76 OUTPUT:
77 RETVAL
78
79
6b86f4c @c9s - provide save_a_copy method
authored
80 int
81 hPopplerDocument::save_a_copy( uri )
82 char * uri;
83 PREINIT:
84 GError **error;
85 gboolean ret;
86 CODE:
87 ret = poppler_document_save_a_copy( THIS->handle , uri , error );
bb8e047 @c9s has_attachments method
authored
88 RETVAL = ( ret == TRUE ) ? 1 : 0; // XXX: should convert in typemap
6b86f4c @c9s - provide save_a_copy method
authored
89 OUTPUT:
90 RETVAL
91
61f68c1 @c9s provide get_page_by_label method
authored
92 int
93 hPopplerDocument::get_n_pages()
94 CODE:
95 RETVAL = poppler_document_get_n_pages( THIS->handle );
96 OUTPUT:
97 RETVAL
98
99
bb8e047 @c9s has_attachments method
authored
100 int
101 hPopplerDocument::has_attachments()
102 PREINIT:
103 gboolean ret;
104 CODE:
105 ret = poppler_document_has_attachments( THIS->handle );
106 RETVAL = ( ret == TRUE ) ? 1 : 0;
107 OUTPUT:
108 RETVAL
27c26d7 @c9s find_text , get_index, get_duration functions
authored
109
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
110
a937e78 @c9s get_attachements: return a list contains Poppler::Attachment.
authored
111 void
112 hPopplerDocument::get_attachments()
113 PREINIT:
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
114 GList* i;
115 GList* list;
a937e78 @c9s get_attachements: return a list contains Poppler::Attachment.
authored
116 PPCODE:
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
117 list = (GList*) poppler_document_get_attachments( THIS->handle );
a937e78 @c9s get_attachements: return a list contains Poppler::Attachment.
authored
118 for (i = list; i != NULL; i = i->next) {
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
119 SV * sv;
87e246f @c9s poppler_attachment:save method
authored
120 hPopplerDocument * pv;
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
121 Newz(0, pv, 1, hPopplerDocument );
122 sv_setref_pv( sv , "Poppler::Attachment" , (void*) pv );
123 XPUSHs ( sv_2mortal( sv ) );
a937e78 @c9s get_attachements: return a list contains Poppler::Attachment.
authored
124 }
125 g_list_free(list);
27c26d7 @c9s find_text , get_index, get_duration functions
authored
126
bb8e047 @c9s has_attachments method
authored
127
6b86f4c @c9s - provide save_a_copy method
authored
128
61f68c1 @c9s provide get_page_by_label method
authored
129 hPopplerPage*
130 hPopplerDocument::get_page_by_label( label );
131 char * label;
132 PREINIT:
133 PopplerPage* page;
134 CODE:
135 Newz(0, RETVAL, 1, hPopplerPage );
136 page = poppler_document_get_page_by_label( THIS->handle , label );
137 char* class = "Poppler::Page";
138 if( page == NULL )
139 FAIL( "get page failed." );
140 RETVAL->handle = page;
141 OUTPUT:
142 RETVAL
6b86f4c @c9s - provide save_a_copy method
authored
143
144
145
146
87e246f @c9s poppler_attachment:save method
authored
147
148
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
149 hPopplerPage*
150 hPopplerDocument::get_page( page_num );
dd44df9 @c9s - save poppler document handler in perl object
authored
151 int page_num;
152 PREINIT:
153 PopplerPage* page;
a45418e @c9s init import
authored
154 CODE:
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
155 Newz(0, RETVAL, 1, hPopplerPage );
dd44df9 @c9s - save poppler document handler in perl object
authored
156 page = poppler_document_get_page( THIS->handle , page_num );
157 char* class = "Poppler::Page"; // XXX: bad hack
43a9bcd @c9s fix poppler_page_render ports
authored
158 if( page == NULL )
6b86f4c @c9s - provide save_a_copy method
authored
159 FAIL( "get page failed." );
43a9bcd @c9s fix poppler_page_render ports
authored
160
dd44df9 @c9s - save poppler document handler in perl object
authored
161 RETVAL->handle = page;
a45418e @c9s init import
authored
162 OUTPUT:
163 RETVAL
164
dd44df9 @c9s - save poppler document handler in perl object
authored
165
61f68c1 @c9s provide get_page_by_label method
authored
166
167
168
169
170
171
2e51a1b @c9s page dimension object for page get size function
authored
172 MODULE = Poppler PACKAGE = Poppler::Page
7c6c3dd @c9s bless poppler document to perl object
authored
173
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
174 hPageDimension*
175 hPopplerPage::get_size();
dd44df9 @c9s - save poppler document handler in perl object
authored
176 PREINIT:
177 double doc_w;
178 double doc_h;
179 CODE:
2e51a1b @c9s page dimension object for page get size function
authored
180 poppler_page_get_size( THIS->handle , &doc_w , &doc_h );
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
181 Newz(0, RETVAL, 1, hPageDimension );
2e51a1b @c9s page dimension object for page get size function
authored
182 char * class = "Poppler::Page::Dimension";
183 RETVAL->w = doc_w;
184 RETVAL->h = doc_h;
185 OUTPUT:
186 RETVAL
187
188 void
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
189 hPopplerPage::render_to_cairo ( cr);
2e51a1b @c9s page dimension object for page get size function
authored
190 cairo_t *cr;
191 CODE:
43a9bcd @c9s fix poppler_page_render ports
authored
192 poppler_page_render( THIS->handle , cr );
2e51a1b @c9s page dimension object for page get size function
authored
193 OUTPUT:
194
1742444 @c9s implement render_to_cairo function. need test
authored
195
27c26d7 @c9s find_text , get_index, get_duration functions
authored
196 ##ifdef POPPLER_WITH_GDK
197 #void poppler_page_render_to_pixbuf (PopplerPage *page,
198 # int src_x,
199 # int src_y,
200 # int src_width,
201 # int src_height,
202 # double scale,
203 # int rotation,
204 # GdkPixbuf *pixbuf);
205 #void poppler_page_render_to_pixbuf_for_printing (PopplerPage *page,
206 # int src_x,
207 # int src_y,
208 # int src_width,
209 # int src_height,
210 # double scale,
211 # int rotation,
212 # GdkPixbuf *pixbuf);
213 #GdkPixbuf *poppler_page_get_thumbnail_pixbuf (PopplerPage *page);
214 #void poppler_page_render_selection_to_pixbuf (
215 # PopplerPage *page,
216 # gdouble scale,
217 # int rotation,
218 # GdkPixbuf *pixbuf,
219 # PopplerRectangle *selection,
220 # PopplerRectangle *old_selection,
221 # PopplerSelectionStyle style,
222 # GdkColor *glyph_color,
223 # GdkColor *background_color);
224 ##endif /* POPPLER_WITH_GDK */
225
226 # #ifdef POPPLER_HAS_CAIRO
227 # void poppler_page_render (PopplerPage *page,
228 # cairo_t *cairo);
229 # void poppler_page_render_for_printing (PopplerPage *page,
230 # cairo_t *cairo);
231 # cairo_surface_t *poppler_page_get_thumbnail (PopplerPage *page);
232 # void poppler_page_render_selection (PopplerPage *page,
233 # cairo_t *cairo,
234 # PopplerRectangle *selection,
235 # PopplerRectangle *old_selection,
236 # PopplerSelectionStyle style,
237 # PopplerColor *glyph_color,
238 # PopplerColor *background_color);
239 # #endif /* POPPLER_HAS_CAIRO */
240
241
242 int
243 hPopplerPage::get_index()
244 CODE:
245 RETVAL = poppler_page_get_index( THIS->handle );
246 OUTPUT:
247 RETVAL
248
249
250 double
251 hPopplerPage::get_duration()
252 CODE:
253 RETVAL = poppler_page_get_duration( THIS->handle );
254 OUTPUT:
255 RETVAL
256
257 int
258 hPopplerPage::find_text( text );
259 char *text;
260 PREINIT:
261 GList *list;
262 CODE:
263 list = poppler_page_find_text( THIS->handle, text );
264 // XXX: convert glist for perl
265 RETVAL = 1;
266 OUTPUT:
267 RETVAL
268
0c28c6d @c9s disable prepare_output_dev
authored
269 ## XXX: static function
270 ## OutputDevData*
271 ## hPopplerPage::prepare_output_dev( scale , rotation , _transparent ) ;
272 ## double scale;
273 ## int rotation;
274 ## int _transparent;
275 ## PREINIT:
276 ## OutputDevData *output_dev_data;
277 ## gboolean transparent;
278 ## CODE:
279 ## transparent = ( _transparent == 1 ? TRUE : FALSE );
280 ## char* class = "Poppler::OutputDevData";
281 ## poppler_page_prepare_output_dev(
282 ## THIS->handle,
283 ## rotation,
284 ## transparent,
285 ## output_dev_data
286 ## );
287 ## RETVAL = output_dev_data;
288 ## OUTPUT:
289 ## RETVAL
6de95ff @c9s outputdevdata structure.
authored
290
291
292 ## void
293 ## hPopplerPage::copy_to_pixbuf( output_dev_data )
294 ## OutputDevData *output_dev_data;
295 ## PREINIT:
296 ## GdkPixbuf * pixbuf;
297 ## CODE:
298 ## poppler_page_copy_to_pixbuf( THIS->handle , pixbuf , output_dev_data );
299 ## NO_OUPUT:
300
301
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
302 MODULE = Poppler PACKAGE = Poppler::Attachment
303
87e246f @c9s poppler_attachment:save method
authored
304 int
305 hPopplerAttachment::save( filename );
306 char * filename;
307 PREINIT:
308 GError **error;
309 gboolean ret;
310 CODE:
311 ret = poppler_attachment_save( THIS->handle , filename , error );
312 RETVAL = ( ret == TRUE ) ? 1 : 0;
313 OUTPUT:
314 RETVAL
d9b06cb @c9s return blessed poppler-attachment list from GList
authored
315
1742444 @c9s implement render_to_cairo function. need test
authored
316
3253a1b @c9s provide get_width/height method for page dimension
authored
317 MODULE = Poppler PACKAGE = Poppler::Page::Dimension
318
319 int
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
320 hPageDimension::get_width()
3253a1b @c9s provide get_width/height method for page dimension
authored
321 CODE:
322 RETVAL = THIS->w;
323 OUTPUT:
324 RETVAL
325
326 int
b7fd0e3 @c9s - change structure prefix "_" to "h"
authored
327 hPageDimension::get_height()
3253a1b @c9s provide get_width/height method for page dimension
authored
328 CODE:
329 RETVAL = THIS->h;
330 OUTPUT:
331 RETVAL
2e51a1b @c9s page dimension object for page get size function
authored
332
87e246f @c9s poppler_attachment:save method
authored
333
334
6de95ff @c9s outputdevdata structure.
authored
335 MODULE = Poppler PACKAGE = Poppler::OutputDevData
336
337 cairo_t*
338 OutputDevData::get_cairo_context()
339 CODE:
340 char * class = "Cairo::Context";
341 RETVAL = THIS->cairo;
342 OUTPUT:
343 RETVAL
344
345 cairo_surface_t*
346 OutputDevData::get_cairo_surface()
347 CODE:
348 char * class = "Cairo::Surface";
349 RETVAL = THIS->surface;
350 OUTPUT:
351 RETVAL
352
518d941 @c9s save cairo unsigned char in sv (scalar)
authored
353 SV*
6de95ff @c9s outputdevdata structure.
authored
354 OutputDevData::get_cairo_data()
355 CODE:
518d941 @c9s save cairo unsigned char in sv (scalar)
authored
356 RETVAL = (SV*) THIS->cairo_data;
6de95ff @c9s outputdevdata structure.
authored
357 OUTPUT:
358 RETVAL
359
360
87e246f @c9s poppler_attachment:save method
authored
361
dd44df9 @c9s - save poppler document handler in perl object
authored
362
363
Something went wrong with that request. Please try again.