CVS update: php3/functions
| From: | steinm | Date: | Fri, 28 May 1999 09:35:14 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6132@lists.php.net to get a copy of this message | ||
Date: Friday May 28, 1999 @ 5:35
Author: steinm
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv4400/functions
Modified Files:
cpdf.c hw.c php3_cpdf.h
Log Message:
- new functions, bugfixes
* set preference of pdf viewer
* include gdImage in pdf file
* fixed output to stdout
Index: php3/functions/cpdf.c
diff -u php3/functions/cpdf.c:1.7 php3/functions/cpdf.c:1.8
--- php3/functions/cpdf.c:1.7 Thu May 27 14:11:06 1999
+++ php3/functions/cpdf.c Fri May 28 05:35:13 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cpdf.c,v 1.7 1999/05/27 18:11:06 steinm Exp $ */
+/* $Id: cpdf.c,v 1.8 1999/05/28 09:35:13 steinm Exp $ */
/* cpdflib.h -- C language API definitions for ClibPDF library
* Copyright (C) 1998 FastIO Systems, All Rights Reserved.
*/
@@ -44,6 +44,9 @@
#include "head.h"
#include <math.h>
#include "php3_cpdf.h"
+#if HAVE_LIBGD13
+#include "gd.h"
+#endif
#if HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -84,6 +87,7 @@
{"cpdf_set_keywords", php3_cpdf_set_keywords, NULL},
{"cpdf_open", php3_cpdf_open, NULL},
{"cpdf_close", php3_cpdf_close, NULL},
+ {"cpdf_set_viewer_preferences", php3_cpdf_set_viewer_preferences,NULL},
{"cpdf_page_init", php3_cpdf_page_init, NULL},
{"cpdf_set_current_page", php3_cpdf_set_current_page, NULL},
{"cpdf_begin_text", php3_cpdf_begin_text, NULL},
@@ -122,6 +126,7 @@
{"cpdf_circle", php3_cpdf_circle, NULL},
{"cpdf_arc", php3_cpdf_arc, NULL},
{"cpdf_rect", php3_cpdf_rect, NULL},
+ {"cpdf_newpath", php3_cpdf_newpath, NULL},
{"cpdf_closepath", php3_cpdf_closepath, NULL},
{"cpdf_stroke", php3_cpdf_stroke, NULL},
{"cpdf_closepath_stroke", php3_cpdf_closepath_stroke, NULL},
@@ -137,9 +142,12 @@
{"cpdf_setrgbcolor", php3_cpdf_setrgbcolor, NULL},
{"cpdf_set_transition", php3_cpdf_set_transition, NULL},
{"cpdf_finalize", php3_cpdf_finalize, NULL},
- {"cpdf_get_buffer", php3_cpdf_get_buffer, NULL},
+ {"cpdf_output_buffer", php3_cpdf_output_buffer, NULL},
{"cpdf_save_to_file", php3_cpdf_save_to_file, NULL},
{"cpdf_import_jpeg", php3_cpdf_import_jpeg, NULL},
+#if HAVE_LIBGD13
+ {"cpdf_place_inline_image", php3_cpdf_place_inline_image, NULL},
+#endif
{"cpdf_set_annotation", php3_cpdf_set_annotation, NULL},
{"cpdf_add_outline", php3_cpdf_add_outline, NULL},
{"cpdf_set_action_url", php3_cpdf_set_action_url, NULL},
@@ -292,6 +300,37 @@
}
/* }}} */
+/* {{{ proto void cpdf_set_viewer_preferences(int pdfdoc, int pagemode)
+ How to show the document by the viewer */
+void php3_cpdf_set_viewer_preferences(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *argv[6];
+ int id, type, pagemode;
+ int argc;
+ int *pdf;
+ CPDF_TLS_VARS;
+
+ argc = ARG_COUNT(ht);
+ if(argc < 1 || argc > 2)
+ WRONG_PARAM_COUNT;
+ if (getParametersArray(ht, argc, argv) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_long(argv[0]);
+ convert_to_long(argv[1]);
+ id=argv[0]->value.lval;
+ pagemode=argv[1]->value.lval;
+ pdf = php3_list_find(id,&type);
+ if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) {
+ php3_error(E_WARNING,"Unable to find file identifier %d",id);
+ RETURN_FALSE;
+ }
+
+ cpdf_setViewerPreferences(pagemode, 0, 0, 0, 0, 0, 0, pagemode);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
/* {{{ proto int cpdf_open(int compression [, string filename])
Opens a new pdf document */
void php3_cpdf_open(INTERNAL_FUNCTION_PARAMETERS) {
@@ -330,6 +369,10 @@
if(argc > 1) {
convert_to_string(arg2);
+#if APACHE
+ if(strcmp(arg2->value.str.val, "-") == 0)
+ php3_error(E_WARNING,"Writing to stdout as described in the ClibPDF manual is not possible
if php3 is used as an Apache module. Write to a memory stream and use cpdf_output_buffer()
instead.");
+#endif
cpdf_setOutputFilename(arg2->value.str.val);
}
cpdf_init();
@@ -376,7 +419,7 @@
CPDF_TLS_VARS;
argc = ARG_COUNT(ht);
- if(argc < 5 || argc < 6)
+ if(argc < 5 || argc > 6)
WRONG_PARAM_COUNT;
if (getParametersArray(ht, argc, argv) == FAILURE)
WRONG_PARAM_COUNT;
@@ -1694,6 +1737,32 @@
}
/* }}} */
+/* {{{ proto void cpdf_newpath(int pdfdoc)
+ Starts new path */
+void php3_cpdf_newpath(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *arg1;
+ int id, type;
+ int *pdf;
+ CPDF_TLS_VARS;
+
+ if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(arg1);
+ id=arg1->value.lval;
+ pdf = php3_list_find(id,&type);
+ if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) {
+ php3_error(E_WARNING,"Unable to find file identifier %d",id);
+ RETURN_FALSE;
+ }
+
+ cpdf_newpath();
+
+ RETURN_TRUE;
+}
+/* }}} */
+
/* {{{ proto void cpdf_closepath(int pdfdoc)
Close path */
void php3_cpdf_closepath(INTERNAL_FUNCTION_PARAMETERS) {
@@ -2106,9 +2175,9 @@
}
/* }}} */
-/* {{{ proto array cpdf_get_buffer(int pdfdoc)
+/* {{{ proto array cpdf_output_buffer(int pdfdoc)
Returns the internal memory stream as string */
-void php3_cpdf_get_buffer(INTERNAL_FUNCTION_PARAMETERS) {
+void php3_cpdf_output_buffer(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1;
pval out_arr;
int id, type, lenght;
@@ -2129,13 +2198,10 @@
}
buffer = cpdf_getBufferForPDF(&lenght);
+ php3_header();
+ php3_write(buffer, lenght);
- /* Array for output */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- add_assoc_long(return_value, "Lenght", lenght);
- add_assoc_string(return_value, "Content", buffer, 1);
+ RETURN_TRUE;
}
/* }}} */
@@ -2160,6 +2226,11 @@
RETURN_FALSE;
}
+#if APACHE
+ if(strcmp(arg2->value.str.val, "-") == 0)
+ php3_error(E_WARNING,"Writing to stdout as described in the ClibPDF manual is not possible
if php3 is used as an Apache module. Use cpdf_output_buffer() instead.");
+#endif
+
cpdf_savePDFmemoryStreamToFile(arg2->value.str.val);
RETURN_TRUE;
@@ -2232,6 +2303,93 @@
RETURN_TRUE;
}
/* }}} */
+
+#if HAVE_LIBGD13
+/* {{{ proto void cpdf_place_inline_image(int pdfdoc, int gdimage, double x, double y, double
angle, fload width, float height, int gsave[, int mode])
+ Includes image */
+void php3_cpdf_place_inline_image(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *argv[11];
+ int id, gid, type, argc, mode=0;
+ int count, i, j, color;
+ float width, height;
+ int *pdf;
+ unsigned char *buffer, *ptr;
+ gdImagePtr im;
+ CPDF_TLS_VARS;
+
+ argc = ARG_COUNT(ht);
+ if((argc < 8) || (argc > 9))
+ WRONG_PARAM_COUNT;
+ if (getParametersArray(ht, argc, argv) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_long(argv[0]);
+ convert_to_long(argv[1]);
+ convert_to_double(argv[2]);
+ convert_to_double(argv[3]);
+ convert_to_double(argv[4]);
+ convert_to_double(argv[5]);
+ convert_to_double(argv[6]);
+ convert_to_long(argv[7]);
+ id=argv[0]->value.lval;
+ pdf = php3_list_find(id,&type);
+ if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) {
+ php3_error(E_WARNING,"Unable to find file identifier %d",id);
+ RETURN_FALSE;
+ }
+
+ gid=argv[1]->value.lval;
+ im = php3_list_find(gid, &type);
+ if (!im || type != php3i_get_le_gd()) {
+ php3_error(E_WARNING, "ImageColorAllocate: Unable to find image pointer");
+ RETURN_FALSE;
+ }
+
+ if(argc > 8) {
+ convert_to_long(argv[8]);
+ mode = argv[8]->value.lval;
+ }
+
+ count = 3 * im->sx * im->sy;
+ if(NULL == (buffer = (unsigned char *) emalloc(count)))
+ RETURN_FALSE;
+
+ ptr = buffer;
+ for(i=0; i<im->sy; i++) {
+ for(j=0; j<im->sx; j++) {
+ color = im->pixels[i][j];
+ *ptr++ = im->red[color];
+ *ptr++ = im->green[color];
+ *ptr++ = im->blue[color];
+ }
+ }
+
+ if(mode == 1)
+ cpdf_placeInLineImage(buffer, count,
+ (float) argv[2]->value.dval,
+ (float) argv[3]->value.dval,
+ (float) argv[4]->value.dval,
+ (float) argv[5]->value.dval,
+ (float) argv[6]->value.dval,
+ im->sx,
+ im->sy,
+ 8, 2, argv[7]->value.lval);
+ else
+ cpdf_rawPlaceInLineImage(buffer, count,
+ (float) argv[2]->value.dval,
+ (float) argv[3]->value.dval,
+ (float) argv[4]->value.dval,
+ (float) argv[5]->value.dval,
+ (float) argv[6]->value.dval,
+ im->sx,
+ im->sy,
+ 8, 2, argv[7]->value.lval);
+
+ efree(buffer);
+ RETURN_TRUE;
+}
+/* }}} */
+#endif
/* {{{ proto void cpdf_set_annotation(int pdfdoc, double xll, double yll, double xur, double xur,
string title, string text[, int mode])
Sets annotation */
Index: php3/functions/hw.c
diff -u php3/functions/hw.c:1.34 php3/functions/hw.c:1.35
--- php3/functions/hw.c:1.34 Wed May 26 14:58:04 1999
+++ php3/functions/hw.c Fri May 28 05:35:13 1999
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.34 1999/05/26 18:58:04 steinm Exp $ */
+/* $Id: hw.c,v 1.35 1999/05/28 09:35:13 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
@@ -2259,10 +2259,8 @@
Prints document */
void php3_hw_output_document(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1;
- int id, type, count;
+ int id, type;
hw_document *ptr;
- char *ptr1;
- int output=1;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
@@ -2276,13 +2274,8 @@
RETURN_FALSE;
}
- output = php3_header();
- ptr1 = ptr->data;
- count = 0;
- while(count < ptr->size) {
- php3_write(ptr1++, 1);
- count++;
- }
+ php3_header();
+ php3_write(ptr->data, ptr->size);
RETURN_TRUE;
}
Index: php3/functions/php3_cpdf.h
diff -u php3/functions/php3_cpdf.h:1.6 php3/functions/php3_cpdf.h:1.7
--- php3/functions/php3_cpdf.h:1.6 Thu May 27 14:11:06 1999
+++ php3/functions/php3_cpdf.h Fri May 28 05:35:14 1999
@@ -26,7 +26,7 @@
| Authors: Uwe Steinmann |
+----------------------------------------------------------------------+
*/
-/* $Id: php3_cpdf.h,v 1.6 1999/05/27 18:11:06 steinm Exp $ */
+/* $Id: php3_cpdf.h,v 1.7 1999/05/28 09:35:14 steinm Exp $ */
#ifndef _PHP3_CPDF_H
#define _PHP3_CPDF_H
@@ -46,6 +46,7 @@
extern void php3_cpdf_set_title(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_set_subject(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_set_keywords(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_cpdf_set_viewer_preferences(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_open(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_close(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_page_init(INTERNAL_FUNCTION_PARAMETERS);
@@ -88,6 +89,7 @@
extern void php3_cpdf_circle(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_arc(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_rect(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_cpdf_newpath(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_closepath(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_closepath_stroke(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_stroke(INTERNAL_FUNCTION_PARAMETERS);
@@ -105,10 +107,13 @@
extern void php3_cpdf_add_outline(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_set_transition(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_finalize(INTERNAL_FUNCTION_PARAMETERS);
-extern void php3_cpdf_get_buffer(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_cpdf_output_buffer(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_save_to_file(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_set_annotation(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_import_jpeg(INTERNAL_FUNCTION_PARAMETERS);
+#if HAVE_LIBGD13
+extern void php3_cpdf_place_inline_image(INTERNAL_FUNCTION_PARAMETERS);
+#endif
extern void php3_cpdf_set_action_url(INTERNAL_FUNCTION_PARAMETERS);
#else
#define cpdf_module_ptr NULL
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net