40
40
41
41
#include "php.h"
42
42
#include "php_globals.h"
43
+ #include "ext/standard/head.h"
43
44
44
45
#include <math.h>
45
46
@@ -224,6 +225,7 @@ static void pdf_efree(PDF *p, void *mem) {
224
225
static size_t pdf_flushwrite (PDF * p , void * data , size_t size ){
225
226
if (php_header ())
226
227
return (php_write (data , size ));
228
+ return 0 ;
227
229
}
228
230
#endif
229
231
@@ -238,6 +240,13 @@ PHP_MINIT_FUNCTION(pdf)
238
240
PHP_MINFO_FUNCTION (pdf ) {
239
241
/* need to use a PHPAPI function here because it is external module in windows */
240
242
php_printf ("pdflib %d.%02d<BR>" , PDF_get_majorversion (), PDF_get_minorversion ());
243
+ #if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20 )
244
+ php_printf ("The CJK fonts supported." );
245
+ #endif
246
+ #ifdef PDF_OPEN_MEM_SUPPORTED
247
+ php_printf ("Support for in memory pdf creation." );
248
+ #endif
249
+
241
250
#if PDFLIB_MINORVERSION > 0
242
251
php_printf ("The function pdf_put_image() and pdf_execute_image() are <B>not</B> available" );
243
252
#else
@@ -415,9 +424,7 @@ PHP_FUNCTION(pdf_open) {
415
424
WRONG_PARAM_COUNT ;
416
425
if (argc != 1 || zend_get_parameters_ex (1 , & file ) == FAILURE ) {
417
426
fp = NULL ;
418
- php3_printf ("No File\n" );
419
427
} else {
420
- php3_printf ("With File\n" );
421
428
ZEND_FETCH_RESOURCE (fp , FILE * , file , -1 , "File-Handle" , php_file_le_fopen ());
422
429
/* XXX should do anzend_list_addref for <fp> here! */
423
430
}
@@ -437,13 +444,17 @@ PHP_FUNCTION(pdf_open) {
437
444
pdf = PDF_new ();
438
445
#endif
439
446
440
- #if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10
447
+ #if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10 & defined PDF_OPEN_MEM_SUPPORTED
441
448
if (fp ) {
442
449
if (0 > PDF_open_fp (pdf , fp ))
443
450
RETURN_FALSE ;
444
451
} else {
452
+ #if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20 ) & defined PDF_OPEN_MEM_SUPPORTED
453
+ PDF_open_mem (pdf , pdf_flushwrite );
454
+ #else
445
455
if (0 > PDF_open_mem (pdf , pdf_flushwrite ))
446
456
RETURN_FALSE ;
457
+ #endif
447
458
}
448
459
#else
449
460
if (0 > PDF_open_fp (pdf , fp )) {
@@ -623,14 +634,22 @@ PHP_FUNCTION(pdf_set_font) {
623
634
convert_to_long (arg1 );
624
635
convert_to_string (arg2 );
625
636
convert_to_double (arg3 );
637
+ #if PDFLIB_MAJORVERSION >= 2
638
+ convert_to_string (arg4 );
639
+ #else
626
640
convert_to_long (arg4 );
641
+ #endif
642
+
627
643
id = arg1 -> value .lval ;
628
644
pdf = zend_list_find (id ,& type );
629
645
if (!pdf || type != PDF_GLOBAL (le_pdf )) {
630
646
php_error (E_WARNING ,"Unable to find file identifier %d" ,id );
631
647
RETURN_FALSE ;
632
648
}
633
-
649
+
650
+ #if PDFLIB_MAJORVERSION >= 2
651
+ font = PDF_findfont (pdf , arg2 -> value .str .val , arg4 -> value .str .val , embed );
652
+ #else
634
653
if ((arg4 -> value .lval > 5 ) || (arg4 -> value .lval < 0 )) {
635
654
php_error (E_WARNING ,"Font encoding set to 4" );
636
655
arg4 -> value .lval = 4 ;
@@ -656,7 +675,7 @@ PHP_FUNCTION(pdf_set_font) {
656
675
php_error (E_WARNING ,"Encoding out of range, using 0" );
657
676
font = PDF_findfont (pdf , arg2 -> value .str .val , "builtin" , embed );
658
677
}
659
-
678
+ #endif
660
679
if (font < 0 ) {
661
680
php_error (E_WARNING ,"Font %s not found" , arg2 -> value .str .val );
662
681
RETURN_FALSE ;
0 commit comments