From a86e27db95dbc91bb8c4f2bf67a2f187ae2e6f2f Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 26 Feb 2000 11:58:49 +0000 Subject: [PATCH] - More function in php module --- NEWS | 1 + ext/pdf/pdf.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++- ext/pdf/php_pdf.h | 5 +++ 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index a03c2b55d1..296bc1e4e4 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ PHP 4.0 NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ???, Version 4.0 Beta 5 +- Add pdf_set_parameter(), pdf_skew(), pdf_show_boxed() (Uwe) - Fixed comparison of (string) "inf" with (string) "inf", which was erroneously returning false (Zeev) - Implemented default_charset and default_mimetype config directives (Stig) diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c index 692ab91a79..835bccd6e7 100644 --- a/ext/pdf/pdf.c +++ b/ext/pdf/pdf.c @@ -93,6 +93,10 @@ function_entry pdf_functions[] = { PHP_FE(pdf_end_page, NULL) PHP_FE(pdf_show, NULL) PHP_FE(pdf_show_xy, NULL) +#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20) + PHP_FE(pdf_show_boxed, NULL) + PHP_FE(pdf_skew, NULL) +#endif PHP_FE(pdf_set_font, NULL) PHP_FE(pdf_set_leading, NULL) PHP_FE(pdf_set_text_rendering, NULL) @@ -134,6 +138,7 @@ function_entry pdf_functions[] = { PHP_FE(pdf_closepath_fill_stroke, NULL) PHP_FE(pdf_endpath, NULL) PHP_FE(pdf_clip, NULL) + PHP_FE(pdf_set_parameter, NULL) PHP_FE(pdf_setgray_fill, NULL) PHP_FE(pdf_setgray_stroke, NULL) PHP_FE(pdf_setgray, NULL) @@ -223,7 +228,7 @@ static void pdf_efree(PDF *p, void *mem) { } #endif -#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10 +#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10) static size_t pdf_flushwrite(PDF *p, void *data, size_t size){ if(php_header()) return(php_write(data, size)); @@ -602,6 +607,40 @@ PHP_FUNCTION(pdf_show_xy) { } /* }}} */ +/* {{{ proto void pdf_show_boxed(int pdfdoc, string text, double x-koor, double y-koor, double width, double height, string mode) + Output text formated in a boxed */ +#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20) +PHP_FUNCTION(pdf_show_boxed) { + pval *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7; + int id, type; + PDF *pdf; + PDF_TLS_VARS; + + if (ARG_COUNT(ht) != 7 || getParameters(ht, 7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(arg2); + convert_to_double(arg3); + convert_to_double(arg4); + convert_to_double(arg5); + convert_to_double(arg6); + id=arg1->value.lval; + pdf = zend_list_find(id,&type); + if(!pdf || type!=PDF_GLOBAL(le_pdf)) { + php_error(E_WARNING,"Unable to find file identifier %d",id); + RETURN_FALSE; + } + + PDF_show_boxed(pdf, arg2->value.str.val, (float) arg3->value.dval, (float) arg4->value.dval, (float) arg5->value.dval, (float) arg6->value.dval, arg7->value.str.val, NULL); + + RETURN_TRUE; +} +#endif +/* }}} */ + + /* {{{ proto void pdf_set_font(int pdfdoc, string font, double size, string encoding [, int embed]) Select the current font face, size and encoding */ PHP_FUNCTION(pdf_set_font) { @@ -1198,6 +1237,36 @@ PHP_FUNCTION(pdf_rotate) { } /* }}} */ +/* {{{ proto void pdf_skew(int pdfdoc, double xangle, double yangle) + Skew the coordinate system */ +#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20) +PHP_FUNCTION(pdf_skew) { + pval *arg1, *arg2, *arg3; + int id, type; + PDF *pdf; + PDF_TLS_VARS; + + if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_double(arg2); + convert_to_double(arg3); + id=arg1->value.lval; + pdf = zend_list_find(id,&type); + if(!pdf || type!=PDF_GLOBAL(le_pdf)) { + php_error(E_WARNING,"Unable to find file identifier %d",id); + RETURN_FALSE; + } + + PDF_skew(pdf, (float) arg2->value.dval, (float) arg3->value.dval); + + RETURN_TRUE; +} +#endif +/* }}} */ + /* {{{ proto void pdf_setflat(int pdfdoc, double value) Sets flatness */ PHP_FUNCTION(pdf_setflat) { @@ -1775,6 +1844,34 @@ PHP_FUNCTION(pdf_clip) { } /* }}} */ +/* {{{ proto void pdf_set_parameter(int pdfdoc, string parameter, string value) + Sets arbitrary parameters */ +PHP_FUNCTION(pdf_set_parameter) { + pval *arg1, *arg2, *arg3; + int id, type; + PDF *pdf; + PDF_TLS_VARS; + + if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(arg2); + convert_to_string(arg3); + id=arg1->value.lval; + pdf = zend_list_find(id,&type); + if(!pdf || type!=PDF_GLOBAL(le_pdf)) { + php_error(E_WARNING,"Unable to find file identifier %d",id); + RETURN_FALSE; + } + + PDF_set_parameter(pdf, arg2->value.str.val, arg3->value.str.val); + + RETURN_TRUE; +} +/* }}} */ + /* {{{ proto void pdf_setgray_fill(int pdfdoc, double value) Sets filling color to gray value */ PHP_FUNCTION(pdf_setgray_fill) { diff --git a/ext/pdf/php_pdf.h b/ext/pdf/php_pdf.h index e707507eb8..c0840f2f54 100644 --- a/ext/pdf/php_pdf.h +++ b/ext/pdf/php_pdf.h @@ -58,6 +58,10 @@ PHP_FUNCTION(pdf_begin_page); PHP_FUNCTION(pdf_end_page); PHP_FUNCTION(pdf_show); PHP_FUNCTION(pdf_show_xy); +#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20) +PHP_FUNCTION(pdf_show_boxed); +PHP_FUNCTION(pdf_skew); +#endif PHP_FUNCTION(pdf_set_font); PHP_FUNCTION(pdf_get_font); PHP_FUNCTION(pdf_get_fontname); @@ -99,6 +103,7 @@ PHP_FUNCTION(pdf_fill_stroke); PHP_FUNCTION(pdf_closepath_fill_stroke); PHP_FUNCTION(pdf_endpath); PHP_FUNCTION(pdf_clip); +PHP_FUNCTION(pdf_set_parameter); PHP_FUNCTION(pdf_setgray_fill); PHP_FUNCTION(pdf_setgray_stroke); PHP_FUNCTION(pdf_setgray); -- 2.50.1