[PHP-CVS] cvs: php4 /ext/pdf pdf.c php_pdf.h

2001-03-21 Thread Rainer Schaaf

rjs Wed Mar 21 12:55:35 2001 EDT

  Modified files:  
/php4/ext/pdf   pdf.c php_pdf.h 
  Log:
  Beta2 of PDFlib V4.0 will introduce on new function (PDF_place_pdi_page)
  and PDF_close_pdi_page will lose one parameter.
  These changes are done for the phpwrapper now.
  This has no impact on PDFlib V3.x.
  
  
Index: php4/ext/pdf/pdf.c
diff -u php4/ext/pdf/pdf.c:1.77 php4/ext/pdf/pdf.c:1.78
--- php4/ext/pdf/pdf.c:1.77 Fri Mar  9 18:21:38 2001
+++ php4/ext/pdf/pdf.c  Wed Mar 21 12:55:34 2001
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: pdf.c,v 1.77 2001/03/10 02:21:38 hirokawa Exp $ */
+/* $Id: pdf.c,v 1.78 2001/03/21 20:55:34 rjs Exp $ */
 /* Id: pdf.c,v 1.73 2001/02/26 06:07:11 andi Exp  */
 
 /* pdflib 2.02 ... 3.0x is subject to the ALADDIN FREE PUBLIC LICENSE.
@@ -185,6 +185,7 @@
PHP_FE(pdf_open_pdi, NULL)
PHP_FE(pdf_close_pdi, NULL)
PHP_FE(pdf_open_pdi_page, NULL)
+   PHP_FE(pdf_place_pdi_page, NULL)
PHP_FE(pdf_close_pdi_page, NULL)
PHP_FE(pdf_get_pdi_parameter, NULL)
PHP_FE(pdf_get_pdi_value, NULL)
@@ -293,7 +294,7 @@
 #else
php_info_print_table_row(2, "PDFlib GmbH Version", tmp );
 #endif
-   php_info_print_table_row(2, "Revision", "$Revision: 1.77 $" );
+   php_info_print_table_row(2, "Revision", "$Revision: 1.78 $" );
php_info_print_table_end();
 
 }
@@ -2684,24 +2685,50 @@
RETURN_LONG(pdi_image+PDFLIB_IMAGE_OFFSET);
 }
 
-/* {{{ proto void pdf_close_pdi_page(int pdf, int doc, int page);
+/* {{{ proto void pdf_place_pdi_page(int pdf, int page, double x, double y, double 
+sx, double sy)
+ * Place a PDF page with the lower left corner at (x, y), and scale it. */
+PHP_FUNCTION(pdf_place_pdi_page) {
+   zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6;
+   PDF *pdf;
+
+   if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, arg1, arg2, arg3, 
+arg4, arg5, arg6) == FAILURE) {
+   WRONG_PARAM_COUNT;
+   }
+
+   ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
+
+   convert_to_long_ex(arg2);
+   convert_to_double_ex(arg3);
+   convert_to_double_ex(arg4);
+   convert_to_double_ex(arg5);
+   convert_to_double_ex(arg6);
+
+   PDF_place_pdi_page(pdf,
+   Z_LVAL_PP(arg2)-PDFLIB_IMAGE_OFFSET,
+   (float) Z_DVAL_PP(arg3),
+   (float) Z_DVAL_PP(arg4),
+   (float) Z_DVAL_PP(arg5),
+   (float) Z_DVAL_PP(arg6));
+
+   RETURN_TRUE;
+}
+
+/* {{{ proto void pdf_close_pdi_page(int pdf, int page);
  * Close the page handle, and free all page-related resources. */
 PHP_FUNCTION(pdf_close_pdi_page) {
-   zval **arg1, **arg2, **arg3;
+   zval **arg1, **arg2;
PDF *pdf;
 
-   if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, arg1, arg2, arg3) == 
FAILURE) {
+   if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, arg1, arg2) == 
+FAILURE) {
WRONG_PARAM_COUNT;
}
 
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
 
convert_to_long_ex(arg2);
-   convert_to_long_ex(arg3);
 
PDF_close_pdi_page(pdf,
-   Z_LVAL_PP(arg2)-PDFLIB_PDI_OFFSET,
-   Z_LVAL_PP(arg3)-PDFLIB_IMAGE_OFFSET);
+   Z_LVAL_PP(arg2)-PDFLIB_IMAGE_OFFSET);
 
RETURN_TRUE;
 }
@@ -2854,7 +2881,7 @@
 PHP_FUNCTION(pdf_setcolor) {
zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7;
PDF *pdf;
-   int c1;
+   double c1;
 
if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, arg1, arg2, arg3, 
arg4, arg5, arg6, arg7) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -2870,11 +2897,11 @@
convert_to_double_ex(arg7);
 
if (0 == (strcmp(Z_STRVAL_PP(arg3), "spot"))) {
-   c1 = (int) Z_DVAL_PP(arg4)-PDFLIB_SPOT_OFFSET;
+   c1 = Z_DVAL_PP(arg4)-PDFLIB_SPOT_OFFSET;
} else if(0 == (strcmp(Z_STRVAL_PP(arg3), "pattern"))) {
-   c1 = (int) Z_DVAL_PP(arg4)-PDFLIB_PATTERN_OFFSET;
+   c1 = Z_DVAL_PP(arg4)-PDFLIB_PATTERN_OFFSET;
} else {
-   c1 = (float) Z_DVAL_PP(arg4);
+   c1 = Z_DVAL_PP(arg4);
}
 
PDF_setcolor(pdf,
Index: php4/ext/pdf/php_pdf.h
diff -u php4/ext/pdf/php_pdf.h:1.15 php4/ext/pdf/php_pdf.h:1.16
--- php4/ext/pdf/php_pdf.h:1.15 Thu Mar  1 11:51:54 2001
+++ php4/ext/pdf/php_pdf.h  Wed Mar 21 12:55:34 2001
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: php_pdf.h,v 1.15 2001/03/01 19:51:54 rjs Exp $ */
+/* $Id: php_pdf.h,v 1.16 2001/03/21 20:55:34 rjs Exp $ */
 
 #ifndef PHP_PDF_H
 #define PHP_PDF_H
@@ -151,6 +151,7 @@
 PHP_FUNCTION(pdf_open_pdi);
 PHP_FUNCTION(pdf_close_pdi);
 PHP_FUNCTION(pdf_open_pdi_page);
+PHP_FUNCTION(pdf_place_pdi_page);
 PHP_FUNCTION(pdf_close_pdi_page);
 PHP_FUNCTION(pdf_get_pdi_parameter);
 

[PHP-CVS] cvs: php4 /ext/pdf pdf.c php_pdf.h

2001-03-01 Thread Rainer Schaaf

rjs Thu Mar  1 11:51:54 2001 EDT

  Modified files:  
/php4/ext/pdf   pdf.c php_pdf.h 
  Log:
  - integrated new functions vor PDFlib V4.0 (beta1)
  - all functions accepting strings now support binary strings, by calling
the appropriate PDF*2() functions.
  
  

Index: php4/ext/pdf/pdf.c
diff -u php4/ext/pdf/pdf.c:1.73 php4/ext/pdf/pdf.c:1.74
--- php4/ext/pdf/pdf.c:1.73 Sun Feb 25 22:07:11 2001
+++ php4/ext/pdf/pdf.c  Thu Mar  1 11:51:53 2001
@@ -17,7 +17,8 @@
+--+
 */
 
-/* $Id: pdf.c,v 1.73 2001/02/26 06:07:11 andi Exp $ */
+/* $Id: pdf.c,v 1.74 2001/03/01 19:51:53 rjs Exp $ */
+/* Id: pdf.c,v 1.73 2001/02/26 06:07:11 andi Exp  */
 
 /* pdflib 2.02 ... 3.0x is subject to the ALADDIN FREE PUBLIC LICENSE.
Copyright (C) 1997-1999 Thomas Merz. 2000-2001 PDFlib GmbH */
@@ -57,6 +58,9 @@
  */
 #define PDFLIB_IMAGE_OFFSET1
 #define PDFLIB_FONT_OFFSET 1
+#define PDFLIB_PDI_OFFSET  1
+#define PDFLIB_PATTERN_OFFSET  1
+#define PDFLIB_SPOT_OFFSET 1
 
 function_entry pdf_functions[] = {
/* sorry for sorting this stuff like the pdflib manual,
@@ -109,12 +113,6 @@
PHP_FE(pdf_closepath_fill_stroke, NULL)
PHP_FE(pdf_clip, NULL)
PHP_FE(pdf_endpath, NULL)
-   PHP_FE(pdf_setgray_fill, NULL)
-   PHP_FE(pdf_setgray_stroke, NULL)
-   PHP_FE(pdf_setgray, NULL)
-   PHP_FE(pdf_setrgbcolor_fill, NULL)
-   PHP_FE(pdf_setrgbcolor_stroke, NULL)
-   PHP_FE(pdf_setrgbcolor, NULL)
PHP_FE(pdf_open_image_file, NULL)  /* new parameters: [char *stringpram, int 
intparam] */
PHP_FE(pdf_open_ccitt, NULL)/* new function */
PHP_FE(pdf_open_image, NULL)/* new function */
@@ -174,6 +172,33 @@
 #if HAVE_LIBGD13
PHP_FE(pdf_open_memory_image, NULL)
 #endif
+   /* depreciatet after V4.0 of PDFlib */
+   PHP_FE(pdf_setgray_fill, NULL)
+   PHP_FE(pdf_setgray_stroke, NULL)
+   PHP_FE(pdf_setgray, NULL)
+   PHP_FE(pdf_setrgbcolor_fill, NULL)
+   PHP_FE(pdf_setrgbcolor_stroke, NULL)
+   PHP_FE(pdf_setrgbcolor, NULL)
+
+#if (PDFLIB_MAJORVERSION = 4)
+/* support for new functions in PDFlib V4.0 */
+   PHP_FE(pdf_open_pdi, NULL)
+   PHP_FE(pdf_close_pdi, NULL)
+   PHP_FE(pdf_open_pdi_page, NULL)
+   PHP_FE(pdf_close_pdi_page, NULL)
+   PHP_FE(pdf_get_pdi_parameter, NULL)
+   PHP_FE(pdf_get_pdi_value, NULL)
+   PHP_FE(pdf_begin_pattern, NULL)
+   PHP_FE(pdf_end_pattern, NULL)
+   PHP_FE(pdf_begin_template, NULL)
+   PHP_FE(pdf_end_template, NULL)
+   PHP_FE(pdf_setcolor, NULL)
+   PHP_FE(pdf_makespotcolor, NULL)
+   PHP_FE(pdf_arcn, NULL)
+   PHP_FE(pdf_add_thumbnail, NULL)
+   PHP_FE(pdf_initgraphics, NULL)
+   PHP_FE(pdf_setmatrix, NULL)
+#endif /* PDFlib = V4 */
 
{NULL, NULL, NULL}
 };
@@ -263,14 +288,22 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "PDF Support", "enabled" );
+#if (PDFLIB_MAJORVERSION = 4)
+   php_info_print_table_row(2, "PDFlib GmbH Version", PDFLIB_VERSIONSTRING );
+#else
php_info_print_table_row(2, "PDFlib GmbH Version", tmp );
-   php_info_print_table_row(2, "Revision", "$Revision: 1.73 $" );
+#endif
+   php_info_print_table_row(2, "Revision", "$Revision: 1.74 $" );
php_info_print_table_end();
 
 }
 
 PHP_MINIT_FUNCTION(pdf)
 {
+   if ((PDF_get_majorversion() != PDFLIB_MAJORVERSION) ||
+   (PDF_get_minorversion() != PDFLIB_MINORVERSION)) {
+   php_error(E_ERROR,"PDFlib error: Version mismatch in wrapper code");
+   }
le_pdf = zend_register_list_destructors_ex(_free_pdf_doc, NULL, "pdf object", 
module_number);
 
/* this does something like setlocale("C", ...) in PDFlib 3.x */
@@ -469,7 +502,7 @@
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
 
convert_to_string_ex(arg2);
-   PDF_show(pdf, Z_STRVAL_PP(arg2));
+   PDF_show2(pdf, Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2));
RETURN_TRUE;
 }
 /* }}} */
@@ -490,7 +523,7 @@
convert_to_string_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
-   PDF_show_xy(pdf, Z_STRVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) 
Z_DVAL_PP(arg4));
+   PDF_show_xy2(pdf, Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2), (float) 
+Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4));
RETURN_TRUE;
 }
 /* }}} */
@@ -803,7 +836,7 @@
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
 
convert_to_string_ex(arg2);
-   PDF_continue_text(pdf, Z_STRVAL_PP(arg2));
+   PDF_continue_text2(pdf, Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2));
RETURN_TRUE;
 }
 /* }}} */
@@ -843,7 +876,12 @@
convert_to_double_ex(arg4);
size = Z_DVAL_PP(arg4);
}
-   width = (double) PDF_stringwidth(pdf, Z_STRVAL_PP(arg2), 
font-PDFLIB_FONT_OFFSET, size);

[PHP-CVS] cvs: php4 /ext/pdf pdf.c php_pdf.h

2001-01-26 Thread Egon Schmid

eschmid Fri Jan 26 10:52:37 2001 EDT

  Modified files:  
/php4/ext/pdf   php_pdf.h pdf.c 
  Log:
  Fixed some protos.
  

Index: php4/ext/pdf/php_pdf.h
diff -u php4/ext/pdf/php_pdf.h:1.12 php4/ext/pdf/php_pdf.h:1.13
--- php4/ext/pdf/php_pdf.h:1.12 Fri Jan 26 00:20:23 2001
+++ php4/ext/pdf/php_pdf.h  Fri Jan 26 10:52:37 2001
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: php_pdf.h,v 1.12 2001/01/26 08:20:23 steinm Exp $ */
+/* $Id: php_pdf.h,v 1.13 2001/01/26 18:52:37 eschmid Exp $ */
 
 #ifndef PHP_PDF_H
 #define PHP_PDF_H
@@ -89,7 +89,7 @@
 PHP_FUNCTION(pdf_setrgbcolor_stroke);
 PHP_FUNCTION(pdf_setrgbcolor);
 PHP_FUNCTION(pdf_open_image_file);  /* new parameters: [char *stringpram, int 
intparam] */
-PHP_FUNCTION(pdf_open_CCITT);  /* new function */
+PHP_FUNCTION(pdf_open_ccitt);  /* new function */
 PHP_FUNCTION(pdf_open_image);  /* new function: checkit not yet completeted :( */
 PHP_FUNCTION(pdf_close_image);
 PHP_FUNCTION(pdf_place_image);
Index: php4/ext/pdf/pdf.c
diff -u php4/ext/pdf/pdf.c:1.66 php4/ext/pdf/pdf.c:1.67
--- php4/ext/pdf/pdf.c:1.66 Fri Jan 26 00:20:23 2001
+++ php4/ext/pdf/pdf.c  Fri Jan 26 10:52:37 2001
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: pdf.c,v 1.66 2001/01/26 08:20:23 steinm Exp $ */
+/* $Id: pdf.c,v 1.67 2001/01/26 18:52:37 eschmid Exp $ */
 
 /* pdflib 2.02 ... 3.0x is subject to the ALADDIN FREE PUBLIC LICENSE.
Copyright (C) 1997-1999 Thomas Merz. 2000-2001 PDFlib GmbH */
@@ -115,7 +115,7 @@
PHP_FE(pdf_setrgbcolor_stroke, NULL)
PHP_FE(pdf_setrgbcolor, NULL)
PHP_FE(pdf_open_image_file, NULL)  /* new parameters: [char *stringpram, int 
intparam] */
-   PHP_FE(pdf_open_CCITT, NULL)/* new function */
+   PHP_FE(pdf_open_ccitt, NULL)/* new function */
PHP_FE(pdf_open_image, NULL)/* new function */
PHP_FE(pdf_close_image, NULL)
PHP_FE(pdf_place_image, NULL)
@@ -375,9 +375,7 @@
 
 
 /* {{{ proto int pdf_open([int filedesc])
-   Opens a new pdf document. If filedesc is NULL, document is created in memory.
-   This is the old interface, only for compatibility 
-   use pdf_new + pdf_open_file instead */
+   Opens a new pdf document. If filedesc is NULL, document is created in memory. This 
+is the old interface, only for compatibility use pdf_new + pdf_open_file instead */
 PHP_FUNCTION(pdf_open) 
 {
zval **file;
@@ -506,7 +504,7 @@
 }
 /* }}} */
 
-/* {{{ proto int pdf_show_boxed(int pdfdoc, string text, double x-koor, double 
y-koor, double width, double height, string mode, [string feature])
+/* {{{ proto int pdf_show_boxed(int pdfdoc, string text, double x-koor, double 
+y-koor, double width, double height, string mode [, string feature])
Output text formated in a boxed */
 PHP_FUNCTION(pdf_show_boxed) 
 {
@@ -781,7 +779,7 @@
 /* }}} */
 
 /* {{{ proto void pdf_set_text_pos(int pdfdoc, double x, double y)
-   Set the position of text for the next pdf_show call */
+   Sets the position of text for the next pdf_show call */
 PHP_FUNCTION(pdf_set_text_pos) 
 {
zval **arg1, **arg2, **arg3;
@@ -820,7 +818,7 @@
 /* }}} */
 
 /* {{{ proto double pdf_stringwidth(int pdfdoc, string text [, int font, double size])
-   Returns width of text in current font*/
+   Returns width of text in current font */
 PHP_FUNCTION(pdf_stringwidth)
 {
zval **arg1, **arg2, **arg3, **arg4;
@@ -1515,7 +1513,7 @@
 /* }}} */
 
 /* {{{ proto void pdf_setrgbcolor_fill(int pdfdoc, double red, double green, double 
blue)
-   Sets filling color to rgb color value */
+   Sets filling color to RGB color value */
 PHP_FUNCTION(pdf_setrgbcolor_fill)
 {
zval **arg1, **arg2, **arg3, **arg4;
@@ -1536,7 +1534,7 @@
 /* }}} */
 
 /* {{{ proto void pdf_setrgbcolor_stroke(int pdfdoc, double red, double green, double 
blue)
-   Sets drawing color to rgb color value */
+   Sets drawing color to RGB color value */
 PHP_FUNCTION(pdf_setrgbcolor_stroke)
 {
zval **arg1, **arg2, **arg3, **arg4;
@@ -1557,7 +1555,7 @@
 /* }}} */
 
 /* {{{ proto void pdf_setrgbcolor(int pdfdoc, double red, double green, double blue)
-   Sets drawing and filling color to rgb color value */
+   Sets drawing and filling color to RGB color value */
 PHP_FUNCTION(pdf_setrgbcolor)
 {
zval **arg1, **arg2, **arg3, **arg4;
@@ -1577,8 +1575,8 @@
 }
 /* }}} */
 
-/* {{{ proto int pdf_add_bookmark(int pdfdoc, string text [, int parent, int open]);
-   Add bookmark for current page */
+/* {{{ proto int pdf_add_bookmark(int pdfdoc, string text [, int parent, int open])
+   Adds bookmark for current page */
 PHP_FUNCTION(pdf_add_bookmark)
 {
zval **arg1, **arg2, **arg3, **arg4;
@@ -1725,7 +1723,7 @@
 }
 
 /* {{{ proto int pdf_open_gif(int pdf, string giffile)
-   Opens a gif file and returns an image for placement in a pdf document */
+   Opens a GIF file and returns an