cvs: php4 /ext/pdf/ pdf.c php_pdf.h

From: Date: Tue, 06 Jun 2000 19:59:29 +0000
Subject: cvs: php4 /ext/pdf/ pdf.c php_pdf.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-61@lists.php.net to get a copy of this message
steinm Tue Jun 6 12:59:29 2000 EDT Modified files: /php4/ext/pdf pdf.c php_pdf.h Log: - add functions pdf_get_value(), pdf_set_value(), pdf_get_parameter(), pdf_set_border_dash() - some prototype fixes Index: php4/ext/pdf/pdf.c diff -u php4/ext/pdf/pdf.c:1.40 php4/ext/pdf/pdf.c:1.41 --- php4/ext/pdf/pdf.c:1.40 Mon Jun 5 12:47:43 2000 +++ php4/ext/pdf/pdf.c Tue Jun 6 12:59:29 2000 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdf.c,v 1.40 2000/06/05 19:47:43 andi Exp $ */ +/* $Id: pdf.c,v 1.41 2000/06/06 19:59:29 steinm Exp $ */ /* pdflib 2.02 is subject to the ALADDIN FREE PUBLIC LICENSE. Copyright (C) 1997 Thomas Merz. */ @@ -135,6 +135,9 @@ PHP_FE(pdf_endpath, NULL) PHP_FE(pdf_clip, NULL) PHP_FE(pdf_set_parameter, NULL) + PHP_FE(pdf_get_parameter, NULL) + PHP_FE(pdf_set_value, NULL) + PHP_FE(pdf_get_value, NULL) PHP_FE(pdf_setgray_fill, NULL) PHP_FE(pdf_setgray_stroke, NULL) PHP_FE(pdf_setgray, NULL) @@ -142,6 +145,7 @@ PHP_FE(pdf_setrgbcolor_stroke, NULL) PHP_FE(pdf_setrgbcolor, NULL) PHP_FE(pdf_add_outline, NULL) + PHP_FALIAS(pdf_add_bookmark, pdf_add_outline, NULL) PHP_FE(pdf_set_transition, NULL) PHP_FE(pdf_set_duration, NULL) PHP_FE(pdf_open_jpeg, NULL) @@ -159,6 +163,7 @@ PHP_FE(pdf_add_annotation, NULL) PHP_FE(pdf_set_border_style, NULL) PHP_FE(pdf_set_border_color, NULL) + PHP_FE(pdf_set_border_dash, NULL) PHP_FE(pdf_get_image_height, NULL) PHP_FE(pdf_get_image_width, NULL) {NULL, NULL, NULL} @@ -260,8 +265,8 @@ return SUCCESS; } -/* {{{ proto bool pdf_set_info_creator(int info, string creator) - Fills the creator field of the info structure */ +/* {{{ proto bool pdf_set_info_creator(int pdfdoc, string creator) + Fills the creator field of the document */ PHP_FUNCTION(pdf_set_info_creator) { pval *arg1, *arg2; int id, type; @@ -289,8 +294,8 @@ /* }}} */ -/* {{{ proto bool pdf_set_info_title(int info, string title) - Fills the title field of the info structure */ +/* {{{ proto bool pdf_set_info_title(int pdfdoc, string title) + Fills the title field of the document */ PHP_FUNCTION(pdf_set_info_title) { pval *arg1, *arg2; int id, type; @@ -318,8 +323,8 @@ /* }}} */ -/* {{{ proto bool pdf_set_info_subject(int info, string subject) - Fills the subject field of the info structure */ +/* {{{ proto bool pdf_set_info_subject(int pdfdoc, string subject) + Fills the subject field of the document */ PHP_FUNCTION(pdf_set_info_subject) { pval *arg1, *arg2; int id, type; @@ -347,8 +352,8 @@ /* }}} */ -/* {{{ proto bool pdf_set_info_author(int info, string author) - Fills the author field of the info structure */ +/* {{{ proto bool pdf_set_info_author(int pdfdoc, string author) + Fills the author field of the document */ PHP_FUNCTION(pdf_set_info_author) { pval *arg1, *arg2; int id, type; @@ -376,8 +381,8 @@ /* }}} */ -/* {{{ proto bool pdf_set_info_keywords(int info, string keywords) - Fills the keywords field of the info structure */ +/* {{{ proto bool pdf_set_info_keywords(int pdfdoc, string keywords) + Fills the keywords field of the document */ PHP_FUNCTION(pdf_set_info_keywords) { pval *arg1, *arg2; int id, type; @@ -666,7 +671,7 @@ } /* }}} */ -/* {{{ proto string pdf_get_font(int pdfdoc) +/* {{{ proto int pdf_get_font(int pdfdoc) Gets the current font */ PHP_FUNCTION(pdf_get_font) { pval *arg1; @@ -719,7 +724,7 @@ } /* }}} */ -/* {{{ proto string pdf_get_fontsize(int pdfdoc) +/* {{{ proto double pdf_get_fontsize(int pdfdoc) Gets the current font size */ PHP_FUNCTION(pdf_get_fontsize) { pval *arg1; @@ -1785,7 +1790,7 @@ } /* }}} */ -/* {{{ proto void pdf_set_parameter(int pdfdoc, string parameter, string value) +/* {{{ proto void pdf_set_parameter(int pdfdoc, string key, string value) Sets arbitrary parameters */ PHP_FUNCTION(pdf_set_parameter) { pval *arg1, *arg2, *arg3; @@ -1813,6 +1818,92 @@ } /* }}} */ +/* {{{ proto string pdf_get_parameter(int pdfdoc, string key, double modifier) + Gets arbitrary parameters */ +PHP_FUNCTION(pdf_get_parameter) { + pval *arg1, *arg2, *arg3; + int id, type; + PDF *pdf; + char *value; + PDF_TLS_VARS; + + if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(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; + } + + value = PDF_get_parameter(pdf, arg2->value.str.val, arg3->value.dval); + + RETURN_STRING(value, 1); +} +/* }}} */ + +/* {{{ proto void pdf_set_value(int pdfdoc, string key, double value) + Sets arbitrary value */ +PHP_FUNCTION(pdf_set_value) { + pval *arg1, *arg2, *arg3; + int id, type; + PDF *pdf; + PDF_TLS_VARS; + + if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(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_set_value(pdf, arg2->value.str.val, arg3->value.dval); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto double pdf_get_value(int pdfdoc, string key, double modifier) + Gets arbitrary value */ +PHP_FUNCTION(pdf_get_value) { + pval *arg1, *arg2, *arg3; + int id, type; + PDF *pdf; + double value; + PDF_TLS_VARS; + + if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(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; + } + + value = PDF_get_value(pdf, arg2->value.str.val, arg3->value.dval); + + RETURN_DOUBLE(value); +} +/* }}} */ + /* {{{ proto void pdf_setgray_fill(int pdfdoc, double value) Sets filling color to gray value */ PHP_FUNCTION(pdf_setgray_fill) { @@ -2579,7 +2670,7 @@ /* }}} */ /* {{{ proto void pdf_set_border_style(int pdfdoc, string style, double width) - Set style of box surounded weblinks */ + Set style of box surounding all kinds of annotations and link */ PHP_FUNCTION(pdf_set_border_style) { pval *arg1, *arg2, *arg3; int id, type; @@ -2607,7 +2698,7 @@ /* }}} */ /* {{{ proto void pdf_set_border_color(int pdfdoc, double red, double green, double blue) - Set color of box surounded weblinks */ + Set color of box surounded all kinds of annotations and links */ PHP_FUNCTION(pdf_set_border_color) { pval *arg1, *arg2, *arg3, *arg4; int id, type; @@ -2630,6 +2721,34 @@ } PDF_set_border_color(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_set_border_dash(int pdfdoc, double black, double white) + Set the border dash style of all kinds of annotations and links */ +PHP_FUNCTION(pdf_set_border_dash) { + pval *arg1, *arg2, *arg3; + int id, type; + PDF *pdf; + PDF_TLS_VARS; + + if (ZEND_NUM_ARGS() != 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_set_border_dash(pdf, (float) arg2->value.dval, (float) arg3->value.dval); RETURN_TRUE; } Index: php4/ext/pdf/php_pdf.h diff -u php4/ext/pdf/php_pdf.h:1.7 php4/ext/pdf/php_pdf.h:1.8 --- php4/ext/pdf/php_pdf.h:1.7 Tue Mar 28 08:45:04 2000 +++ php4/ext/pdf/php_pdf.h Tue Jun 6 12:59:29 2000 @@ -26,7 +26,7 @@ | Authors: Uwe Steinmann | +----------------------------------------------------------------------+ */ -/* $Id: php_pdf.h,v 1.7 2000/03/28 16:45:04 steinm Exp $ */ +/* $Id: php_pdf.h,v 1.8 2000/06/06 19:59:29 steinm Exp $ */ #ifndef _PHP_PDF_H #define _PHP_PDF_H @@ -35,8 +35,8 @@ /* with version 2.20 of pdflib PDF_open_mem isn't available unless the following define isn't there. - #define PDF_OPEN_MEM_SUPPORTED */ +#define PDF_OPEN_MEM_SUPPORTED #include <pdflib.h> extern int le_fp; @@ -104,6 +104,9 @@ PHP_FUNCTION(pdf_endpath); PHP_FUNCTION(pdf_clip); PHP_FUNCTION(pdf_set_parameter); +PHP_FUNCTION(pdf_get_parameter); +PHP_FUNCTION(pdf_set_value); +PHP_FUNCTION(pdf_get_value); PHP_FUNCTION(pdf_setgray_fill); PHP_FUNCTION(pdf_setgray_stroke); PHP_FUNCTION(pdf_setgray); @@ -130,6 +133,7 @@ PHP_FUNCTION(pdf_add_annotation); PHP_FUNCTION(pdf_set_border_style); PHP_FUNCTION(pdf_set_border_color); +PHP_FUNCTION(pdf_set_border_dash); PHP_FUNCTION(pdf_get_image_width); PHP_FUNCTION(pdf_get_image_height); #else

« previous php.cvs (#61) next »