page_print 0.1.1-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +247 -0
- data/ext/page_print/extconf.rb +48 -0
- data/ext/page_print/page_print.c +851 -0
- data/lib/page_print/page_print.so +0 -0
- data/lib/page_print/rails_resource_fetcher.rb +138 -0
- data/lib/page_print/railtie.rb +15 -0
- data/lib/page_print/vendor/x86_64-linux/include/plutobook/plutobook.h +1101 -0
- data/lib/page_print/vendor/x86_64-linux/include/plutobook/plutobook.hpp +1361 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libX11.so.6 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libXau.so.6 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libXdmcp.so.6 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libXext.so.6 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libXrender.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libbrotlicommon.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libbrotlidec.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libbsd.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libbz2.so.1.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libcairo.so.2 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libcrypt.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libexpat.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libfontconfig.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libfreetype.so.6 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libglib-2.0.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libgmp.so.10 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libgraphite2.so.3 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libharfbuzz.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libicudata.so.74 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libicui18n.so.74 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libicuuc.so.74 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libmd.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libpcre2-8.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libpixman-1.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libplutobook.so +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libplutobook.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libplutobook.so.0.17.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libpng16.so.16 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libruby.so.3.4 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libxcb-render.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libxcb-shm.so.0 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libxcb.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/libz.so.1 +0 -0
- data/lib/page_print/vendor/x86_64-linux/lib/pkgconfig/plutobook.pc +10 -0
- data/lib/page_print/version.rb +3 -0
- data/lib/page_print.rb +28 -0
- metadata +89 -0
|
@@ -0,0 +1,851 @@
|
|
|
1
|
+
#include "ruby.h"
|
|
2
|
+
#include "ruby/encoding.h"
|
|
3
|
+
#include "ruby/thread.h"
|
|
4
|
+
#include <limits.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
#include <plutobook/plutobook.h>
|
|
7
|
+
|
|
8
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
9
|
+
#define PAGEPRINT_NORETURN __attribute__((noreturn))
|
|
10
|
+
#else
|
|
11
|
+
#define PAGEPRINT_NORETURN
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
static VALUE mPagePrint;
|
|
15
|
+
static ID id_base_url;
|
|
16
|
+
static ID id_page_size;
|
|
17
|
+
static ID id_margins;
|
|
18
|
+
static ID id_media;
|
|
19
|
+
static ID id_resource_fetcher;
|
|
20
|
+
static ID id_metadata;
|
|
21
|
+
static ID id_width;
|
|
22
|
+
static ID id_height;
|
|
23
|
+
static ID id_unit;
|
|
24
|
+
static ID id_top;
|
|
25
|
+
static ID id_right;
|
|
26
|
+
static ID id_bottom;
|
|
27
|
+
static ID id_left;
|
|
28
|
+
static ID id_resource_fetcher_ivar;
|
|
29
|
+
static ID id_base_url_method;
|
|
30
|
+
static ID id_call;
|
|
31
|
+
static ID id_content;
|
|
32
|
+
static ID id_mime_type;
|
|
33
|
+
static ID id_text_encoding;
|
|
34
|
+
static ID id_title;
|
|
35
|
+
static ID id_author;
|
|
36
|
+
static ID id_subject;
|
|
37
|
+
static ID id_keywords;
|
|
38
|
+
static ID id_creation_date;
|
|
39
|
+
static ID id_modification_date;
|
|
40
|
+
static ID id_pt;
|
|
41
|
+
static ID id_pc;
|
|
42
|
+
static ID id_in;
|
|
43
|
+
static ID id_cm;
|
|
44
|
+
static ID id_mm;
|
|
45
|
+
static ID id_px;
|
|
46
|
+
|
|
47
|
+
typedef struct {
|
|
48
|
+
plutobook_page_size_t page_size;
|
|
49
|
+
plutobook_page_margins_t margins;
|
|
50
|
+
plutobook_media_type_t media;
|
|
51
|
+
const char *base_url;
|
|
52
|
+
VALUE resource_fetcher;
|
|
53
|
+
VALUE metadata;
|
|
54
|
+
} pageprint_options_t;
|
|
55
|
+
|
|
56
|
+
typedef struct {
|
|
57
|
+
VALUE object;
|
|
58
|
+
int state;
|
|
59
|
+
} pageprint_resource_fetcher_t;
|
|
60
|
+
|
|
61
|
+
typedef struct {
|
|
62
|
+
pageprint_resource_fetcher_t *fetcher;
|
|
63
|
+
const char *url;
|
|
64
|
+
plutobook_resource_data_t *resource;
|
|
65
|
+
} pageprint_resource_fetch_args_t;
|
|
66
|
+
|
|
67
|
+
typedef struct {
|
|
68
|
+
VALUE output;
|
|
69
|
+
int state;
|
|
70
|
+
} pageprint_pdf_string_output_t;
|
|
71
|
+
|
|
72
|
+
typedef struct {
|
|
73
|
+
VALUE output;
|
|
74
|
+
const char *data;
|
|
75
|
+
unsigned int length;
|
|
76
|
+
} pageprint_pdf_string_append_t;
|
|
77
|
+
|
|
78
|
+
typedef struct {
|
|
79
|
+
plutobook_t *book;
|
|
80
|
+
const char *html;
|
|
81
|
+
int length;
|
|
82
|
+
const char *user_style;
|
|
83
|
+
const char *user_script;
|
|
84
|
+
const char *base_url;
|
|
85
|
+
int ok;
|
|
86
|
+
} pageprint_load_html_args_t;
|
|
87
|
+
|
|
88
|
+
typedef struct {
|
|
89
|
+
plutobook_t *book;
|
|
90
|
+
const char *path;
|
|
91
|
+
int ok;
|
|
92
|
+
} pageprint_write_pdf_args_t;
|
|
93
|
+
|
|
94
|
+
typedef struct {
|
|
95
|
+
plutobook_t *book;
|
|
96
|
+
pageprint_pdf_string_output_t *output;
|
|
97
|
+
int ok;
|
|
98
|
+
} pageprint_write_pdf_stream_args_t;
|
|
99
|
+
|
|
100
|
+
static VALUE pageprint_append_pdf_string(VALUE value);
|
|
101
|
+
static plutobook_stream_status_t pageprint_write_pdf_string(void *closure, const char *data, unsigned int length);
|
|
102
|
+
static plutobook_resource_data_t *pageprint_fetch_resource(void *closure, const char *url);
|
|
103
|
+
|
|
104
|
+
static void PAGEPRINT_NORETURN pageprint_raise_plutobook_error(VALUE error_class, const char *message)
|
|
105
|
+
{
|
|
106
|
+
const char *error_message = plutobook_get_error_message();
|
|
107
|
+
|
|
108
|
+
if (error_message && error_message[0] != '\0') {
|
|
109
|
+
rb_raise(error_class, "%s: %s", message, error_message);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
rb_raise(error_class, "%s", message);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static void PAGEPRINT_NORETURN pageprint_raise_plutobook_error_with_path(VALUE error_class, const char *message, const char *path)
|
|
116
|
+
{
|
|
117
|
+
const char *error_message = plutobook_get_error_message();
|
|
118
|
+
|
|
119
|
+
if (error_message && error_message[0] != '\0') {
|
|
120
|
+
rb_raise(error_class, "%s %s: %s", message, path, error_message);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
rb_raise(error_class, "%s %s", message, path);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static double pageprint_unit_factor_from_value(VALUE value, const char *name)
|
|
127
|
+
{
|
|
128
|
+
ID value_id;
|
|
129
|
+
|
|
130
|
+
if (!RB_SYMBOL_P(value)) {
|
|
131
|
+
rb_raise(rb_eTypeError, "%s must be a Symbol", name);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
value_id = SYM2ID(value);
|
|
135
|
+
|
|
136
|
+
if (value_id == id_pt) return PLUTOBOOK_UNITS_PT;
|
|
137
|
+
if (value_id == id_pc) return PLUTOBOOK_UNITS_PC;
|
|
138
|
+
if (value_id == id_in) return PLUTOBOOK_UNITS_IN;
|
|
139
|
+
if (value_id == id_cm) return PLUTOBOOK_UNITS_CM;
|
|
140
|
+
if (value_id == id_mm) return PLUTOBOOK_UNITS_MM;
|
|
141
|
+
if (value_id == id_px) return PLUTOBOOK_UNITS_PX;
|
|
142
|
+
|
|
143
|
+
rb_raise(rb_eArgError, "%s must be one of: :pt, :pc, :in, :cm, :mm, :px", name);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static plutobook_page_size_t pageprint_page_size_from_value(VALUE value)
|
|
147
|
+
{
|
|
148
|
+
ID value_id;
|
|
149
|
+
|
|
150
|
+
if (RB_TYPE_P(value, T_HASH)) {
|
|
151
|
+
VALUE width = rb_hash_aref(value, ID2SYM(id_width));
|
|
152
|
+
VALUE height = rb_hash_aref(value, ID2SYM(id_height));
|
|
153
|
+
VALUE unit = rb_hash_aref(value, ID2SYM(id_unit));
|
|
154
|
+
double width_number;
|
|
155
|
+
double height_number;
|
|
156
|
+
double factor;
|
|
157
|
+
|
|
158
|
+
if (NIL_P(width)) {
|
|
159
|
+
rb_raise(rb_eArgError, "page_size requires :width");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (NIL_P(height)) {
|
|
163
|
+
rb_raise(rb_eArgError, "page_size requires :height");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (NIL_P(unit)) {
|
|
167
|
+
rb_raise(rb_eArgError, "page_size requires :unit");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
width_number = NUM2DBL(width);
|
|
171
|
+
height_number = NUM2DBL(height);
|
|
172
|
+
|
|
173
|
+
if (width_number <= 0) {
|
|
174
|
+
rb_raise(rb_eArgError, "page_size width must be greater than 0");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (height_number <= 0) {
|
|
178
|
+
rb_raise(rb_eArgError, "page_size height must be greater than 0");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
factor = pageprint_unit_factor_from_value(unit, "page_size unit");
|
|
182
|
+
|
|
183
|
+
return PLUTOBOOK_MAKE_PAGE_SIZE((float)(width_number * factor), (float)(height_number * factor));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (!RB_SYMBOL_P(value)) {
|
|
187
|
+
rb_raise(rb_eTypeError, "page_size must be a Symbol or Hash");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
value_id = SYM2ID(value);
|
|
191
|
+
|
|
192
|
+
if (value_id == rb_intern("a3")) return PLUTOBOOK_PAGE_SIZE_A3;
|
|
193
|
+
if (value_id == rb_intern("a4")) return PLUTOBOOK_PAGE_SIZE_A4;
|
|
194
|
+
if (value_id == rb_intern("a5")) return PLUTOBOOK_PAGE_SIZE_A5;
|
|
195
|
+
if (value_id == rb_intern("b4")) return PLUTOBOOK_PAGE_SIZE_B4;
|
|
196
|
+
if (value_id == rb_intern("b5")) return PLUTOBOOK_PAGE_SIZE_B5;
|
|
197
|
+
if (value_id == rb_intern("letter")) return PLUTOBOOK_PAGE_SIZE_LETTER;
|
|
198
|
+
if (value_id == rb_intern("legal")) return PLUTOBOOK_PAGE_SIZE_LEGAL;
|
|
199
|
+
if (value_id == rb_intern("ledger")) return PLUTOBOOK_PAGE_SIZE_LEDGER;
|
|
200
|
+
|
|
201
|
+
rb_raise(rb_eArgError, "page_size must be one of: :a3, :a4, :a5, :b4, :b5, :letter, :legal, :ledger");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
static plutobook_page_margins_t pageprint_margins_from_value(VALUE value)
|
|
205
|
+
{
|
|
206
|
+
ID value_id;
|
|
207
|
+
|
|
208
|
+
if (RB_TYPE_P(value, T_HASH)) {
|
|
209
|
+
VALUE top = rb_hash_aref(value, ID2SYM(id_top));
|
|
210
|
+
VALUE right = rb_hash_aref(value, ID2SYM(id_right));
|
|
211
|
+
VALUE bottom = rb_hash_aref(value, ID2SYM(id_bottom));
|
|
212
|
+
VALUE left = rb_hash_aref(value, ID2SYM(id_left));
|
|
213
|
+
VALUE unit = rb_hash_aref(value, ID2SYM(id_unit));
|
|
214
|
+
double top_number;
|
|
215
|
+
double right_number;
|
|
216
|
+
double bottom_number;
|
|
217
|
+
double left_number;
|
|
218
|
+
double factor;
|
|
219
|
+
|
|
220
|
+
if (NIL_P(top)) {
|
|
221
|
+
rb_raise(rb_eArgError, "margins requires :top");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (NIL_P(right)) {
|
|
225
|
+
rb_raise(rb_eArgError, "margins requires :right");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (NIL_P(bottom)) {
|
|
229
|
+
rb_raise(rb_eArgError, "margins requires :bottom");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (NIL_P(left)) {
|
|
233
|
+
rb_raise(rb_eArgError, "margins requires :left");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (NIL_P(unit)) {
|
|
237
|
+
rb_raise(rb_eArgError, "margins requires :unit");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
top_number = NUM2DBL(top);
|
|
241
|
+
right_number = NUM2DBL(right);
|
|
242
|
+
bottom_number = NUM2DBL(bottom);
|
|
243
|
+
left_number = NUM2DBL(left);
|
|
244
|
+
|
|
245
|
+
if (top_number < 0 || right_number < 0 || bottom_number < 0 || left_number < 0) {
|
|
246
|
+
rb_raise(rb_eArgError, "margins values must be greater than or equal to 0");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
factor = pageprint_unit_factor_from_value(unit, "margins unit");
|
|
250
|
+
|
|
251
|
+
return PLUTOBOOK_MAKE_PAGE_MARGINS(
|
|
252
|
+
(float)(top_number * factor),
|
|
253
|
+
(float)(right_number * factor),
|
|
254
|
+
(float)(bottom_number * factor),
|
|
255
|
+
(float)(left_number * factor)
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (!RB_SYMBOL_P(value)) {
|
|
260
|
+
rb_raise(rb_eTypeError, "margins must be a Symbol or Hash");
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
value_id = SYM2ID(value);
|
|
264
|
+
|
|
265
|
+
if (value_id == rb_intern("none")) return PLUTOBOOK_PAGE_MARGINS_NONE;
|
|
266
|
+
if (value_id == rb_intern("normal")) return PLUTOBOOK_PAGE_MARGINS_NORMAL;
|
|
267
|
+
if (value_id == rb_intern("narrow")) return PLUTOBOOK_PAGE_MARGINS_NARROW;
|
|
268
|
+
if (value_id == rb_intern("moderate")) return PLUTOBOOK_PAGE_MARGINS_MODERATE;
|
|
269
|
+
if (value_id == rb_intern("wide")) return PLUTOBOOK_PAGE_MARGINS_WIDE;
|
|
270
|
+
|
|
271
|
+
rb_raise(rb_eArgError, "margins must be one of: :none, :normal, :narrow, :moderate, :wide");
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
static plutobook_media_type_t pageprint_media_from_value(VALUE value)
|
|
275
|
+
{
|
|
276
|
+
ID value_id;
|
|
277
|
+
|
|
278
|
+
if (!RB_SYMBOL_P(value)) {
|
|
279
|
+
rb_raise(rb_eTypeError, "media must be a Symbol");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
value_id = SYM2ID(value);
|
|
283
|
+
|
|
284
|
+
if (value_id == rb_intern("print")) return PLUTOBOOK_MEDIA_TYPE_PRINT;
|
|
285
|
+
if (value_id == rb_intern("screen")) return PLUTOBOOK_MEDIA_TYPE_SCREEN;
|
|
286
|
+
|
|
287
|
+
rb_raise(rb_eArgError, "media must be one of: :print, :screen");
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
static int pageprint_metadata_id_known(ID key_id)
|
|
291
|
+
{
|
|
292
|
+
return key_id == id_title ||
|
|
293
|
+
key_id == id_author ||
|
|
294
|
+
key_id == id_subject ||
|
|
295
|
+
key_id == id_keywords ||
|
|
296
|
+
key_id == id_creation_date ||
|
|
297
|
+
key_id == id_modification_date;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
static void pageprint_validate_metadata_key(VALUE key)
|
|
301
|
+
{
|
|
302
|
+
ID key_id;
|
|
303
|
+
|
|
304
|
+
if (!RB_SYMBOL_P(key)) {
|
|
305
|
+
rb_raise(rb_eTypeError, "metadata keys must be Symbols");
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
key_id = SYM2ID(key);
|
|
309
|
+
|
|
310
|
+
if (!pageprint_metadata_id_known(key_id)) {
|
|
311
|
+
rb_raise(rb_eArgError, "metadata contains unknown key: :%s", rb_id2name(key_id));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static void pageprint_validate_metadata(VALUE metadata)
|
|
316
|
+
{
|
|
317
|
+
VALUE keys;
|
|
318
|
+
long i;
|
|
319
|
+
|
|
320
|
+
if (NIL_P(metadata)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (!RB_TYPE_P(metadata, T_HASH)) {
|
|
325
|
+
rb_raise(rb_eTypeError, "metadata must be a Hash or nil");
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
keys = rb_funcall(metadata, rb_intern("keys"), 0);
|
|
329
|
+
|
|
330
|
+
for (i = 0; i < RARRAY_LEN(keys); i++) {
|
|
331
|
+
VALUE key = rb_ary_entry(keys, i);
|
|
332
|
+
VALUE value;
|
|
333
|
+
|
|
334
|
+
pageprint_validate_metadata_key(key);
|
|
335
|
+
|
|
336
|
+
value = rb_hash_aref(metadata, key);
|
|
337
|
+
|
|
338
|
+
if (!NIL_P(value) && !RB_TYPE_P(value, T_STRING)) {
|
|
339
|
+
rb_raise(rb_eTypeError, "metadata values must be Strings or nil");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
static void pageprint_set_metadata_value(plutobook_t *book, VALUE metadata, ID key_id, plutobook_pdf_metadata_t metadata_key)
|
|
345
|
+
{
|
|
346
|
+
VALUE value;
|
|
347
|
+
|
|
348
|
+
value = rb_hash_aref(metadata, ID2SYM(key_id));
|
|
349
|
+
|
|
350
|
+
if (NIL_P(value)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
plutobook_set_metadata(book, metadata_key, StringValueCStr(value));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
static void pageprint_apply_metadata(plutobook_t *book, VALUE metadata)
|
|
358
|
+
{
|
|
359
|
+
if (NIL_P(metadata)) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
pageprint_set_metadata_value(book, metadata, id_title, PLUTOBOOK_PDF_METADATA_TITLE);
|
|
364
|
+
pageprint_set_metadata_value(book, metadata, id_author, PLUTOBOOK_PDF_METADATA_AUTHOR);
|
|
365
|
+
pageprint_set_metadata_value(book, metadata, id_subject, PLUTOBOOK_PDF_METADATA_SUBJECT);
|
|
366
|
+
pageprint_set_metadata_value(book, metadata, id_keywords, PLUTOBOOK_PDF_METADATA_KEYWORDS);
|
|
367
|
+
pageprint_set_metadata_value(book, metadata, id_creation_date, PLUTOBOOK_PDF_METADATA_CREATION_DATE);
|
|
368
|
+
pageprint_set_metadata_value(book, metadata, id_modification_date, PLUTOBOOK_PDF_METADATA_MODIFICATION_DATE);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static void *pageprint_load_html_without_gvl(void *ptr)
|
|
372
|
+
{
|
|
373
|
+
pageprint_load_html_args_t *args = ptr;
|
|
374
|
+
|
|
375
|
+
args->ok = plutobook_load_html(
|
|
376
|
+
args->book,
|
|
377
|
+
args->html,
|
|
378
|
+
args->length,
|
|
379
|
+
args->user_style,
|
|
380
|
+
args->user_script,
|
|
381
|
+
args->base_url
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
return NULL;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
static void *pageprint_write_pdf_without_gvl(void *ptr)
|
|
388
|
+
{
|
|
389
|
+
pageprint_write_pdf_args_t *args = ptr;
|
|
390
|
+
|
|
391
|
+
args->ok = plutobook_write_to_pdf(args->book, args->path);
|
|
392
|
+
|
|
393
|
+
return NULL;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
static void *pageprint_append_pdf_string_with_gvl(void *ptr)
|
|
397
|
+
{
|
|
398
|
+
pageprint_pdf_string_append_t *append = ptr;
|
|
399
|
+
int state = 0;
|
|
400
|
+
|
|
401
|
+
rb_protect(pageprint_append_pdf_string, (VALUE)append, &state);
|
|
402
|
+
|
|
403
|
+
return (void *)(intptr_t)state;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
static void *pageprint_write_pdf_stream_without_gvl(void *ptr)
|
|
407
|
+
{
|
|
408
|
+
pageprint_write_pdf_stream_args_t *args = ptr;
|
|
409
|
+
|
|
410
|
+
args->ok = plutobook_write_to_pdf_stream(args->book, pageprint_write_pdf_string, args->output);
|
|
411
|
+
|
|
412
|
+
return NULL;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
static VALUE pageprint_call_resource_fetcher(VALUE value)
|
|
416
|
+
{
|
|
417
|
+
pageprint_resource_fetch_args_t *args = (pageprint_resource_fetch_args_t *)value;
|
|
418
|
+
VALUE url;
|
|
419
|
+
VALUE result;
|
|
420
|
+
VALUE content;
|
|
421
|
+
VALUE mime_type;
|
|
422
|
+
VALUE text_encoding;
|
|
423
|
+
const char *text_encoding_str = "";
|
|
424
|
+
|
|
425
|
+
url = rb_str_new_cstr(args->url);
|
|
426
|
+
result = rb_funcall(args->fetcher->object, id_call, 1, url);
|
|
427
|
+
|
|
428
|
+
if (NIL_P(result)) {
|
|
429
|
+
return Qnil;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (!RB_TYPE_P(result, T_HASH)) {
|
|
433
|
+
rb_raise(rb_eTypeError, "resource_fetcher must return a Hash or nil");
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
content = rb_hash_aref(result, ID2SYM(id_content));
|
|
437
|
+
mime_type = rb_hash_aref(result, ID2SYM(id_mime_type));
|
|
438
|
+
text_encoding = rb_hash_aref(result, ID2SYM(id_text_encoding));
|
|
439
|
+
|
|
440
|
+
if (!RB_TYPE_P(content, T_STRING)) {
|
|
441
|
+
rb_raise(rb_eTypeError, "resource_fetcher result content must be a String");
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (!RB_TYPE_P(mime_type, T_STRING)) {
|
|
445
|
+
rb_raise(rb_eTypeError, "resource_fetcher result mime_type must be a String");
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (!NIL_P(text_encoding)) {
|
|
449
|
+
if (!RB_TYPE_P(text_encoding, T_STRING)) {
|
|
450
|
+
rb_raise(rb_eTypeError, "resource_fetcher result text_encoding must be a String or nil");
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
text_encoding_str = StringValueCStr(text_encoding);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (RSTRING_LEN(content) > UINT_MAX) {
|
|
457
|
+
rb_raise(rb_eArgError, "resource_fetcher result content is too large");
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
args->resource = plutobook_resource_data_create(
|
|
461
|
+
RSTRING_PTR(content),
|
|
462
|
+
(unsigned int)RSTRING_LEN(content),
|
|
463
|
+
StringValueCStr(mime_type),
|
|
464
|
+
text_encoding_str
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
if (!args->resource) {
|
|
468
|
+
pageprint_raise_plutobook_error(rb_eRuntimeError, "failed to create resource data");
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return Qnil;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
static void *pageprint_call_resource_fetcher_with_gvl(void *ptr)
|
|
475
|
+
{
|
|
476
|
+
pageprint_resource_fetch_args_t *args = ptr;
|
|
477
|
+
int state = 0;
|
|
478
|
+
|
|
479
|
+
rb_protect(pageprint_call_resource_fetcher, (VALUE)args, &state);
|
|
480
|
+
|
|
481
|
+
return (void *)(intptr_t)state;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
static plutobook_resource_data_t *pageprint_fetch_resource(void *closure, const char *url)
|
|
485
|
+
{
|
|
486
|
+
pageprint_resource_fetcher_t *fetcher = closure;
|
|
487
|
+
pageprint_resource_fetch_args_t args;
|
|
488
|
+
int state;
|
|
489
|
+
|
|
490
|
+
args.fetcher = fetcher;
|
|
491
|
+
args.url = url;
|
|
492
|
+
args.resource = NULL;
|
|
493
|
+
|
|
494
|
+
state = (int)(intptr_t)rb_thread_call_with_gvl(pageprint_call_resource_fetcher_with_gvl, &args);
|
|
495
|
+
|
|
496
|
+
if (state) {
|
|
497
|
+
fetcher->state = state;
|
|
498
|
+
plutobook_set_error_message("failed to fetch URL '%s'", url);
|
|
499
|
+
return NULL;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (args.resource) {
|
|
503
|
+
return args.resource;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return plutobook_fetch_url(url);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
static pageprint_options_t pageprint_options_from_value(VALUE options)
|
|
510
|
+
{
|
|
511
|
+
pageprint_options_t result;
|
|
512
|
+
VALUE base_url_value;
|
|
513
|
+
VALUE page_size_value;
|
|
514
|
+
VALUE margins_value;
|
|
515
|
+
VALUE media_value;
|
|
516
|
+
VALUE resource_fetcher_value;
|
|
517
|
+
VALUE metadata_value;
|
|
518
|
+
VALUE keyword_values[6];
|
|
519
|
+
ID keyword_ids[6];
|
|
520
|
+
|
|
521
|
+
result.page_size = PLUTOBOOK_PAGE_SIZE_A4;
|
|
522
|
+
result.margins = PLUTOBOOK_PAGE_MARGINS_NORMAL;
|
|
523
|
+
result.media = PLUTOBOOK_MEDIA_TYPE_PRINT;
|
|
524
|
+
result.base_url = "";
|
|
525
|
+
result.resource_fetcher = Qnil;
|
|
526
|
+
result.metadata = Qnil;
|
|
527
|
+
|
|
528
|
+
if (NIL_P(options)) {
|
|
529
|
+
options = rb_hash_new();
|
|
530
|
+
} else if (!RB_TYPE_P(options, T_HASH)) {
|
|
531
|
+
rb_raise(rb_eTypeError, "options must be a Hash");
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
keyword_ids[0] = id_base_url;
|
|
535
|
+
keyword_ids[1] = id_page_size;
|
|
536
|
+
keyword_ids[2] = id_margins;
|
|
537
|
+
keyword_ids[3] = id_media;
|
|
538
|
+
keyword_ids[4] = id_resource_fetcher;
|
|
539
|
+
keyword_ids[5] = id_metadata;
|
|
540
|
+
|
|
541
|
+
rb_get_kwargs(options, keyword_ids, 0, 6, keyword_values);
|
|
542
|
+
|
|
543
|
+
base_url_value = keyword_values[0];
|
|
544
|
+
page_size_value = keyword_values[1];
|
|
545
|
+
margins_value = keyword_values[2];
|
|
546
|
+
media_value = keyword_values[3];
|
|
547
|
+
resource_fetcher_value = keyword_values[4];
|
|
548
|
+
metadata_value = keyword_values[5];
|
|
549
|
+
|
|
550
|
+
if (base_url_value == Qundef) {
|
|
551
|
+
base_url_value = rb_funcall(mPagePrint, id_base_url_method, 0);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (!NIL_P(base_url_value)) {
|
|
555
|
+
if (!RB_TYPE_P(base_url_value, T_STRING)) {
|
|
556
|
+
rb_raise(rb_eTypeError, "base_url must be a String or nil");
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
result.base_url = StringValueCStr(base_url_value);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if (page_size_value != Qundef) {
|
|
563
|
+
result.page_size = pageprint_page_size_from_value(page_size_value);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (margins_value != Qundef) {
|
|
567
|
+
result.margins = pageprint_margins_from_value(margins_value);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (media_value != Qundef) {
|
|
571
|
+
result.media = pageprint_media_from_value(media_value);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if (resource_fetcher_value == Qundef) {
|
|
575
|
+
resource_fetcher_value = rb_ivar_get(mPagePrint, id_resource_fetcher_ivar);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (!NIL_P(resource_fetcher_value) && resource_fetcher_value != Qfalse) {
|
|
579
|
+
if (!rb_respond_to(resource_fetcher_value, id_call)) {
|
|
580
|
+
rb_raise(rb_eTypeError, "resource_fetcher must respond to call or be nil/false");
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
result.resource_fetcher = resource_fetcher_value;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (metadata_value != Qundef) {
|
|
587
|
+
pageprint_validate_metadata(metadata_value);
|
|
588
|
+
result.metadata = metadata_value;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
static plutobook_t *pageprint_create_book_from_html(VALUE html, VALUE options, pageprint_resource_fetcher_t *resource_fetcher)
|
|
595
|
+
{
|
|
596
|
+
pageprint_options_t pageprint_options;
|
|
597
|
+
|
|
598
|
+
const char *html_str;
|
|
599
|
+
long html_len;
|
|
600
|
+
|
|
601
|
+
plutobook_t *book;
|
|
602
|
+
pageprint_load_html_args_t load_args;
|
|
603
|
+
|
|
604
|
+
if (!RB_TYPE_P(html, T_STRING)) {
|
|
605
|
+
rb_raise(rb_eTypeError, "html must be a String");
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (RSTRING_LEN(html) == 0) {
|
|
609
|
+
rb_raise(rb_eArgError, "html must not be empty");
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
if (RSTRING_LEN(html) > INT_MAX) {
|
|
613
|
+
rb_raise(rb_eArgError, "html is too large");
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
pageprint_options = pageprint_options_from_value(options);
|
|
617
|
+
|
|
618
|
+
html_str = RSTRING_PTR(html);
|
|
619
|
+
html_len = RSTRING_LEN(html);
|
|
620
|
+
|
|
621
|
+
/* 1. Create */
|
|
622
|
+
book = plutobook_create(pageprint_options.page_size, pageprint_options.margins, pageprint_options.media);
|
|
623
|
+
|
|
624
|
+
if (!book) {
|
|
625
|
+
rb_raise(rb_eRuntimeError, "failed to create plutobook");
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
resource_fetcher->object = pageprint_options.resource_fetcher;
|
|
629
|
+
resource_fetcher->state = 0;
|
|
630
|
+
|
|
631
|
+
if (!NIL_P(resource_fetcher->object)) {
|
|
632
|
+
plutobook_set_custom_resource_fetcher(book, pageprint_fetch_resource, resource_fetcher);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/* 2. Load HTML */
|
|
636
|
+
plutobook_clear_error_message();
|
|
637
|
+
|
|
638
|
+
load_args.book = book;
|
|
639
|
+
load_args.html = html_str;
|
|
640
|
+
load_args.length = (int)html_len;
|
|
641
|
+
load_args.user_style = "";
|
|
642
|
+
load_args.user_script = "";
|
|
643
|
+
load_args.base_url = pageprint_options.base_url;
|
|
644
|
+
load_args.ok = 0;
|
|
645
|
+
|
|
646
|
+
rb_thread_call_without_gvl(
|
|
647
|
+
pageprint_load_html_without_gvl,
|
|
648
|
+
&load_args,
|
|
649
|
+
RUBY_UBF_IO,
|
|
650
|
+
NULL
|
|
651
|
+
);
|
|
652
|
+
|
|
653
|
+
if (!load_args.ok) {
|
|
654
|
+
plutobook_destroy(book);
|
|
655
|
+
|
|
656
|
+
if (resource_fetcher->state) {
|
|
657
|
+
rb_jump_tag(resource_fetcher->state);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
pageprint_raise_plutobook_error(rb_eRuntimeError, "failed to load HTML into plutobook");
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (resource_fetcher->state) {
|
|
664
|
+
plutobook_destroy(book);
|
|
665
|
+
rb_jump_tag(resource_fetcher->state);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
pageprint_apply_metadata(book, pageprint_options.metadata);
|
|
669
|
+
|
|
670
|
+
return book;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
static VALUE pageprint_append_pdf_string(VALUE value)
|
|
674
|
+
{
|
|
675
|
+
pageprint_pdf_string_append_t *append = (pageprint_pdf_string_append_t *)value;
|
|
676
|
+
|
|
677
|
+
rb_str_cat(append->output, append->data, append->length);
|
|
678
|
+
|
|
679
|
+
return Qnil;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
static plutobook_stream_status_t pageprint_write_pdf_string(void *closure, const char *data, unsigned int length)
|
|
683
|
+
{
|
|
684
|
+
pageprint_pdf_string_output_t *output = closure;
|
|
685
|
+
pageprint_pdf_string_append_t append;
|
|
686
|
+
int state;
|
|
687
|
+
|
|
688
|
+
append.output = output->output;
|
|
689
|
+
append.data = data;
|
|
690
|
+
append.length = length;
|
|
691
|
+
|
|
692
|
+
state = (int)(intptr_t)rb_thread_call_with_gvl(pageprint_append_pdf_string_with_gvl, &append);
|
|
693
|
+
|
|
694
|
+
if (state) {
|
|
695
|
+
output->state = state;
|
|
696
|
+
return PLUTOBOOK_STREAM_STATUS_WRITE_ERROR;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return PLUTOBOOK_STREAM_STATUS_SUCCESS;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
static VALUE pageprint_html_to_pdf(int argc, VALUE *argv, VALUE self) {
|
|
703
|
+
VALUE html;
|
|
704
|
+
VALUE path;
|
|
705
|
+
VALUE options;
|
|
706
|
+
|
|
707
|
+
const char *path_str;
|
|
708
|
+
|
|
709
|
+
plutobook_t *book;
|
|
710
|
+
pageprint_resource_fetcher_t resource_fetcher;
|
|
711
|
+
pageprint_write_pdf_args_t write_args;
|
|
712
|
+
|
|
713
|
+
rb_check_arity(argc, 2, 3);
|
|
714
|
+
|
|
715
|
+
html = argv[0];
|
|
716
|
+
path = argv[1];
|
|
717
|
+
options = argc == 3 ? argv[2] : Qnil;
|
|
718
|
+
|
|
719
|
+
if (!RB_TYPE_P(path, T_STRING)) {
|
|
720
|
+
rb_raise(rb_eTypeError, "path must be a String");
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (RSTRING_LEN(path) == 0) {
|
|
724
|
+
rb_raise(rb_eArgError, "path must not be empty");
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
path_str = StringValueCStr(path);
|
|
728
|
+
|
|
729
|
+
book = pageprint_create_book_from_html(html, options, &resource_fetcher);
|
|
730
|
+
|
|
731
|
+
plutobook_clear_error_message();
|
|
732
|
+
|
|
733
|
+
write_args.book = book;
|
|
734
|
+
write_args.path = path_str;
|
|
735
|
+
write_args.ok = 0;
|
|
736
|
+
|
|
737
|
+
rb_thread_call_without_gvl(
|
|
738
|
+
pageprint_write_pdf_without_gvl,
|
|
739
|
+
&write_args,
|
|
740
|
+
RUBY_UBF_IO,
|
|
741
|
+
NULL
|
|
742
|
+
);
|
|
743
|
+
|
|
744
|
+
plutobook_destroy(book);
|
|
745
|
+
|
|
746
|
+
if (resource_fetcher.state) {
|
|
747
|
+
rb_jump_tag(resource_fetcher.state);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
if (!write_args.ok) {
|
|
751
|
+
pageprint_raise_plutobook_error_with_path(rb_eRuntimeError, "failed to write PDF to", path_str);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
RB_GC_GUARD(resource_fetcher.object);
|
|
755
|
+
RB_GC_GUARD(options);
|
|
756
|
+
RB_GC_GUARD(path);
|
|
757
|
+
|
|
758
|
+
return Qtrue;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
static VALUE pageprint_html_to_pdf_string(int argc, VALUE *argv, VALUE self) {
|
|
762
|
+
VALUE html;
|
|
763
|
+
VALUE options;
|
|
764
|
+
pageprint_pdf_string_output_t output;
|
|
765
|
+
|
|
766
|
+
plutobook_t *book;
|
|
767
|
+
pageprint_resource_fetcher_t resource_fetcher;
|
|
768
|
+
pageprint_write_pdf_stream_args_t write_args;
|
|
769
|
+
|
|
770
|
+
rb_check_arity(argc, 1, 2);
|
|
771
|
+
|
|
772
|
+
html = argv[0];
|
|
773
|
+
options = argc == 2 ? argv[1] : Qnil;
|
|
774
|
+
output.output = rb_str_new(NULL, 0);
|
|
775
|
+
output.state = 0;
|
|
776
|
+
rb_enc_associate_index(output.output, rb_ascii8bit_encindex());
|
|
777
|
+
|
|
778
|
+
book = pageprint_create_book_from_html(html, options, &resource_fetcher);
|
|
779
|
+
|
|
780
|
+
plutobook_clear_error_message();
|
|
781
|
+
|
|
782
|
+
write_args.book = book;
|
|
783
|
+
write_args.output = &output;
|
|
784
|
+
write_args.ok = 0;
|
|
785
|
+
|
|
786
|
+
rb_thread_call_without_gvl(
|
|
787
|
+
pageprint_write_pdf_stream_without_gvl,
|
|
788
|
+
&write_args,
|
|
789
|
+
RUBY_UBF_IO,
|
|
790
|
+
NULL
|
|
791
|
+
);
|
|
792
|
+
|
|
793
|
+
plutobook_destroy(book);
|
|
794
|
+
|
|
795
|
+
if (resource_fetcher.state) {
|
|
796
|
+
rb_jump_tag(resource_fetcher.state);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (output.state) {
|
|
800
|
+
rb_jump_tag(output.state);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
if (!write_args.ok) {
|
|
804
|
+
pageprint_raise_plutobook_error(rb_eRuntimeError, "failed to write PDF to string");
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
RB_GC_GUARD(resource_fetcher.object);
|
|
808
|
+
RB_GC_GUARD(options);
|
|
809
|
+
RB_GC_GUARD(output.output);
|
|
810
|
+
|
|
811
|
+
return output.output;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
void Init_page_print(void) {
|
|
815
|
+
mPagePrint = rb_define_module("PagePrint");
|
|
816
|
+
|
|
817
|
+
id_base_url = rb_intern_const("base_url");
|
|
818
|
+
id_page_size = rb_intern_const("page_size");
|
|
819
|
+
id_margins = rb_intern_const("margins");
|
|
820
|
+
id_media = rb_intern_const("media");
|
|
821
|
+
id_resource_fetcher = rb_intern_const("resource_fetcher");
|
|
822
|
+
id_metadata = rb_intern_const("metadata");
|
|
823
|
+
id_width = rb_intern_const("width");
|
|
824
|
+
id_height = rb_intern_const("height");
|
|
825
|
+
id_unit = rb_intern_const("unit");
|
|
826
|
+
id_top = rb_intern_const("top");
|
|
827
|
+
id_right = rb_intern_const("right");
|
|
828
|
+
id_bottom = rb_intern_const("bottom");
|
|
829
|
+
id_left = rb_intern_const("left");
|
|
830
|
+
id_resource_fetcher_ivar = rb_intern_const("@resource_fetcher");
|
|
831
|
+
id_base_url_method = rb_intern_const("base_url");
|
|
832
|
+
id_call = rb_intern_const("call");
|
|
833
|
+
id_content = rb_intern_const("content");
|
|
834
|
+
id_mime_type = rb_intern_const("mime_type");
|
|
835
|
+
id_text_encoding = rb_intern_const("text_encoding");
|
|
836
|
+
id_title = rb_intern_const("title");
|
|
837
|
+
id_author = rb_intern_const("author");
|
|
838
|
+
id_subject = rb_intern_const("subject");
|
|
839
|
+
id_keywords = rb_intern_const("keywords");
|
|
840
|
+
id_creation_date = rb_intern_const("creation_date");
|
|
841
|
+
id_modification_date = rb_intern_const("modification_date");
|
|
842
|
+
id_pt = rb_intern_const("pt");
|
|
843
|
+
id_pc = rb_intern_const("pc");
|
|
844
|
+
id_in = rb_intern_const("in");
|
|
845
|
+
id_cm = rb_intern_const("cm");
|
|
846
|
+
id_mm = rb_intern_const("mm");
|
|
847
|
+
id_px = rb_intern_const("px");
|
|
848
|
+
|
|
849
|
+
rb_define_singleton_method(mPagePrint, "html_to_pdf", RUBY_METHOD_FUNC(pageprint_html_to_pdf), -1);
|
|
850
|
+
rb_define_singleton_method(mPagePrint, "html_to_pdf_string", RUBY_METHOD_FUNC(pageprint_html_to_pdf_string), -1);
|
|
851
|
+
}
|