Skip to content

Commit 385b6a2

Browse files
author
Uwe Steinmann
committed
- initial support for pdflib 2.20, little testing till now
1 parent f331c22 commit 385b6a2

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PHP 4.0 NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33

44
?? ?? ????, Version 4.0 Beta 4
5+
- Initital support for pdflib 2.20 (Uwe)
56
- Added PostgreSQL support for DB (Rui Hirokawa <louis@cityfujisawa.ne.jp>)
67
- Re-introduced "none" for disabling auto_prepend/append_file (Stig)
78
- Added DB/storage to PEAR

ext/pdf/pdf.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include "php.h"
4242
#include "php_globals.h"
43+
#include "ext/standard/head.h"
4344

4445
#include <math.h>
4546

@@ -224,6 +225,7 @@ static void pdf_efree(PDF *p, void *mem) {
224225
static size_t pdf_flushwrite(PDF *p, void *data, size_t size){
225226
if(php_header())
226227
return(php_write(data, size));
228+
return 0;
227229
}
228230
#endif
229231

@@ -238,6 +240,13 @@ PHP_MINIT_FUNCTION(pdf)
238240
PHP_MINFO_FUNCTION(pdf) {
239241
/* need to use a PHPAPI function here because it is external module in windows */
240242
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+
241250
#if PDFLIB_MINORVERSION > 0
242251
php_printf("The function pdf_put_image() and pdf_execute_image() are <B>not</B> available");
243252
#else
@@ -415,9 +424,7 @@ PHP_FUNCTION(pdf_open) {
415424
WRONG_PARAM_COUNT;
416425
if (argc != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
417426
fp = NULL;
418-
php3_printf("No File\n");
419427
} else {
420-
php3_printf("With File\n");
421428
ZEND_FETCH_RESOURCE(fp, FILE *, file, -1, "File-Handle", php_file_le_fopen());
422429
/* XXX should do anzend_list_addref for <fp> here! */
423430
}
@@ -437,13 +444,17 @@ PHP_FUNCTION(pdf_open) {
437444
pdf = PDF_new();
438445
#endif
439446

440-
#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10
447+
#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10 & defined PDF_OPEN_MEM_SUPPORTED
441448
if(fp) {
442449
if (0 > PDF_open_fp(pdf, fp))
443450
RETURN_FALSE;
444451
} 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
445455
if (0 > PDF_open_mem(pdf, pdf_flushwrite))
446456
RETURN_FALSE;
457+
#endif
447458
}
448459
#else
449460
if (0 > PDF_open_fp(pdf, fp)) {
@@ -623,14 +634,22 @@ PHP_FUNCTION(pdf_set_font) {
623634
convert_to_long(arg1);
624635
convert_to_string(arg2);
625636
convert_to_double(arg3);
637+
#if PDFLIB_MAJORVERSION >= 2
638+
convert_to_string(arg4);
639+
#else
626640
convert_to_long(arg4);
641+
#endif
642+
627643
id=arg1->value.lval;
628644
pdf = zend_list_find(id,&type);
629645
if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
630646
php_error(E_WARNING,"Unable to find file identifier %d",id);
631647
RETURN_FALSE;
632648
}
633-
649+
650+
#if PDFLIB_MAJORVERSION >= 2
651+
font = PDF_findfont(pdf, arg2->value.str.val, arg4->value.str.val, embed);
652+
#else
634653
if((arg4->value.lval > 5) || (arg4->value.lval < 0)) {
635654
php_error(E_WARNING,"Font encoding set to 4");
636655
arg4->value.lval = 4;
@@ -656,7 +675,7 @@ PHP_FUNCTION(pdf_set_font) {
656675
php_error(E_WARNING,"Encoding out of range, using 0");
657676
font = PDF_findfont(pdf, arg2->value.str.val, "builtin", embed);
658677
}
659-
678+
#endif
660679
if (font < 0) {
661680
php_error(E_WARNING,"Font %s not found", arg2->value.str.val);
662681
RETURN_FALSE;

ext/pdf/php_pdf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333

3434
#if HAVE_PDFLIB
3535

36+
/* with version 2.20 of pdflib PDF_open_mem isn't available unless
37+
the following define isn't there.
38+
#define PDF_OPEN_MEM_SUPPORTED
39+
*/
3640
#include <pdflib.h>
3741

3842
extern int le_fp;

0 commit comments

Comments
 (0)