1 #if defined(_WRAP_CODE)
2
3
4 /* Activate a previously created structure element or other content item.. */
5 static VALUE
activate_item(VALUE self,VALUE id)6 activate_item(VALUE self, VALUE id)
7 {
8 PDF *pdf = get_pdf(self);
9 pdf_try {
10 PDF_activate_item(pdf, NUM2INT(id));
11 } pdf_catch;
12
13 return self;
14 }
15
16
17 /* Create a 3D view (requires PDF 1.6). Returns: A 3D view handle, or -1 (in PHP: 0) on error.. */
18 static VALUE
create_3dview(VALUE self,VALUE username,VALUE optlist)19 create_3dview(VALUE self, VALUE username, VALUE optlist)
20 {
21 PDF *pdf = get_pdf(self);
22 int ret = 0;
23
24 pdf_try {
25 ret = PDF_create_3dview(pdf, CHAR(username), 0, CHAR(optlist));
26 } pdf_catch;
27
28 return INT2NUM(ret);
29 }
30
31
32 /* Load a 3D model from a disk-based or virtual file (requires PDF 1.6). Returns: A 3D handle, or -1 (in PHP: 0) on error.. */
33 static VALUE
load_3ddata(VALUE self,VALUE filename,VALUE optlist)34 load_3ddata(VALUE self, VALUE filename, VALUE optlist)
35 {
36 PDF *pdf = get_pdf(self);
37 int ret = 0;
38
39 pdf_try {
40 ret = PDF_load_3ddata(pdf, CHAR(filename), 0, CHAR(optlist));
41 } pdf_catch;
42
43 return INT2NUM(ret);
44 }
45
46
47 /* Create a named destination on an arbitrary page in the current document.. */
48 static VALUE
add_nameddest(VALUE self,VALUE name,VALUE optlist)49 add_nameddest(VALUE self, VALUE name, VALUE optlist)
50 {
51 PDF *pdf = get_pdf(self);
52 pdf_try {
53 PDF_add_nameddest(pdf, CHAR(name), LEN(name), CHAR(optlist));
54 } pdf_catch;
55
56 return self;
57 }
58
59
60 /* Add a cell to a new or existing table. Returns: A table handle which can be used in subsequent table-related calls. . */
61 static VALUE
add_table_cell(VALUE self,VALUE table,VALUE column,VALUE row,VALUE text,VALUE optlist)62 add_table_cell(VALUE self, VALUE table, VALUE column, VALUE row, VALUE text, VALUE optlist)
63 {
64 PDF *pdf = get_pdf(self);
65 int ret = 0;
66
67 pdf_try {
68 ret = PDF_add_table_cell(pdf, NUM2INT(table), NUM2INT(column), NUM2INT(row), CHAR(text), LEN(text), CHAR(optlist));
69 } pdf_catch;
70
71 return INT2NUM(ret);
72 }
73
74
75 /* Create a Textflow object, or add text and explicit options to an existing Textflow. Returns: A Textflow handle, or -1 (in PHP: 0) on error.. */
76 static VALUE
add_textflow(VALUE self,VALUE textflow,VALUE text,VALUE optlist)77 add_textflow(VALUE self, VALUE textflow, VALUE text, VALUE optlist)
78 {
79 PDF *pdf = get_pdf(self);
80 int ret = 0;
81
82 pdf_try {
83 ret = PDF_add_textflow(pdf, NUM2INT(textflow), CHAR(text), LEN(text), CHAR(optlist));
84 } pdf_catch;
85
86 return INT2NUM(ret);
87 }
88
89
90 /* Add an existing image as thumbnail for the current page.. */
91 static VALUE
add_thumbnail(VALUE self,VALUE image)92 add_thumbnail(VALUE self, VALUE image)
93 {
94 PDF *pdf = get_pdf(self);
95 pdf_try {
96 PDF_add_thumbnail(pdf, NUM2INT(image));
97 } pdf_catch;
98
99 return self;
100 }
101
102
103 /* Draw a counterclockwise circular arc segment.. */
104 static VALUE
arc(VALUE self,VALUE x,VALUE y,VALUE r,VALUE alpha,VALUE beta)105 arc(VALUE self, VALUE x, VALUE y, VALUE r, VALUE alpha, VALUE beta)
106 {
107 PDF *pdf = get_pdf(self);
108 pdf_try {
109 PDF_arc(pdf, NUM2DBL(x), NUM2DBL(y), NUM2DBL(r), NUM2DBL(alpha), NUM2DBL(beta));
110 } pdf_catch;
111
112 return self;
113 }
114
115
116 /* Draw a clockwise circular arc segment.. */
117 static VALUE
arcn(VALUE self,VALUE x,VALUE y,VALUE r,VALUE alpha,VALUE beta)118 arcn(VALUE self, VALUE x, VALUE y, VALUE r, VALUE alpha, VALUE beta)
119 {
120 PDF *pdf = get_pdf(self);
121 pdf_try {
122 PDF_arcn(pdf, NUM2DBL(x), NUM2DBL(y), NUM2DBL(r), NUM2DBL(alpha), NUM2DBL(beta));
123 } pdf_catch;
124
125 return self;
126 }
127
128
129 /* Create a new PDF file subject to various options. Returns: -1 (in PHP: 0) on error, and 1 otherwise. . */
130 static VALUE
begin_document(VALUE self,VALUE filename,VALUE optlist)131 begin_document(VALUE self, VALUE filename, VALUE optlist)
132 {
133 PDF *pdf = get_pdf(self);
134 int ret = 0;
135
136 pdf_try {
137 ret = PDF_begin_document(pdf, CHAR(filename), 0, CHAR(optlist));
138 } pdf_catch;
139
140 return INT2NUM(ret);
141 }
142
143
144 /* Start a Type 3 font definition.. */
145 static VALUE
begin_font(VALUE self,VALUE fontname,VALUE a,VALUE b,VALUE c,VALUE d,VALUE e,VALUE f,VALUE optlist)146 begin_font(VALUE self, VALUE fontname, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e, VALUE f, VALUE optlist)
147 {
148 PDF *pdf = get_pdf(self);
149 pdf_try {
150 PDF_begin_font(pdf, CHAR(fontname), 0, NUM2DBL(a), NUM2DBL(b), NUM2DBL(c), NUM2DBL(d), NUM2DBL(e), NUM2DBL(f), CHAR(optlist));
151 } pdf_catch;
152
153 return self;
154 }
155
156
157 /* Start a glyph definition for a Type 3 font.. */
158 static VALUE
begin_glyph(VALUE self,VALUE glyphname,VALUE wx,VALUE llx,VALUE lly,VALUE urx,VALUE ury)159 begin_glyph(VALUE self, VALUE glyphname, VALUE wx, VALUE llx, VALUE lly, VALUE urx, VALUE ury)
160 {
161 PDF *pdf = get_pdf(self);
162 pdf_try {
163 PDF_begin_glyph(pdf, CHAR(glyphname), NUM2DBL(wx), NUM2DBL(llx), NUM2DBL(lly), NUM2DBL(urx), NUM2DBL(ury));
164 } pdf_catch;
165
166 return self;
167 }
168
169
170 /* Open a structure element or other content item with attributes supplied as options. Returns: An item handle. . */
171 static VALUE
begin_item(VALUE self,VALUE tag,VALUE optlist)172 begin_item(VALUE self, VALUE tag, VALUE optlist)
173 {
174 PDF *pdf = get_pdf(self);
175 int ret = 0;
176
177 pdf_try {
178 ret = PDF_begin_item(pdf, CHAR(tag), CHAR(optlist));
179 } pdf_catch;
180
181 return INT2NUM(ret);
182 }
183
184
185 /* Start a layer for subsequent output on the page (requires PDF 1.5).. */
186 static VALUE
begin_layer(VALUE self,VALUE layer)187 begin_layer(VALUE self, VALUE layer)
188 {
189 PDF *pdf = get_pdf(self);
190 pdf_try {
191 PDF_begin_layer(pdf, NUM2INT(layer));
192 } pdf_catch;
193
194 return self;
195 }
196
197
198 /* Add a new page to the document, and specify various options.. */
199 static VALUE
begin_page_ext(VALUE self,VALUE width,VALUE height,VALUE optlist)200 begin_page_ext(VALUE self, VALUE width, VALUE height, VALUE optlist)
201 {
202 PDF *pdf = get_pdf(self);
203 pdf_try {
204 PDF_begin_page_ext(pdf, NUM2DBL(width), NUM2DBL(height), CHAR(optlist));
205 } pdf_catch;
206
207 return self;
208 }
209
210
211 /* Start a pattern definition. Returns: A pattern handle. . */
212 static VALUE
begin_pattern(VALUE self,VALUE width,VALUE height,VALUE xstep,VALUE ystep,VALUE painttype)213 begin_pattern(VALUE self, VALUE width, VALUE height, VALUE xstep, VALUE ystep, VALUE painttype)
214 {
215 PDF *pdf = get_pdf(self);
216 int ret = 0;
217
218 pdf_try {
219 ret = PDF_begin_pattern(pdf, NUM2DBL(width), NUM2DBL(height), NUM2DBL(xstep), NUM2DBL(ystep), NUM2INT(painttype));
220 } pdf_catch;
221
222 return INT2NUM(ret);
223 }
224
225
226 /* Deprecated, use PDF_begin_template_ext().. */
227 static VALUE
begin_template(VALUE self,VALUE width,VALUE height)228 begin_template(VALUE self, VALUE width, VALUE height)
229 {
230 PDF *pdf = get_pdf(self);
231 int ret = 0;
232
233 pdf_try {
234 ret = PDF_begin_template(pdf, NUM2DBL(width), NUM2DBL(height));
235 } pdf_catch;
236
237 return INT2NUM(ret);
238 }
239
240
241 /* Start a template definition. Returns: A template handle. . */
242 static VALUE
begin_template_ext(VALUE self,VALUE width,VALUE height,VALUE optlist)243 begin_template_ext(VALUE self, VALUE width, VALUE height, VALUE optlist)
244 {
245 PDF *pdf = get_pdf(self);
246 int ret = 0;
247
248 pdf_try {
249 ret = PDF_begin_template_ext(pdf, NUM2DBL(width), NUM2DBL(height), CHAR(optlist));
250 } pdf_catch;
251
252 return INT2NUM(ret);
253 }
254
255
256 /* Draw a circle.. */
257 static VALUE
circle(VALUE self,VALUE x,VALUE y,VALUE r)258 circle(VALUE self, VALUE x, VALUE y, VALUE r)
259 {
260 PDF *pdf = get_pdf(self);
261 pdf_try {
262 PDF_circle(pdf, NUM2DBL(x), NUM2DBL(y), NUM2DBL(r));
263 } pdf_catch;
264
265 return self;
266 }
267
268
269 /* Use the current path as clipping path, and terminate the path.. */
270 static VALUE
clip(VALUE self)271 clip(VALUE self)
272 {
273 PDF *pdf = get_pdf(self);
274 pdf_try {
275 PDF_clip(pdf);
276 } pdf_catch;
277
278 return self;
279 }
280
281
282 /* Close an image.. */
283 static VALUE
close_image(VALUE self,VALUE image)284 close_image(VALUE self, VALUE image)
285 {
286 PDF *pdf = get_pdf(self);
287 pdf_try {
288 PDF_close_image(pdf, NUM2INT(image));
289 } pdf_catch;
290
291 return self;
292 }
293
294
295 /* Deprecated, use PDF_close_pdi_document().. */
296 static VALUE
close_pdi(VALUE self,VALUE doc)297 close_pdi(VALUE self, VALUE doc)
298 {
299 PDF *pdf = get_pdf(self);
300 pdf_try {
301 PDF_close_pdi(pdf, NUM2INT(doc));
302 } pdf_catch;
303
304 return self;
305 }
306
307
308 /* Close all open PDI page handles, and close the input PDF document.. */
309 static VALUE
close_pdi_document(VALUE self,VALUE doc)310 close_pdi_document(VALUE self, VALUE doc)
311 {
312 PDF *pdf = get_pdf(self);
313 pdf_try {
314 PDF_close_pdi_document(pdf, NUM2INT(doc));
315 } pdf_catch;
316
317 return self;
318 }
319
320
321 /* Close the page handle and free all page-related resources.. */
322 static VALUE
close_pdi_page(VALUE self,VALUE page)323 close_pdi_page(VALUE self, VALUE page)
324 {
325 PDF *pdf = get_pdf(self);
326 pdf_try {
327 PDF_close_pdi_page(pdf, NUM2INT(page));
328 } pdf_catch;
329
330 return self;
331 }
332
333
334 /* Close the current path.. */
335 static VALUE
closepath(VALUE self)336 closepath(VALUE self)
337 {
338 PDF *pdf = get_pdf(self);
339 pdf_try {
340 PDF_closepath(pdf);
341 } pdf_catch;
342
343 return self;
344 }
345
346
347 /* Close the path, fill, and stroke it.. */
348 static VALUE
closepath_fill_stroke(VALUE self)349 closepath_fill_stroke(VALUE self)
350 {
351 PDF *pdf = get_pdf(self);
352 pdf_try {
353 PDF_closepath_fill_stroke(pdf);
354 } pdf_catch;
355
356 return self;
357 }
358
359
360 /* Close the path, and stroke it.. */
361 static VALUE
closepath_stroke(VALUE self)362 closepath_stroke(VALUE self)
363 {
364 PDF *pdf = get_pdf(self);
365 pdf_try {
366 PDF_closepath_stroke(pdf);
367 } pdf_catch;
368
369 return self;
370 }
371
372
373 /* Apply a transformation matrix to the current coordinate system.. */
374 static VALUE
concat(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d,VALUE e,VALUE f)375 concat(VALUE self, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e, VALUE f)
376 {
377 PDF *pdf = get_pdf(self);
378 pdf_try {
379 PDF_concat(pdf, NUM2DBL(a), NUM2DBL(b), NUM2DBL(c), NUM2DBL(d), NUM2DBL(e), NUM2DBL(f));
380 } pdf_catch;
381
382 return self;
383 }
384
385
386 /* Same as PDF_continue_text(), but with explicit string length.. */
387 static VALUE
continue_text(VALUE self,VALUE text)388 continue_text(VALUE self, VALUE text)
389 {
390 PDF *pdf = get_pdf(self);
391 pdf_try {
392 PDF_continue_text2(pdf, CHAR(text), LEN(text));
393 } pdf_catch;
394
395 return self;
396 }
397
398
399 /* Create an action which can be applied to various objects and events. Returns: An action handle.. */
400 static VALUE
create_action(VALUE self,VALUE type,VALUE optlist)401 create_action(VALUE self, VALUE type, VALUE optlist)
402 {
403 PDF *pdf = get_pdf(self);
404 int ret = 0;
405
406 pdf_try {
407 ret = PDF_create_action(pdf, CHAR(type), CHAR(optlist));
408 } pdf_catch;
409
410 return INT2NUM(ret);
411 }
412
413
414 /* Create a rectangular annotation on the current page.. */
415 static VALUE
create_annotation(VALUE self,VALUE llx,VALUE lly,VALUE urx,VALUE ury,VALUE type,VALUE optlist)416 create_annotation(VALUE self, VALUE llx, VALUE lly, VALUE urx, VALUE ury, VALUE type, VALUE optlist)
417 {
418 PDF *pdf = get_pdf(self);
419 pdf_try {
420 PDF_create_annotation(pdf, NUM2DBL(llx), NUM2DBL(lly), NUM2DBL(urx), NUM2DBL(ury), CHAR(type), CHAR(optlist));
421 } pdf_catch;
422
423 return self;
424 }
425
426
427 /* Create a bookmark subject to various options. Returns: A handle for the generated bookmark.. */
428 static VALUE
create_bookmark(VALUE self,VALUE text,VALUE optlist)429 create_bookmark(VALUE self, VALUE text, VALUE optlist)
430 {
431 PDF *pdf = get_pdf(self);
432 int ret = 0;
433
434 pdf_try {
435 ret = PDF_create_bookmark(pdf, CHAR(text), LEN(text), CHAR(optlist));
436 } pdf_catch;
437
438 return INT2NUM(ret);
439 }
440
441
442 /* Create a form field on the current page subject to various options.. */
443 static VALUE
create_field(VALUE self,VALUE llx,VALUE lly,VALUE urx,VALUE ury,VALUE name,VALUE type,VALUE optlist)444 create_field(VALUE self, VALUE llx, VALUE lly, VALUE urx, VALUE ury, VALUE name, VALUE type, VALUE optlist)
445 {
446 PDF *pdf = get_pdf(self);
447 pdf_try {
448 PDF_create_field(pdf, NUM2DBL(llx), NUM2DBL(lly), NUM2DBL(urx), NUM2DBL(ury), CHAR(name), LEN(name), CHAR(type), CHAR(optlist));
449 } pdf_catch;
450
451 return self;
452 }
453
454
455 /* Create a form field group subject to various options. Returns: A graphics state handle.. */
456 static VALUE
create_fieldgroup(VALUE self,VALUE name,VALUE optlist)457 create_fieldgroup(VALUE self, VALUE name, VALUE optlist)
458 {
459 PDF *pdf = get_pdf(self);
460 pdf_try {
461 PDF_create_fieldgroup(pdf, CHAR(name), LEN(name), CHAR(optlist));
462 } pdf_catch;
463
464 return self;
465 }
466
467
468 /* Create a graphics state object subject to various options.. */
469 static VALUE
create_gstate(VALUE self,VALUE optlist)470 create_gstate(VALUE self, VALUE optlist)
471 {
472 PDF *pdf = get_pdf(self);
473 int ret = 0;
474
475 pdf_try {
476 ret = PDF_create_gstate(pdf, CHAR(optlist));
477 } pdf_catch;
478
479 return INT2NUM(ret);
480 }
481
482
483 /* Create a named virtual read-only file from data provided in memory.. */
484 static VALUE
create_pvf(VALUE self,VALUE filename,VALUE data,VALUE optlist)485 create_pvf(VALUE self, VALUE filename, VALUE data, VALUE optlist)
486 {
487 PDF *pdf = get_pdf(self);
488 pdf_try {
489 PDF_create_pvf(pdf, CHAR(filename), 0, CHAR(data), LEN(data), CHAR(optlist));
490 } pdf_catch;
491
492 return self;
493 }
494
495
496 /* Create a Textflow object from text contents, inline options, and explicit options. Returns: A Textflow handle, or -1 (in PHP: 0) on error.. */
497 static VALUE
create_textflow(VALUE self,VALUE text,VALUE optlist)498 create_textflow(VALUE self, VALUE text, VALUE optlist)
499 {
500 PDF *pdf = get_pdf(self);
501 int ret = 0;
502
503 pdf_try {
504 ret = PDF_create_textflow(pdf, CHAR(text), LEN(text), CHAR(optlist));
505 } pdf_catch;
506
507 return INT2NUM(ret);
508 }
509
510
511 /* Draw a Bezier curve from the current point, using 3 more control points.. */
512 static VALUE
curveto(VALUE self,VALUE x_1,VALUE y_1,VALUE x_2,VALUE y_2,VALUE x_3,VALUE y_3)513 curveto(VALUE self, VALUE x_1, VALUE y_1, VALUE x_2, VALUE y_2, VALUE x_3, VALUE y_3)
514 {
515 PDF *pdf = get_pdf(self);
516 pdf_try {
517 PDF_curveto(pdf, NUM2DBL(x_1), NUM2DBL(y_1), NUM2DBL(x_2), NUM2DBL(y_2), NUM2DBL(x_3), NUM2DBL(y_3));
518 } pdf_catch;
519
520 return self;
521 }
522
523
524 /* Create a new layer definition (requires PDF 1.5). Returns: A layer handle.. */
525 static VALUE
define_layer(VALUE self,VALUE name,VALUE optlist)526 define_layer(VALUE self, VALUE name, VALUE optlist)
527 {
528 PDF *pdf = get_pdf(self);
529 int ret = 0;
530
531 pdf_try {
532 ret = PDF_define_layer(pdf, CHAR(name), LEN(name), CHAR(optlist));
533 } pdf_catch;
534
535 return INT2NUM(ret);
536 }
537
538
539 /* Delete a named virtual file and free its data structures (but not the contents). Returns: -1 (in PHP: 0) if the virtual file exists but is locked, and 1 otherwise.. */
540 static VALUE
delete_pvf(VALUE self,VALUE filename)541 delete_pvf(VALUE self, VALUE filename)
542 {
543 PDF *pdf = get_pdf(self);
544 int ret = 0;
545
546 pdf_try {
547 ret = PDF_delete_pvf(pdf, CHAR(filename), 0);
548 } pdf_catch;
549
550 return INT2NUM(ret);
551 }
552
553
554 /* Delete a table and all associated data structures.. */
555 static VALUE
delete_table(VALUE self,VALUE table,VALUE optlist)556 delete_table(VALUE self, VALUE table, VALUE optlist)
557 {
558 PDF *pdf = get_pdf(self);
559 pdf_try {
560 PDF_delete_table(pdf, NUM2INT(table), CHAR(optlist));
561 } pdf_catch;
562
563 return self;
564 }
565
566
567 /* Delete a textflow and all associated data structures.. */
568 static VALUE
delete_textflow(VALUE self,VALUE textflow)569 delete_textflow(VALUE self, VALUE textflow)
570 {
571 PDF *pdf = get_pdf(self);
572 pdf_try {
573 PDF_delete_textflow(pdf, NUM2INT(textflow));
574 } pdf_catch;
575
576 return self;
577 }
578
579
580 /* Add a glyph name and/or Unicode value to a custom encoding.. */
581 static VALUE
encoding_set_char(VALUE self,VALUE encoding,VALUE slot,VALUE glyphname,VALUE uv)582 encoding_set_char(VALUE self, VALUE encoding, VALUE slot, VALUE glyphname, VALUE uv)
583 {
584 PDF *pdf = get_pdf(self);
585 pdf_try {
586 PDF_encoding_set_char(pdf, CHAR(encoding), NUM2INT(slot), CHAR(glyphname), NUM2INT(uv));
587 } pdf_catch;
588
589 return self;
590 }
591
592
593 /* Close the generated PDF document and apply various options.. */
594 static VALUE
end_document(VALUE self,VALUE optlist)595 end_document(VALUE self, VALUE optlist)
596 {
597 PDF *pdf = get_pdf(self);
598 pdf_try {
599 PDF_end_document(pdf, CHAR(optlist));
600 } pdf_catch;
601
602 return self;
603 }
604
605
606 /* Terminate a Type 3 font definition.. */
607 static VALUE
end_font(VALUE self)608 end_font(VALUE self)
609 {
610 PDF *pdf = get_pdf(self);
611 pdf_try {
612 PDF_end_font(pdf);
613 } pdf_catch;
614
615 return self;
616 }
617
618
619 /* Terminate a glyph definition for a Type 3 font.. */
620 static VALUE
end_glyph(VALUE self)621 end_glyph(VALUE self)
622 {
623 PDF *pdf = get_pdf(self);
624 pdf_try {
625 PDF_end_glyph(pdf);
626 } pdf_catch;
627
628 return self;
629 }
630
631
632 /* Close a structure element or other content item.. */
633 static VALUE
end_item(VALUE self,VALUE id)634 end_item(VALUE self, VALUE id)
635 {
636 PDF *pdf = get_pdf(self);
637 pdf_try {
638 PDF_end_item(pdf, NUM2INT(id));
639 } pdf_catch;
640
641 return self;
642 }
643
644
645 /* Deactivate all active layers (requires PDF 1.5).. */
646 static VALUE
end_layer(VALUE self)647 end_layer(VALUE self)
648 {
649 PDF *pdf = get_pdf(self);
650 pdf_try {
651 PDF_end_layer(pdf);
652 } pdf_catch;
653
654 return self;
655 }
656
657
658 /* End the least recently opened marked content sequence (unsupported).. */
659 static VALUE
end_mc(VALUE self)660 end_mc(VALUE self)
661 {
662 PDF *pdf = get_pdf(self);
663 pdf_try {
664 PDF_end_mc(pdf);
665 } pdf_catch;
666
667 return self;
668 }
669
670
671 /* Finish a page, and apply various options.. */
672 static VALUE
end_page_ext(VALUE self,VALUE optlist)673 end_page_ext(VALUE self, VALUE optlist)
674 {
675 PDF *pdf = get_pdf(self);
676 pdf_try {
677 PDF_end_page_ext(pdf, CHAR(optlist));
678 } pdf_catch;
679
680 return self;
681 }
682
683
684 /* Finish a pattern definition.. */
685 static VALUE
end_pattern(VALUE self)686 end_pattern(VALUE self)
687 {
688 PDF *pdf = get_pdf(self);
689 pdf_try {
690 PDF_end_pattern(pdf);
691 } pdf_catch;
692
693 return self;
694 }
695
696
697 /* Finish a template definition.. */
698 static VALUE
end_template(VALUE self)699 end_template(VALUE self)
700 {
701 PDF *pdf = get_pdf(self);
702 pdf_try {
703 PDF_end_template(pdf);
704 } pdf_catch;
705
706 return self;
707 }
708
709
710 /* End the current path without filling or stroking it.. */
711 static VALUE
endpath(VALUE self)712 endpath(VALUE self)
713 {
714 PDF *pdf = get_pdf(self);
715 pdf_try {
716 PDF_endpath(pdf);
717 } pdf_catch;
718
719 return self;
720 }
721
722
723 /* Fill the interior of the path with the current fill color.. */
724 static VALUE
fill(VALUE self)725 fill(VALUE self)
726 {
727 PDF *pdf = get_pdf(self);
728 pdf_try {
729 PDF_fill(pdf);
730 } pdf_catch;
731
732 return self;
733 }
734
735
736 /* Fill an image block with variable data according to its properties. Returns: -1 (in PHP: 0) on error, and 1 otherwise.. */
737 static VALUE
fill_imageblock(VALUE self,VALUE page,VALUE blockname,VALUE image,VALUE optlist)738 fill_imageblock(VALUE self, VALUE page, VALUE blockname, VALUE image, VALUE optlist)
739 {
740 PDF *pdf = get_pdf(self);
741 int ret = 0;
742
743 pdf_try {
744 ret = PDF_fill_imageblock(pdf, NUM2INT(page), CHAR(blockname), NUM2INT(image), CHAR(optlist));
745 } pdf_catch;
746
747 return INT2NUM(ret);
748 }
749
750
751 /* Fill a PDF block with variable data according to its properties. Returns: -1 (in PHP: 0) on error, and 1 otherwise.. */
752 static VALUE
fill_pdfblock(VALUE self,VALUE page,VALUE blockname,VALUE contents,VALUE optlist)753 fill_pdfblock(VALUE self, VALUE page, VALUE blockname, VALUE contents, VALUE optlist)
754 {
755 PDF *pdf = get_pdf(self);
756 int ret = 0;
757
758 pdf_try {
759 ret = PDF_fill_pdfblock(pdf, NUM2INT(page), CHAR(blockname), NUM2INT(contents), CHAR(optlist));
760 } pdf_catch;
761
762 return INT2NUM(ret);
763 }
764
765
766 /* Fill and stroke the path with the current fill and stroke color.. */
767 static VALUE
fill_stroke(VALUE self)768 fill_stroke(VALUE self)
769 {
770 PDF *pdf = get_pdf(self);
771 pdf_try {
772 PDF_fill_stroke(pdf);
773 } pdf_catch;
774
775 return self;
776 }
777
778
779 /* Fill a text block with variable data according to its properties. Returns: -1 (in PHP: 0) on error, and 1 otherwise.. */
780 static VALUE
fill_textblock(VALUE self,VALUE page,VALUE blockname,VALUE text,VALUE optlist)781 fill_textblock(VALUE self, VALUE page, VALUE blockname, VALUE text, VALUE optlist)
782 {
783 PDF *pdf = get_pdf(self);
784 int ret = 0;
785
786 pdf_try {
787 ret = PDF_fill_textblock(pdf, NUM2INT(page), CHAR(blockname), CHAR(text), LEN(text), CHAR(optlist));
788 } pdf_catch;
789
790 return INT2NUM(ret);
791 }
792
793
794 /* Place an image or template on the page, subject to various options.. */
795 static VALUE
fit_image(VALUE self,VALUE image,VALUE x,VALUE y,VALUE optlist)796 fit_image(VALUE self, VALUE image, VALUE x, VALUE y, VALUE optlist)
797 {
798 PDF *pdf = get_pdf(self);
799 pdf_try {
800 PDF_fit_image(pdf, NUM2INT(image), NUM2DBL(x), NUM2DBL(y), CHAR(optlist));
801 } pdf_catch;
802
803 return self;
804 }
805
806
807 /* Place an imported PDF page on the page subject to various options.. */
808 static VALUE
fit_pdi_page(VALUE self,VALUE page,VALUE x,VALUE y,VALUE optlist)809 fit_pdi_page(VALUE self, VALUE page, VALUE x, VALUE y, VALUE optlist)
810 {
811 PDF *pdf = get_pdf(self);
812 pdf_try {
813 PDF_fit_pdi_page(pdf, NUM2INT(page), NUM2DBL(x), NUM2DBL(y), CHAR(optlist));
814 } pdf_catch;
815
816 return self;
817 }
818
819
820 /* Fully or partially place a table on the page. Returns: A string which specifies the reason for returning.. */
821 static VALUE
fit_table(VALUE self,VALUE table,VALUE llx,VALUE lly,VALUE urx,VALUE ury,VALUE optlist)822 fit_table(VALUE self, VALUE table, VALUE llx, VALUE lly, VALUE urx, VALUE ury, VALUE optlist)
823 {
824 PDF *pdf = get_pdf(self);
825 const char *ret = NULL;
826
827 pdf_try {
828 ret = PDF_fit_table(pdf, NUM2INT(table), NUM2DBL(llx), NUM2DBL(lly), NUM2DBL(urx), NUM2DBL(ury), CHAR(optlist));
829 } pdf_catch;
830
831 return rb_str_new2(ret);
832 }
833
834
835 /* Format the next portion of a textflow into a rectangular area. Returns: A string which specifies the reason for returning.. */
836 static VALUE
fit_textflow(VALUE self,VALUE textflow,VALUE llx,VALUE lly,VALUE urx,VALUE ury,VALUE optlist)837 fit_textflow(VALUE self, VALUE textflow, VALUE llx, VALUE lly, VALUE urx, VALUE ury, VALUE optlist)
838 {
839 PDF *pdf = get_pdf(self);
840 const char *ret = NULL;
841
842 pdf_try {
843 ret = PDF_fit_textflow(pdf, NUM2INT(textflow), NUM2DBL(llx), NUM2DBL(lly), NUM2DBL(urx), NUM2DBL(ury), CHAR(optlist));
844 } pdf_catch;
845
846 return rb_str_new2(ret);
847 }
848
849
850 /* Place a single line of text at position (x, y) subject to various options.. */
851 static VALUE
fit_textline(VALUE self,VALUE text,VALUE x,VALUE y,VALUE optlist)852 fit_textline(VALUE self, VALUE text, VALUE x, VALUE y, VALUE optlist)
853 {
854 PDF *pdf = get_pdf(self);
855 pdf_try {
856 PDF_fit_textline(pdf, CHAR(text), LEN(text), NUM2DBL(x), NUM2DBL(y), CHAR(optlist));
857 } pdf_catch;
858
859 return self;
860 }
861
862
863 /* Get the name of the API function which threw the last exception or failed. Returns: Name of an API function.. */
864 static VALUE
get_apiname(VALUE self)865 get_apiname(VALUE self)
866 {
867 PDF *pdf = get_pdf(self);
868 const char *ret = NULL;
869
870 pdf_try {
871 ret = PDF_get_apiname(pdf);
872 } pdf_catch;
873
874 return rb_str_new2(ret);
875 }
876
877
878 /* Get the contents of the PDF output buffer. Returns: A buffer full of binary PDF data for consumption by the client.. */
879 static VALUE
get_buffer(VALUE self)880 get_buffer(VALUE self)
881 {
882 PDF *pdf = get_pdf(self);
883 long size = -1;
884 const char *ret = NULL;
885
886
887 pdf_try {
888 ret = PDF_get_buffer(pdf, &size);
889 } pdf_catch;
890
891 return rb_str_new(ret, size);
892 }
893
894
895 /* Get the text of the last thrown exception or the reason of a failed function call. Returns: Text containing the description of the most recent error condition.. */
896 static VALUE
get_errmsg(VALUE self)897 get_errmsg(VALUE self)
898 {
899 PDF *pdf = get_pdf(self);
900 const char *ret = NULL;
901
902 pdf_try {
903 ret = PDF_get_errmsg(pdf);
904 } pdf_catch;
905
906 return rb_str_new2(ret);
907 }
908
909
910 /* Get the number of the last thrown exception or the reason of a failed function call. Returns: The error code of the most recent error condition.. */
911 static VALUE
get_errnum(VALUE self)912 get_errnum(VALUE self)
913 {
914 PDF *pdf = get_pdf(self);
915 int ret = 0;
916
917 pdf_try {
918 ret = PDF_get_errnum(pdf);
919 } pdf_catch;
920
921 return INT2NUM(ret);
922 }
923
924
925 /* Get the contents of some PDFlib parameter with string type. Returns: The string value of the parameter as a hypertext string.. */
926 static VALUE
get_parameter(VALUE self,VALUE key,VALUE modifier)927 get_parameter(VALUE self, VALUE key, VALUE modifier)
928 {
929 PDF *pdf = get_pdf(self);
930 const char *ret = NULL;
931
932 pdf_try {
933 ret = PDF_get_parameter(pdf, CHAR(key), NUM2DBL(modifier));
934 } pdf_catch;
935
936 return rb_str_new2(ret);
937 }
938
939
940 /* Deprecated, use PDF_pcos_get_string().. */
941 static VALUE
get_pdi_parameter(VALUE self,VALUE key,VALUE doc,VALUE page,VALUE reserved)942 get_pdi_parameter(VALUE self, VALUE key, VALUE doc, VALUE page, VALUE reserved)
943 {
944 PDF *pdf = get_pdf(self);
945 int len = -1;
946 const char *ret = NULL;
947
948
949 pdf_try {
950 ret = PDF_get_pdi_parameter(pdf, CHAR(key), NUM2INT(doc), NUM2INT(page), NUM2INT(reserved), &len);
951 } pdf_catch;
952
953 return rb_str_new(ret, len);
954 }
955
956
957 /* Deprecated, use PDF_pcos_get_number().. */
958 static VALUE
get_pdi_value(VALUE self,VALUE key,VALUE doc,VALUE page,VALUE reserved)959 get_pdi_value(VALUE self, VALUE key, VALUE doc, VALUE page, VALUE reserved)
960 {
961 PDF *pdf = get_pdf(self);
962 double ret = 0;
963
964 pdf_try {
965 ret = PDF_get_pdi_value(pdf, CHAR(key), NUM2INT(doc), NUM2INT(page), NUM2INT(reserved));
966 } pdf_catch;
967
968 return rb_float_new(ret);
969 }
970
971
972 /* Get the value of some PDFlib parameter with numerical type. Returns: The numerical value of the parameter.. */
973 static VALUE
get_value(VALUE self,VALUE key,VALUE modifier)974 get_value(VALUE self, VALUE key, VALUE modifier)
975 {
976 PDF *pdf = get_pdf(self);
977 double ret = 0;
978
979 pdf_try {
980 ret = PDF_get_value(pdf, CHAR(key), NUM2DBL(modifier));
981 } pdf_catch;
982
983 return rb_float_new(ret);
984 }
985
986
987 /* Query detailed information about a loaded font. Returns: The value of some font property as requested by keyword.. */
988 static VALUE
info_font(VALUE self,VALUE font,VALUE keyword,VALUE optlist)989 info_font(VALUE self, VALUE font, VALUE keyword, VALUE optlist)
990 {
991 PDF *pdf = get_pdf(self);
992 double ret = 0;
993
994 pdf_try {
995 ret = PDF_info_font(pdf, NUM2INT(font), CHAR(keyword), CHAR(optlist));
996 } pdf_catch;
997
998 return rb_float_new(ret);
999 }
1000
1001
1002 /* Query information about a matchbox on the current page. Returns: The value of some matchbox parameter as requested by keyword.. */
1003 static VALUE
info_matchbox(VALUE self,VALUE boxname,VALUE num,VALUE keyword)1004 info_matchbox(VALUE self, VALUE boxname, VALUE num, VALUE keyword)
1005 {
1006 PDF *pdf = get_pdf(self);
1007 double ret = 0;
1008
1009 pdf_try {
1010 ret = PDF_info_matchbox(pdf, CHAR(boxname), 0, NUM2INT(num), CHAR(keyword));
1011 } pdf_catch;
1012
1013 return rb_float_new(ret);
1014 }
1015
1016
1017 /* Retrieve table information related to the most recently placed table instance. Returns: The value of some table parameter as requested by keyword.. */
1018 static VALUE
info_table(VALUE self,VALUE table,VALUE keyword)1019 info_table(VALUE self, VALUE table, VALUE keyword)
1020 {
1021 PDF *pdf = get_pdf(self);
1022 double ret = 0;
1023
1024 pdf_try {
1025 ret = PDF_info_table(pdf, NUM2INT(table), CHAR(keyword));
1026 } pdf_catch;
1027
1028 return rb_float_new(ret);
1029 }
1030
1031
1032 /* Query the current state of a Textflow. Returns: The value of some Textflow parameter as requested by keyword.. */
1033 static VALUE
info_textflow(VALUE self,VALUE textflow,VALUE keyword)1034 info_textflow(VALUE self, VALUE textflow, VALUE keyword)
1035 {
1036 PDF *pdf = get_pdf(self);
1037 double ret = 0;
1038
1039 pdf_try {
1040 ret = PDF_info_textflow(pdf, NUM2INT(textflow), CHAR(keyword));
1041 } pdf_catch;
1042
1043 return rb_float_new(ret);
1044 }
1045
1046
1047 /* Query geometrical sizes of a textline at position (0, 0).. */
1048 static VALUE
info_textline(VALUE self,VALUE text,VALUE keyword,VALUE optlist)1049 info_textline(VALUE self, VALUE text, VALUE keyword, VALUE optlist)
1050 {
1051 PDF *pdf = get_pdf(self);
1052 double ret = 0;
1053
1054 pdf_try {
1055 ret = PDF_info_textline(pdf, CHAR(text), LEN(text), CHAR(keyword), CHAR(optlist));
1056 } pdf_catch;
1057
1058 return rb_float_new(ret);
1059 }
1060
1061
1062 /* Perform textline formatting and query the resulting metrics. Returns: The value of some text metric value as requested by keyword.. */
1063 static VALUE
initgraphics(VALUE self)1064 initgraphics(VALUE self)
1065 {
1066 PDF *pdf = get_pdf(self);
1067 pdf_try {
1068 PDF_initgraphics(pdf);
1069 } pdf_catch;
1070
1071 return self;
1072 }
1073
1074
1075 /* Draw a line from the current point to another point.. */
1076 static VALUE
lineto(VALUE self,VALUE x,VALUE y)1077 lineto(VALUE self, VALUE x, VALUE y)
1078 {
1079 PDF *pdf = get_pdf(self);
1080 pdf_try {
1081 PDF_lineto(pdf, NUM2DBL(x), NUM2DBL(y));
1082 } pdf_catch;
1083
1084 return self;
1085 }
1086
1087
1088 /* Search for a font and prepare it for later use. Returns: A font handle.. */
1089 static VALUE
load_font(VALUE self,VALUE fontname,VALUE encoding,VALUE optlist)1090 load_font(VALUE self, VALUE fontname, VALUE encoding, VALUE optlist)
1091 {
1092 PDF *pdf = get_pdf(self);
1093 int ret = 0;
1094
1095 pdf_try {
1096 ret = PDF_load_font(pdf, CHAR(fontname), 0, CHAR(encoding), CHAR(optlist));
1097 } pdf_catch;
1098
1099 return INT2NUM(ret);
1100 }
1101
1102
1103 /* Search for an ICC profile, and prepare it for later use. Returns: A profile handle.. */
1104 static VALUE
load_iccprofile(VALUE self,VALUE profilename,VALUE optlist)1105 load_iccprofile(VALUE self, VALUE profilename, VALUE optlist)
1106 {
1107 PDF *pdf = get_pdf(self);
1108 int ret = 0;
1109
1110 pdf_try {
1111 ret = PDF_load_iccprofile(pdf, CHAR(profilename), 0, CHAR(optlist));
1112 } pdf_catch;
1113
1114 return INT2NUM(ret);
1115 }
1116
1117
1118 /* Open a disk-based or virtual image file subject to various options. Returns: An image handle, or -1 (in PHP: 0) on error.. */
1119 static VALUE
load_image(VALUE self,VALUE imagetype,VALUE filename,VALUE optlist)1120 load_image(VALUE self, VALUE imagetype, VALUE filename, VALUE optlist)
1121 {
1122 PDF *pdf = get_pdf(self);
1123 int ret = 0;
1124
1125 pdf_try {
1126 ret = PDF_load_image(pdf, CHAR(imagetype), CHAR(filename), 0, CHAR(optlist));
1127 } pdf_catch;
1128
1129 return INT2NUM(ret);
1130 }
1131
1132
1133 /* Find a built-in spot color name, or make a named spot color from the current fill color. Returns: A color handle.. */
1134 static VALUE
makespotcolor(VALUE self,VALUE spotname)1135 makespotcolor(VALUE self, VALUE spotname)
1136 {
1137 PDF *pdf = get_pdf(self);
1138 int ret = 0;
1139
1140 pdf_try {
1141 ret = PDF_makespotcolor(pdf, CHAR(spotname), 0);
1142 } pdf_catch;
1143
1144 return INT2NUM(ret);
1145 }
1146
1147
1148 /* Set the current point.. */
1149 static VALUE
moveto(VALUE self,VALUE x,VALUE y)1150 moveto(VALUE self, VALUE x, VALUE y)
1151 {
1152 PDF *pdf = get_pdf(self);
1153 pdf_try {
1154 PDF_moveto(pdf, NUM2DBL(x), NUM2DBL(y));
1155 } pdf_catch;
1156
1157 return self;
1158 }
1159
1160
1161 /* Open a disk-based or virtual PDF document and prepare it for later use. Returns: A PDI document handle.. */
1162 static VALUE
open_pdi_document(VALUE self,VALUE filename,VALUE optlist)1163 open_pdi_document(VALUE self, VALUE filename, VALUE optlist)
1164 {
1165 PDF *pdf = get_pdf(self);
1166 int ret = 0;
1167
1168 pdf_try {
1169 ret = PDF_open_pdi_document(pdf, CHAR(filename), 0, CHAR(optlist));
1170 } pdf_catch;
1171
1172 return INT2NUM(ret);
1173 }
1174
1175
1176 /* Prepare a page for later use with PDF_fit_pdi_page(). Returns: A page handle.. */
1177 static VALUE
open_pdi_page(VALUE self,VALUE doc,VALUE pagenumber,VALUE optlist)1178 open_pdi_page(VALUE self, VALUE doc, VALUE pagenumber, VALUE optlist)
1179 {
1180 PDF *pdf = get_pdf(self);
1181 int ret = 0;
1182
1183 pdf_try {
1184 ret = PDF_open_pdi_page(pdf, NUM2INT(doc), NUM2INT(pagenumber), CHAR(optlist));
1185 } pdf_catch;
1186
1187 return INT2NUM(ret);
1188 }
1189
1190
1191 /* Get the value of a pCOS path with type number or boolean. Returns: The numerical value of the object identified by the pCOS path.. */
1192 static VALUE
pcos_get_number(VALUE self,VALUE doc,VALUE path)1193 pcos_get_number(VALUE self, VALUE doc, VALUE path)
1194 {
1195 PDF *pdf = get_pdf(self);
1196 double ret = 0;
1197
1198 pdf_try {
1199 ret = PDF_pcos_get_number(pdf, NUM2INT(doc), "%s", CHAR(path));
1200 } pdf_catch;
1201
1202 return rb_float_new(ret);
1203 }
1204
1205
1206 /* Get the value of a pCOS path with type name, string or boolean. Returns: A string with the value of the object identified by the pCOS path.. */
1207 static VALUE
pcos_get_string(VALUE self,VALUE doc,VALUE path)1208 pcos_get_string(VALUE self, VALUE doc, VALUE path)
1209 {
1210 PDF *pdf = get_pdf(self);
1211 const char *ret = NULL;
1212
1213 pdf_try {
1214 ret = PDF_pcos_get_string(pdf, NUM2INT(doc), "%s", CHAR(path));
1215 } pdf_catch;
1216
1217 return rb_str_new2(ret);
1218 }
1219
1220
1221 /* Get the contents of a pCOS path with type stream, fstream, or string. Returns: The unencrypted data contained in the stream or string.. */
1222 static VALUE
pcos_get_stream(VALUE self,VALUE doc,VALUE optlist,VALUE path)1223 pcos_get_stream(VALUE self, VALUE doc, VALUE optlist, VALUE path)
1224 {
1225 PDF *pdf = get_pdf(self);
1226 int length = -1;
1227 const char *ret = NULL;
1228
1229
1230 pdf_try {
1231 ret = PDF_pcos_get_stream(pdf, NUM2INT(doc), &length, CHAR(optlist), "%s", CHAR(path));
1232 } pdf_catch;
1233
1234 return rb_str_new(ret, length);
1235 }
1236
1237
1238 /* Process certain elements of an imported PDF document. Returns: -1 (in PHP: 0) on error, and 1 otherwise.. */
1239 static VALUE
process_pdi(VALUE self,VALUE doc,VALUE page,VALUE optlist)1240 process_pdi(VALUE self, VALUE doc, VALUE page, VALUE optlist)
1241 {
1242 PDF *pdf = get_pdf(self);
1243 int ret = 0;
1244
1245 pdf_try {
1246 ret = PDF_process_pdi(pdf, NUM2INT(doc), NUM2INT(page), CHAR(optlist));
1247 } pdf_catch;
1248
1249 return INT2NUM(ret);
1250 }
1251
1252
1253 /* Draw a rectangle.. */
1254 static VALUE
rect(VALUE self,VALUE x,VALUE y,VALUE width,VALUE height)1255 rect(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
1256 {
1257 PDF *pdf = get_pdf(self);
1258 pdf_try {
1259 PDF_rect(pdf, NUM2DBL(x), NUM2DBL(y), NUM2DBL(width), NUM2DBL(height));
1260 } pdf_catch;
1261
1262 return self;
1263 }
1264
1265
1266 /* Restore the most recently saved graphics state from the stack.. */
1267 static VALUE
restore(VALUE self)1268 restore(VALUE self)
1269 {
1270 PDF *pdf = get_pdf(self);
1271 pdf_try {
1272 PDF_restore(pdf);
1273 } pdf_catch;
1274
1275 return self;
1276 }
1277
1278
1279 /* Resume a page to add more content to it.. */
1280 static VALUE
resume_page(VALUE self,VALUE optlist)1281 resume_page(VALUE self, VALUE optlist)
1282 {
1283 PDF *pdf = get_pdf(self);
1284 pdf_try {
1285 PDF_resume_page(pdf, CHAR(optlist));
1286 } pdf_catch;
1287
1288 return self;
1289 }
1290
1291
1292 /* Rotate the coordinate system.. */
1293 static VALUE
rotate(VALUE self,VALUE phi)1294 rotate(VALUE self, VALUE phi)
1295 {
1296 PDF *pdf = get_pdf(self);
1297 pdf_try {
1298 PDF_rotate(pdf, NUM2DBL(phi));
1299 } pdf_catch;
1300
1301 return self;
1302 }
1303
1304
1305 /* Save the current graphics state to a stack.. */
1306 static VALUE
save(VALUE self)1307 save(VALUE self)
1308 {
1309 PDF *pdf = get_pdf(self);
1310 pdf_try {
1311 PDF_save(pdf);
1312 } pdf_catch;
1313
1314 return self;
1315 }
1316
1317
1318 /* Scale the coordinate system.. */
1319 static VALUE
scale(VALUE self,VALUE sx,VALUE sy)1320 scale(VALUE self, VALUE sx, VALUE sy)
1321 {
1322 PDF *pdf = get_pdf(self);
1323 pdf_try {
1324 PDF_scale(pdf, NUM2DBL(sx), NUM2DBL(sy));
1325 } pdf_catch;
1326
1327 return self;
1328 }
1329
1330
1331 /* Activate a graphics state object.. */
1332 static VALUE
set_gstate(VALUE self,VALUE gstate)1333 set_gstate(VALUE self, VALUE gstate)
1334 {
1335 PDF *pdf = get_pdf(self);
1336 pdf_try {
1337 PDF_set_gstate(pdf, NUM2INT(gstate));
1338 } pdf_catch;
1339
1340 return self;
1341 }
1342
1343
1344 /* Like PDF_set_info(), but with explicit string length.. */
1345 static VALUE
set_info(VALUE self,VALUE key,VALUE value)1346 set_info(VALUE self, VALUE key, VALUE value)
1347 {
1348 PDF *pdf = get_pdf(self);
1349 pdf_try {
1350 PDF_set_info2(pdf, CHAR(key), CHAR(value), LEN(value));
1351 } pdf_catch;
1352
1353 return self;
1354 }
1355
1356
1357 /* Define hierarchical, group, and lock conditions among layers (requires PDF 1.5).. */
1358 static VALUE
set_layer_dependency(VALUE self,VALUE type,VALUE optlist)1359 set_layer_dependency(VALUE self, VALUE type, VALUE optlist)
1360 {
1361 PDF *pdf = get_pdf(self);
1362 pdf_try {
1363 PDF_set_layer_dependency(pdf, CHAR(type), CHAR(optlist));
1364 } pdf_catch;
1365
1366 return self;
1367 }
1368
1369
1370 /* Set some PDFlib parameter with string type.. */
1371 static VALUE
set_parameter(VALUE self,VALUE key,VALUE value)1372 set_parameter(VALUE self, VALUE key, VALUE value)
1373 {
1374 PDF *pdf = get_pdf(self);
1375 pdf_try {
1376 PDF_set_parameter(pdf, CHAR(key), CHAR(value));
1377 } pdf_catch;
1378
1379 return self;
1380 }
1381
1382
1383 /* Set the position for text output on the page.. */
1384 static VALUE
set_text_pos(VALUE self,VALUE x,VALUE y)1385 set_text_pos(VALUE self, VALUE x, VALUE y)
1386 {
1387 PDF *pdf = get_pdf(self);
1388 pdf_try {
1389 PDF_set_text_pos(pdf, NUM2DBL(x), NUM2DBL(y));
1390 } pdf_catch;
1391
1392 return self;
1393 }
1394
1395
1396 /* Set the value of some PDFlib parameter with numerical type.. */
1397 static VALUE
set_value(VALUE self,VALUE key,VALUE value)1398 set_value(VALUE self, VALUE key, VALUE value)
1399 {
1400 PDF *pdf = get_pdf(self);
1401 pdf_try {
1402 PDF_set_value(pdf, CHAR(key), NUM2DBL(value));
1403 } pdf_catch;
1404
1405 return self;
1406 }
1407
1408
1409 /* Set the current color space and color.. */
1410 static VALUE
setcolor(VALUE self,VALUE fstype,VALUE colorspace,VALUE c1,VALUE c2,VALUE c3,VALUE c4)1411 setcolor(VALUE self, VALUE fstype, VALUE colorspace, VALUE c1, VALUE c2, VALUE c3, VALUE c4)
1412 {
1413 PDF *pdf = get_pdf(self);
1414 pdf_try {
1415 PDF_setcolor(pdf, CHAR(fstype), CHAR(colorspace), NUM2DBL(c1), NUM2DBL(c2), NUM2DBL(c3), NUM2DBL(c4));
1416 } pdf_catch;
1417
1418 return self;
1419 }
1420
1421
1422 /* Set the current dash pattern.. */
1423 static VALUE
setdash(VALUE self,VALUE b,VALUE w)1424 setdash(VALUE self, VALUE b, VALUE w)
1425 {
1426 PDF *pdf = get_pdf(self);
1427 pdf_try {
1428 PDF_setdash(pdf, NUM2DBL(b), NUM2DBL(w));
1429 } pdf_catch;
1430
1431 return self;
1432 }
1433
1434
1435 /* Set a dash pattern defined by an option list.. */
1436 static VALUE
setdashpattern(VALUE self,VALUE optlist)1437 setdashpattern(VALUE self, VALUE optlist)
1438 {
1439 PDF *pdf = get_pdf(self);
1440 pdf_try {
1441 PDF_setdashpattern(pdf, CHAR(optlist));
1442 } pdf_catch;
1443
1444 return self;
1445 }
1446
1447
1448 /* Set the flatness parameter.. */
1449 static VALUE
setflat(VALUE self,VALUE flatness)1450 setflat(VALUE self, VALUE flatness)
1451 {
1452 PDF *pdf = get_pdf(self);
1453 pdf_try {
1454 PDF_setflat(pdf, NUM2DBL(flatness));
1455 } pdf_catch;
1456
1457 return self;
1458 }
1459
1460
1461 /* Set the current font in the specified size.. */
1462 static VALUE
setfont(VALUE self,VALUE font,VALUE fontsize)1463 setfont(VALUE self, VALUE font, VALUE fontsize)
1464 {
1465 PDF *pdf = get_pdf(self);
1466 pdf_try {
1467 PDF_setfont(pdf, NUM2INT(font), NUM2DBL(fontsize));
1468 } pdf_catch;
1469
1470 return self;
1471 }
1472
1473
1474 /* Set the linecap parameter.. */
1475 static VALUE
setlinecap(VALUE self,VALUE linecap)1476 setlinecap(VALUE self, VALUE linecap)
1477 {
1478 PDF *pdf = get_pdf(self);
1479 pdf_try {
1480 PDF_setlinecap(pdf, NUM2INT(linecap));
1481 } pdf_catch;
1482
1483 return self;
1484 }
1485
1486
1487 /* Set the linejoin parameter.. */
1488 static VALUE
setlinejoin(VALUE self,VALUE linejoin)1489 setlinejoin(VALUE self, VALUE linejoin)
1490 {
1491 PDF *pdf = get_pdf(self);
1492 pdf_try {
1493 PDF_setlinejoin(pdf, NUM2INT(linejoin));
1494 } pdf_catch;
1495
1496 return self;
1497 }
1498
1499
1500 /* Set the current linewidth.. */
1501 static VALUE
setlinewidth(VALUE self,VALUE width)1502 setlinewidth(VALUE self, VALUE width)
1503 {
1504 PDF *pdf = get_pdf(self);
1505 pdf_try {
1506 PDF_setlinewidth(pdf, NUM2DBL(width));
1507 } pdf_catch;
1508
1509 return self;
1510 }
1511
1512
1513 /* Explicitly set the current transformation matrix.. */
1514 static VALUE
setmatrix(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d,VALUE e,VALUE f)1515 setmatrix(VALUE self, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e, VALUE f)
1516 {
1517 PDF *pdf = get_pdf(self);
1518 pdf_try {
1519 PDF_setmatrix(pdf, NUM2DBL(a), NUM2DBL(b), NUM2DBL(c), NUM2DBL(d), NUM2DBL(e), NUM2DBL(f));
1520 } pdf_catch;
1521
1522 return self;
1523 }
1524
1525
1526 /* Set the miter limit.. */
1527 static VALUE
setmiterlimit(VALUE self,VALUE miter)1528 setmiterlimit(VALUE self, VALUE miter)
1529 {
1530 PDF *pdf = get_pdf(self);
1531 pdf_try {
1532 PDF_setmiterlimit(pdf, NUM2DBL(miter));
1533 } pdf_catch;
1534
1535 return self;
1536 }
1537
1538
1539 /* Define a blend from the current fill color to another color (requires PDF 1.4 or above).. */
1540 static VALUE
shading(VALUE self,VALUE shtype,VALUE x_0,VALUE y_0,VALUE x_1,VALUE y_1,VALUE c_1,VALUE c_2,VALUE c_3,VALUE c_4,VALUE optlist)1541 shading(VALUE self, VALUE shtype, VALUE x_0, VALUE y_0, VALUE x_1, VALUE y_1, VALUE c_1, VALUE c_2, VALUE c_3, VALUE c_4, VALUE optlist)
1542 {
1543 PDF *pdf = get_pdf(self);
1544 int ret = 0;
1545
1546 pdf_try {
1547 ret = PDF_shading(pdf, CHAR(shtype), NUM2DBL(x_0), NUM2DBL(y_0), NUM2DBL(x_1), NUM2DBL(y_1), NUM2DBL(c_1), NUM2DBL(c_2), NUM2DBL(c_3), NUM2DBL(c_4), CHAR(optlist));
1548 } pdf_catch;
1549
1550 return INT2NUM(ret);
1551 }
1552
1553
1554 /* Define a shading pattern using a shading object (requires PDF 1.4). Returns: A shading handle.. */
1555 static VALUE
shading_pattern(VALUE self,VALUE shading,VALUE optlist)1556 shading_pattern(VALUE self, VALUE shading, VALUE optlist)
1557 {
1558 PDF *pdf = get_pdf(self);
1559 int ret = 0;
1560
1561 pdf_try {
1562 ret = PDF_shading_pattern(pdf, NUM2INT(shading), CHAR(optlist));
1563 } pdf_catch;
1564
1565 return INT2NUM(ret);
1566 }
1567
1568
1569 /* Fill an area with a shading, based on a shading object (requires PDF 1.4).. */
1570 static VALUE
shfill(VALUE self,VALUE shading)1571 shfill(VALUE self, VALUE shading)
1572 {
1573 PDF *pdf = get_pdf(self);
1574 pdf_try {
1575 PDF_shfill(pdf, NUM2INT(shading));
1576 } pdf_catch;
1577
1578 return self;
1579 }
1580
1581
1582 /* Same as PDF_show() but with explicit string length.. */
1583 static VALUE
show(VALUE self,VALUE text)1584 show(VALUE self, VALUE text)
1585 {
1586 PDF *pdf = get_pdf(self);
1587 pdf_try {
1588 PDF_show2(pdf, CHAR(text), LEN(text));
1589 } pdf_catch;
1590
1591 return self;
1592 }
1593
1594
1595 /* Same as PDF_show_xy() but with explicit string length.. */
1596 static VALUE
show_xy(VALUE self,VALUE text,VALUE x,VALUE y)1597 show_xy(VALUE self, VALUE text, VALUE x, VALUE y)
1598 {
1599 PDF *pdf = get_pdf(self);
1600 pdf_try {
1601 PDF_show_xy2(pdf, CHAR(text), LEN(text), NUM2DBL(x), NUM2DBL(y));
1602 } pdf_catch;
1603
1604 return self;
1605 }
1606
1607
1608 /* Skew the coordinate system.. */
1609 static VALUE
skew(VALUE self,VALUE alpha,VALUE beta)1610 skew(VALUE self, VALUE alpha, VALUE beta)
1611 {
1612 PDF *pdf = get_pdf(self);
1613 pdf_try {
1614 PDF_skew(pdf, NUM2DBL(alpha), NUM2DBL(beta));
1615 } pdf_catch;
1616
1617 return self;
1618 }
1619
1620
1621 /* Same as PDF_stringwidth(), but with explicit string length.. */
1622 static VALUE
stringwidth(VALUE self,VALUE text,VALUE font,VALUE fontsize)1623 stringwidth(VALUE self, VALUE text, VALUE font, VALUE fontsize)
1624 {
1625 PDF *pdf = get_pdf(self);
1626 double ret = 0;
1627
1628 pdf_try {
1629 ret = PDF_stringwidth2(pdf, CHAR(text), LEN(text), NUM2INT(font), NUM2DBL(fontsize));
1630 } pdf_catch;
1631
1632 return rb_float_new(ret);
1633 }
1634
1635
1636 /* Stroke the path with the current color and line width, and clear it.. */
1637 static VALUE
stroke(VALUE self)1638 stroke(VALUE self)
1639 {
1640 PDF *pdf = get_pdf(self);
1641 pdf_try {
1642 PDF_stroke(pdf);
1643 } pdf_catch;
1644
1645 return self;
1646 }
1647
1648
1649 /* Suspend the current page so that it can later be resumed.. */
1650 static VALUE
suspend_page(VALUE self,VALUE optlist)1651 suspend_page(VALUE self, VALUE optlist)
1652 {
1653 PDF *pdf = get_pdf(self);
1654 pdf_try {
1655 PDF_suspend_page(pdf, CHAR(optlist));
1656 } pdf_catch;
1657
1658 return self;
1659 }
1660
1661
1662 /* Translate the origin of the coordinate system.. */
1663 static VALUE
translate(VALUE self,VALUE tx,VALUE ty)1664 translate(VALUE self, VALUE tx, VALUE ty)
1665 {
1666 PDF *pdf = get_pdf(self);
1667 pdf_try {
1668 PDF_translate(pdf, NUM2DBL(tx), NUM2DBL(ty));
1669 } pdf_catch;
1670
1671 return self;
1672 }
1673 #endif /* defined(_WRAP_CODE) */
1674 #if defined(_WRAP_METHODS)
1675 rb_define_method(cPDFlib, "activate_item", activate_item, 1);
1676 rb_define_method(cPDFlib, "create_3dview", create_3dview, 2);
1677 rb_define_method(cPDFlib, "load_3ddata", load_3ddata, 2);
1678 rb_define_method(cPDFlib, "add_nameddest", add_nameddest, 2);
1679 rb_define_method(cPDFlib, "add_table_cell", add_table_cell, 5);
1680 rb_define_method(cPDFlib, "add_textflow", add_textflow, 3);
1681 rb_define_method(cPDFlib, "add_thumbnail", add_thumbnail, 1);
1682 rb_define_method(cPDFlib, "arc", arc, 5);
1683 rb_define_method(cPDFlib, "arcn", arcn, 5);
1684 rb_define_method(cPDFlib, "begin_document", begin_document, 2);
1685 rb_define_method(cPDFlib, "begin_font", begin_font, 8);
1686 rb_define_method(cPDFlib, "begin_glyph", begin_glyph, 6);
1687 rb_define_method(cPDFlib, "begin_item", begin_item, 2);
1688 rb_define_method(cPDFlib, "begin_layer", begin_layer, 1);
1689 rb_define_method(cPDFlib, "begin_page_ext", begin_page_ext, 3);
1690 rb_define_method(cPDFlib, "begin_pattern", begin_pattern, 5);
1691 rb_define_method(cPDFlib, "begin_template", begin_template, 2);
1692 rb_define_method(cPDFlib, "begin_template_ext", begin_template_ext, 3);
1693 rb_define_method(cPDFlib, "circle", circle, 3);
1694 rb_define_method(cPDFlib, "clip", clip, 0);
1695 rb_define_method(cPDFlib, "close_image", close_image, 1);
1696 rb_define_method(cPDFlib, "close_pdi", close_pdi, 1);
1697 rb_define_method(cPDFlib, "close_pdi_document", close_pdi_document, 1);
1698 rb_define_method(cPDFlib, "close_pdi_page", close_pdi_page, 1);
1699 rb_define_method(cPDFlib, "closepath", closepath, 0);
1700 rb_define_method(cPDFlib, "closepath_fill_stroke", closepath_fill_stroke, 0);
1701 rb_define_method(cPDFlib, "closepath_stroke", closepath_stroke, 0);
1702 rb_define_method(cPDFlib, "concat", concat, 6);
1703 rb_define_method(cPDFlib, "continue_text", continue_text, 1);
1704 rb_define_method(cPDFlib, "create_action", create_action, 2);
1705 rb_define_method(cPDFlib, "create_annotation", create_annotation, 6);
1706 rb_define_method(cPDFlib, "create_bookmark", create_bookmark, 2);
1707 rb_define_method(cPDFlib, "create_field", create_field, 7);
1708 rb_define_method(cPDFlib, "create_fieldgroup", create_fieldgroup, 2);
1709 rb_define_method(cPDFlib, "create_gstate", create_gstate, 1);
1710 rb_define_method(cPDFlib, "create_pvf", create_pvf, 3);
1711 rb_define_method(cPDFlib, "create_textflow", create_textflow, 2);
1712 rb_define_method(cPDFlib, "curveto", curveto, 6);
1713 rb_define_method(cPDFlib, "define_layer", define_layer, 2);
1714 rb_define_method(cPDFlib, "delete_pvf", delete_pvf, 1);
1715 rb_define_method(cPDFlib, "delete_table", delete_table, 2);
1716 rb_define_method(cPDFlib, "delete_textflow", delete_textflow, 1);
1717 rb_define_method(cPDFlib, "encoding_set_char", encoding_set_char, 4);
1718 rb_define_method(cPDFlib, "end_document", end_document, 1);
1719 rb_define_method(cPDFlib, "end_font", end_font, 0);
1720 rb_define_method(cPDFlib, "end_glyph", end_glyph, 0);
1721 rb_define_method(cPDFlib, "end_item", end_item, 1);
1722 rb_define_method(cPDFlib, "end_layer", end_layer, 0);
1723 rb_define_method(cPDFlib, "end_mc", end_mc, 0);
1724 rb_define_method(cPDFlib, "end_page_ext", end_page_ext, 1);
1725 rb_define_method(cPDFlib, "end_pattern", end_pattern, 0);
1726 rb_define_method(cPDFlib, "end_template", end_template, 0);
1727 rb_define_method(cPDFlib, "endpath", endpath, 0);
1728 rb_define_method(cPDFlib, "fill", fill, 0);
1729 rb_define_method(cPDFlib, "fill_imageblock", fill_imageblock, 4);
1730 rb_define_method(cPDFlib, "fill_pdfblock", fill_pdfblock, 4);
1731 rb_define_method(cPDFlib, "fill_stroke", fill_stroke, 0);
1732 rb_define_method(cPDFlib, "fill_textblock", fill_textblock, 4);
1733 rb_define_method(cPDFlib, "fit_image", fit_image, 4);
1734 rb_define_method(cPDFlib, "fit_pdi_page", fit_pdi_page, 4);
1735 rb_define_method(cPDFlib, "fit_table", fit_table, 6);
1736 rb_define_method(cPDFlib, "fit_textflow", fit_textflow, 6);
1737 rb_define_method(cPDFlib, "fit_textline", fit_textline, 4);
1738 rb_define_method(cPDFlib, "get_apiname", get_apiname, 0);
1739 rb_define_method(cPDFlib, "get_buffer", get_buffer, 0);
1740 rb_define_method(cPDFlib, "get_errmsg", get_errmsg, 0);
1741 rb_define_method(cPDFlib, "get_errnum", get_errnum, 0);
1742 rb_define_method(cPDFlib, "get_parameter", get_parameter, 2);
1743 rb_define_method(cPDFlib, "get_pdi_parameter", get_pdi_parameter, 4);
1744 rb_define_method(cPDFlib, "get_pdi_value", get_pdi_value, 4);
1745 rb_define_method(cPDFlib, "get_value", get_value, 2);
1746 rb_define_method(cPDFlib, "info_font", info_font, 3);
1747 rb_define_method(cPDFlib, "info_matchbox", info_matchbox, 3);
1748 rb_define_method(cPDFlib, "info_table", info_table, 2);
1749 rb_define_method(cPDFlib, "info_textflow", info_textflow, 2);
1750 rb_define_method(cPDFlib, "info_textline", info_textline, 3);
1751 rb_define_method(cPDFlib, "initgraphics", initgraphics, 0);
1752 rb_define_method(cPDFlib, "lineto", lineto, 2);
1753 rb_define_method(cPDFlib, "load_font", load_font, 3);
1754 rb_define_method(cPDFlib, "load_iccprofile", load_iccprofile, 2);
1755 rb_define_method(cPDFlib, "load_image", load_image, 3);
1756 rb_define_method(cPDFlib, "makespotcolor", makespotcolor, 1);
1757 rb_define_method(cPDFlib, "moveto", moveto, 2);
1758 rb_define_method(cPDFlib, "open_pdi_document", open_pdi_document, 2);
1759 rb_define_method(cPDFlib, "open_pdi_page", open_pdi_page, 3);
1760 rb_define_method(cPDFlib, "pcos_get_number", pcos_get_number, 2);
1761 rb_define_method(cPDFlib, "pcos_get_string", pcos_get_string, 2);
1762 rb_define_method(cPDFlib, "pcos_get_stream", pcos_get_stream, 3);
1763 rb_define_method(cPDFlib, "process_pdi", process_pdi, 3);
1764 rb_define_method(cPDFlib, "rect", rect, 4);
1765 rb_define_method(cPDFlib, "restore", restore, 0);
1766 rb_define_method(cPDFlib, "resume_page", resume_page, 1);
1767 rb_define_method(cPDFlib, "rotate", rotate, 1);
1768 rb_define_method(cPDFlib, "save", save, 0);
1769 rb_define_method(cPDFlib, "scale", scale, 2);
1770 rb_define_method(cPDFlib, "set_gstate", set_gstate, 1);
1771 rb_define_method(cPDFlib, "set_info", set_info, 2);
1772 rb_define_method(cPDFlib, "set_layer_dependency", set_layer_dependency, 2);
1773 rb_define_method(cPDFlib, "set_parameter", set_parameter, 2);
1774 rb_define_method(cPDFlib, "set_text_pos", set_text_pos, 2);
1775 rb_define_method(cPDFlib, "set_value", set_value, 2);
1776 rb_define_method(cPDFlib, "setcolor", setcolor, 6);
1777 rb_define_method(cPDFlib, "setdash", setdash, 2);
1778 rb_define_method(cPDFlib, "setdashpattern", setdashpattern, 1);
1779 rb_define_method(cPDFlib, "setflat", setflat, 1);
1780 rb_define_method(cPDFlib, "setfont", setfont, 2);
1781 rb_define_method(cPDFlib, "setlinecap", setlinecap, 1);
1782 rb_define_method(cPDFlib, "setlinejoin", setlinejoin, 1);
1783 rb_define_method(cPDFlib, "setlinewidth", setlinewidth, 1);
1784 rb_define_method(cPDFlib, "setmatrix", setmatrix, 6);
1785 rb_define_method(cPDFlib, "setmiterlimit", setmiterlimit, 1);
1786 rb_define_method(cPDFlib, "shading", shading, 10);
1787 rb_define_method(cPDFlib, "shading_pattern", shading_pattern, 2);
1788 rb_define_method(cPDFlib, "shfill", shfill, 1);
1789 rb_define_method(cPDFlib, "show", show, 1);
1790 rb_define_method(cPDFlib, "show_xy", show_xy, 3);
1791 rb_define_method(cPDFlib, "skew", skew, 2);
1792 rb_define_method(cPDFlib, "stringwidth", stringwidth, 3);
1793 rb_define_method(cPDFlib, "stroke", stroke, 0);
1794 rb_define_method(cPDFlib, "suspend_page", suspend_page, 1);
1795 rb_define_method(cPDFlib, "translate", translate, 2);
1796 #endif /* defined(_WRAP_METHODS)*/
1797