CVS update: php3/functions
| From: | steinm | Date: | Fri, 21 May 1999 08:14:07 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-5829@lists.php.net to get a copy of this message | ||
Date: Friday May 21, 1999 @ 4:14
Author: steinm
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv21574/functions
Modified Files:
cpdf.c php3_cpdf.h
Log Message:
- several bug fixes. First test has been succesful.
Index: php3/functions/cpdf.c
diff -u php3/functions/cpdf.c:1.1 php3/functions/cpdf.c:1.2
--- php3/functions/cpdf.c:1.1 Thu May 20 15:21:52 1999
+++ php3/functions/cpdf.c Fri May 21 04:14:06 1999
@@ -27,9 +27,11 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cpdf.c,v 1.1 1999/05/20 19:21:52 steinm Exp $ */
+/* $Id: cpdf.c,v 1.2 1999/05/21 08:14:06 steinm Exp $ */
+/* cpdflib.h -- C language API definitions for ClibPDF library
+ * Copyright (C) 1998 FastIO Systems, All Rights Reserved.
+*/
-
/* Note that there is no code from the cpdflib package in this file */
#if !PHP_31 && defined(THREAD_SAFE)
@@ -62,7 +64,7 @@
typedef struct cpdflib_global_struct{
int le_cpdf;
-} pdflib_global_struct;
+} cpdflib_global_struct;
# define CPDF_GLOBAL(a) cpdflib_globals->a
# define CPDF_TLS_VARS cpdflib_global_struct *cpdflib_globals=TlsGetValue(CPDFlibTls)
@@ -81,6 +83,8 @@
{"cpdf_open", php3_cpdf_open, NULL},
{"cpdf_close", php3_cpdf_close, NULL},
{"cpdf_page_init", php3_cpdf_page_init, NULL},
+ {"cpdf_begin_text", php3_cpdf_begin_text, NULL},
+ {"cpdf_end_text", php3_cpdf_end_text, NULL},
{"cpdf_show", php3_cpdf_show, NULL},
{"cpdf_show_xy", php3_cpdf_show_xy, NULL},
{"cpdf_set_font", php3_cpdf_set_font, NULL},
@@ -92,7 +96,6 @@
{"cpdf_set_text_pos", php3_cpdf_set_text_pos, NULL},
{"cpdf_set_char_spacing", php3_cpdf_set_char_spacing, NULL},
{"cpdf_set_word_spacing", php3_cpdf_set_word_spacing, NULL},
- {"cpdf_continue_text", php3_cpdf_continue_text, NULL},
{"cpdf_stringwidth", php3_cpdf_stringwidth, NULL},
{"cpdf_save", php3_cpdf_save, NULL},
{"cpdf_restore", php3_cpdf_restore, NULL},
@@ -125,10 +128,13 @@
{"cpdf_setrgbcolor_stroke", php3_cpdf_setrgbcolor_stroke,NULL},
{"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_save_to_file", php3_cpdf_save_to_file, NULL},
{NULL, NULL, NULL}
};
-php3_module_entry pdf_module_entry = {
+php3_module_entry cpdf_module_entry = {
"cpdf", cpdf_functions, php3_minit_cpdf, php3_mend_cpdf, NULL, NULL, php3_info_cpdf,
STANDARD_MODULE_PROPERTIES
};
@@ -263,29 +269,46 @@
}
/* }}} */
-/* {{{ proto int pdf_open(int compression)
+/* {{{ proto int cpdf_open(int compression [, string filename])
Opens a new pdf document */
void php3_cpdf_open(INTERNAL_FUNCTION_PARAMETERS) {
- pval *arg1;
- int id, type;
+ pval *arg1, *arg2;
+ int id, type, argc;
FILE *fp;
int *cpdf;
CPDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
+ argc = ARG_COUNT(ht);
+ switch(argc) {
+ case 1:
+ if (getParameters(ht, 1, &arg1) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+ case 2:
+ if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+ default:
+ WRONG_PARAM_COUNT;
}
convert_to_long(arg1);
cpdf_open(0);
+// *cpdf = 1;
if(!cpdf)
RETURN_FALSE;
if(arg1->value.lval == 1)
cpdf_enableCompression(YES);
else
cpdf_enableCompression(NO);
+
+ if(argc > 1) {
+ convert_to_string(arg2);
+ cpdf_setOutputFilename(arg2->value.str.val);
+ }
cpdf_init();
id = php3_list_insert(cpdf,CPDF_GLOBAL(le_cpdf));
@@ -319,7 +342,7 @@
}
/* }}} */
-/* {{{ proto void pdf_page_init(int pdfdoc, int pagenr, int orientation, int height, int width)
+/* {{{ proto void cpdf_page_init(int pdfdoc, int pagenr, int orientation, int height, int width)
Starts page */
void php3_cpdf_page_init(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2, *arg3, *arg4, *arg5;
@@ -341,22 +364,24 @@
id=arg1->value.lval;
pagenr=arg2->value.lval;
orientation=arg3->value.lval;
- height = arg4->value.dval;
- width = arg5->value.dval;
+ height = arg4->value.lval;
+ width = arg5->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;
}
- sprintf(buffer, "0 0 %d %d", height, width);
- cpdf_page_init(pdf, pagenr, orientation, buffer, buffer);
+ sprintf(buffer, "0 0 %d %d", width, height);
+fprintf(stderr, "%s\n", buffer);
+// cpdf_pageInit(pagenr, PORTRAIT, LETTER, LETTER);
+ cpdf_pageInit(pagenr, orientation, buffer, buffer);
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto void pdf_begin_text(int pdfdoc)
+/* {{{ proto void cpdf_begin_text(int pdfdoc)
Starts text section */
void php3_cpdf_begin_text(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1;
@@ -376,13 +401,13 @@
RETURN_FALSE;
}
- cpdf_begin_text(0);
+ cpdf_beginText(0);
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto void pdf_end_text(int pdfdoc)
+/* {{{ proto void cpdf_end_text(int pdfdoc)
Ends text section */
void php3_cpdf_end_text(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1;
@@ -402,7 +427,7 @@
RETURN_FALSE;
}
- cpdf_end_text(0);
+ cpdf_endText();
RETURN_TRUE;
}
@@ -458,7 +483,7 @@
RETURN_FALSE;
}
- cpdf_textShow(arg2->value.str.val);
+ cpdf_rawText((float) arg3->value.dval, (float) arg4->value.dval, 0.0,
arg2->value.str.val);
RETURN_TRUE;
}
@@ -495,6 +520,15 @@
case 2:
cpdf_setFont(arg2->value.str.val, "MacRomanEncoding", (float) arg3->value.dval);
break;
+ case 3:
+ cpdf_setFont(arg2->value.str.val, "MacExpertEncoding", (float)
arg3->value.dval);
+ break;
+ case 4:
+ cpdf_setFont(arg2->value.str.val, "WinAnsiEncoding", (float) arg3->value.dval);
+ break;
+ default:
+ cpdf_setFont(arg2->value.str.val, NULL, (float) arg3->value.dval);
+ break;
}
RETURN_TRUE;
@@ -844,7 +878,7 @@
RETURN_FALSE;
}
- cpdf_translate((float) arg2->value.dval, (float) arg3->value.dval);
+ cpdf_rawTranslate((float) arg2->value.dval, (float) arg3->value.dval);
RETURN_TRUE;
}
@@ -1112,7 +1146,7 @@
RETURN_FALSE;
}
- cpdf_moveto((float) arg2->value.dval, (float) arg3->value.dval);
+ cpdf_rawMoveto((float) arg2->value.dval, (float) arg3->value.dval);
RETURN_TRUE;
}
@@ -1144,7 +1178,7 @@
RETURN_FALSE;
}
- cpdf_curveto((float) arg2->value.dval,
+ cpdf_rawCurveto((float) arg2->value.dval,
(float) arg3->value.dval,
(float) arg4->value.dval,
(float) arg5->value.dval,
@@ -1177,7 +1211,7 @@
RETURN_FALSE;
}
- cpdf_lineto((float) arg2->value.dval, (float) arg3->value.dval);
+ cpdf_rawLineto((float) arg2->value.dval, (float) arg3->value.dval);
RETURN_TRUE;
}
@@ -1206,7 +1240,7 @@
RETURN_FALSE;
}
- cpdf_circle((float) arg2->value.dval, (float) arg3->value.dval, (float)
arg4->value.dval);
+ cpdf_rawCircle((float) arg2->value.dval, (float) arg3->value.dval, (float)
arg4->value.dval);
RETURN_TRUE;
}
@@ -1267,7 +1301,7 @@
RETURN_FALSE;
}
- cpdf_rect((float) arg2->value.dval,
+ cpdf_rawRect((float) arg2->value.dval,
(float) arg3->value.dval,
(float) arg4->value.dval,
(float) arg5->value.dval);
@@ -1630,9 +1664,9 @@
}
/* }}} */
-/* {{{ proto void pdf_add_outline(int pdfdoc, string text);
+/* {{{ proto void cpdf_add_outline(int pdfdoc, string text);
Add bookmark for current page */
-void php3_pdf_add_outline(INTERNAL_FUNCTION_PARAMETERS) {
+void php3_cpdf_add_outline(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2;
int id, type;
int *pdf;
@@ -1651,7 +1685,6 @@
RETURN_FALSE;
}
- PDF_add_outline(pdf, estrdup(arg2->value.str.val));
RETURN_TRUE;
}
@@ -1681,6 +1714,92 @@
}
cpdf_setPageTransition(arg2->value.lval, arg3->value.dval, arg4->value.dval, 0, 0);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array cpdf_finalize(int pdfdoc)
+ Creates pdf doc in memory */
+void php3_cpdf_finalize(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_finalizeAll();
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array cpdf_get_buffer(int pdfdoc)
+ Returns the internal memory stream as string */
+void php3_cpdf_get_buffer(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *arg1;
+ pval out_arr;
+ int id, type, lenght;
+ int *pdf;
+ char *buffer;
+ 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;
+ }
+
+ buffer = cpdf_getBufferForPDF(&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);
+}
+/* }}} */
+
+/* {{{ proto array cpdf_save_to_file(int pdfdoc, string filename)
+ Saves the internal memory stream to a file */
+void php3_cpdf_save_to_file(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *arg1, *arg2;
+ int id, type;
+ int *pdf;
+ CPDF_TLS_VARS;
+
+ if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(arg1);
+ convert_to_string(arg2);
+ 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_savePDFmemoryStreamToFile(arg2->value.str.val);
RETURN_TRUE;
}
Index: php3/functions/php3_cpdf.h
diff -u php3/functions/php3_cpdf.h:1.1 php3/functions/php3_cpdf.h:1.2
--- php3/functions/php3_cpdf.h:1.1 Thu May 20 15:21:52 1999
+++ php3/functions/php3_cpdf.h Fri May 21 04:14:06 1999
@@ -26,7 +26,7 @@
| Authors: Uwe Steinmann |
+----------------------------------------------------------------------+
*/
-/* $Id: php3_cpdf.h,v 1.1 1999/05/20 19:21:52 steinm Exp $ */
+/* $Id: php3_cpdf.h,v 1.2 1999/05/21 08:14:06 steinm Exp $ */
#ifndef _PHP3_CPDF_H
#define _PHP3_CPDF_H
@@ -48,6 +48,8 @@
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);
+extern void php3_cpdf_begin_text(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_cpdf_end_text(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_show(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_show_xy(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_cpdf_set_font(INTERNAL_FUNCTION_PARAMETERS);
@@ -94,6 +96,9 @@
extern void php3_cpdf_setrgbcolor(INTERNAL_FUNCTION_PARAMETERS);
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_save_to_file(INTERNAL_FUNCTION_PARAMETERS);
#else
#define cpdf_module_ptr NULL
#endif
--
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