--- pdf.c Mon Feb 21 10:23:07 2000
+++ /tmp/pdf.c Wed Mar 15 04:04:56 2000
@@ -92,6 +92,9 @@
PHP_FE(pdf_begin_page, NULL)
PHP_FE(pdf_end_page, NULL)
PHP_FE(pdf_show, NULL)
+#if (PDFLIB_MAJORVERSION >= 3)
+ PHP_FE(pdf_show_boxed, NULL)
+#endif
PHP_FE(pdf_show_xy, NULL)
PHP_FE(pdf_set_font, NULL)
PHP_FE(pdf_set_leading, NULL)
@@ -99,6 +102,7 @@
PHP_FE(pdf_set_horiz_scaling, NULL)
PHP_FE(pdf_set_text_rise, NULL)
#if PDFLIB_MAJORVERSION < 3 & PDFLIB_MINORVERSION < 30
+/* All Versions < 2.30 */
PHP_FE(pdf_set_text_matrix, NULL)
#endif
PHP_FE(pdf_set_text_pos, NULL)
@@ -187,7 +191,8 @@
if(outline) efree(outline);
}
-#if PDFLIB_MAJORVERSION > 1 & PDFLIB_MINORVERSION > 0
+#if (PDFLIB_MAJORVERSION == 2 && PDFLIB_MINORVERSION > 0) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.01 */
static void custom_errorhandler(PDF *p, int type, const char*shortmsg) {
switch (type){
case PDF_NonfatalError:
@@ -223,7 +228,8 @@
}
#endif
-#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10
+#if (PDFLIB_MAJORVERSION == 2 && PDFLIB_MINORVERSION >= 10) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.10 */
static size_t pdf_flushwrite(PDF *p, void *data, size_t size){
if(php_header())
return(php_write(data, size));
@@ -242,14 +248,16 @@
PHP_MINFO_FUNCTION(pdf) {
/* need to use a PHPAPI function here because it is external module in windows */
php_printf("pdflib %d.%02d
", PDF_get_majorversion(), PDF_get_minorversion());
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20)
+#if (PDFLIB_MAJORVERSION >= 3) || (PDFLIB_MAJORVERSION == 2 && PDFLIB_MINORVERSION >= 20)
+/* All Versions >= 2.20 */
php_printf("The CJK fonts supported.");
#endif
#ifdef PDF_OPEN_MEM_SUPPORTED
php_printf("Support for in memory pdf creation.");
#endif
-#if PDFLIB_MINORVERSION > 0
+#if (PDFLIB_MAJORVERSION == 2 && PDFLIB_MINORVERSION > 0) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.01 */
php_printf("The function pdf_put_image() and pdf_execute_image() are not available");
#else
php_printf("The function pdf_put_image() and pdf_execute_image() are available");
@@ -420,7 +428,8 @@
int argc;
PDF_TLS_VARS;
-#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10
+#if ((PDFLIB_MAJORVERSION == 2) && (PDFLIB_MINORVERSION >= 10)) || (PDFLIB_MAJORVERSION >= 3)
+/* Versions >= 2.10 */
argc = ARG_COUNT(ht);
if(argc > 1)
WRONG_PARAM_COUNT;
@@ -440,18 +449,21 @@
/* XXX should do anzend_list_addref for here! */
#endif
-#if PDFLIB_MAJORVERSION > 1 & PDFLIB_MINORVERSION > 0
+#if ((PDFLIB_MAJORVERSION == 2) && (PDFLIB_MINORVERSION >= 1)) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.01 */
pdf = PDF_new2(custom_errorhandler, pdf_emalloc, pdf_realloc, pdf_efree, NULL);
#else
pdf = PDF_new();
#endif
-#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10 & defined PDF_OPEN_MEM_SUPPORTED
+#if (PDFLIB_MAJORVERSION >= 3) || (PDFLIB_MAJORVERSION == 2 && PDFLIB_MINORVERSION >= 10 && defined PDF_OPEN_MEM_SUPPORTED)
+/* All Versions >= 2.10 */
if(fp) {
if (0 > PDF_open_fp(pdf, fp))
RETURN_FALSE;
} else {
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20) & defined PDF_OPEN_MEM_SUPPORTED
+#if (PDFLIB_MAJORVERSION >= 3) || (PDFLIB_MAJORVERSION >= 2 && PDFLIB_MINORVERSION >= 20 && defined PDF_OPEN_MEM_SUPPORTED)
+/* All Versions >= 2.20 */
PDF_open_mem(pdf, pdf_flushwrite);
#else
if (0 > PDF_open_mem(pdf, pdf_flushwrite))
@@ -578,6 +590,58 @@
}
/* }}} */
+/* {{{ proto void pdf_show_boxed(int pdfdoc, string text, float left, float bottom, float width,
+ float height, string hmode, string reserved)
+ Output text at constrained to a box defined by left, bottom, width, height
+ Options to fill are alignments (specified as a string in hmode):
+ left, right, center, justify, fulljustify
+ Returns false if the text could not fit in the region specified,
+ Returns true if the text was displayed...
+
+ */
+PHP_FUNCTION(pdf_show_boxed) {
+#if (PDFLIB_MAJORVERSION >= 3)
+ 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);
+ convert_to_string(arg7);
+ 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;
+ }
+
+ if (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_FALSE;
+ } else {
+ RETURN_TRUE;
+ }
+
+ /* Note: The 8th argument is supposed to be null, otherwise it balks */
+// RETURN_TRUE;
+#else
+ php_error(E_WARNING,"PDF_show_boxed() is not supported in this version of PDFlib %d",id);
+ RETURN FALSE;
+#endif
+}
+/* }}} */
+
/* {{{ proto void pdf_show_xy(int pdfdoc, string text, double x-koor, double y-koor)
Output text at position */
PHP_FUNCTION(pdf_show_xy) {
@@ -637,6 +701,7 @@
convert_to_string(arg2);
convert_to_double(arg3);
#if PDFLIB_MAJORVERSION >= 2
+/* All Versions >= 2.00 */
convert_to_string(arg4);
#else
convert_to_long(arg4);
@@ -650,6 +715,7 @@
}
#if PDFLIB_MAJORVERSION >= 2
+/* All Versions >= 2.00 */
font = PDF_findfont(pdf, arg2->value.str.val, arg4->value.str.val, embed);
#else
if((arg4->value.lval > 5) || (arg4->value.lval < 0)) {
@@ -877,7 +943,8 @@
}
/* }}} */
-#if PDFLIB_MAJORVERSION < 3 & PDFLIB_MINORVERSION < 30
+#if PDFLIB_MAJORVERSION < 3 && PDFLIB_MINORVERSION < 30
+/* All Versions < 2.30 */
/* {{{ proto void pdf_set_text_matrix(int pdfdoc, arry matrix)
Sets the text matrix */
PHP_FUNCTION(pdf_set_text_matrix) {
@@ -2252,7 +2319,8 @@
}
-#if PDFLIB_MINORVERSION == 0
+#if ((PDFLIB_MINORVERSION < 1) && (PDFLIB_MAJORVERSION < 3))
+/* All Versions <= 2.00 */
pdf_image = PDF_open_memory_image(pdf, buffer, im->sx, im->sy, 3, 8);
#else
pdf_image = PDF_open_image(pdf, "raw", "memory", buffer, im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL);
@@ -2348,7 +2416,8 @@
/* {{{ proto void pdf_put_image(int pdf, int pdfimage)
Stores image in the pdf document for later use */
PHP_FUNCTION(pdf_put_image) {
-#if PDFLIB_MINORVERSION > 0
+#if (PDFLIB_MINORVERSION > 0) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.01 */
#else
pval *arg1, *arg2;
int id, type;
@@ -2357,7 +2426,8 @@
#endif
PDF_TLS_VARS;
-#if PDFLIB_MINORVERSION > 0
+#if (PDFLIB_MINORVERSION > 0) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.01 */
php_error(E_WARNING, "Version 2.01 of pdflib does not need the pdf_put_image() anymore, check the docs!");
#else
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
@@ -2390,7 +2460,8 @@
/* {{{ proto void pdf_execute_image(int pdf, int pdfimage, int x, int y, int scale)
Places stored image in the pdf document */
PHP_FUNCTION(pdf_execute_image) {
-#if PDFLIB_MINORVERSION >= 01
+#if ((PDFLIB_MAJORVERSION == 2) && (PDFLIB_MINORVERSION >= 1)) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.01 */
#else
pval *arg1, *arg2, *arg3, *arg4, *arg5;
int id, type;
@@ -2399,7 +2470,8 @@
PDF_TLS_VARS;
#endif
-#if PDFLIB_MINORVERSION >= 01
+#if ((PDFLIB_MAJORVERSION == 2) && (PDFLIB_MINORVERSION >= 01)) || (PDFLIB_MAJORVERSION >= 3)
+/* All Versions >= 2.01 */
php_error(E_WARNING, "Version 2.01 of pdflib does not need the pdf_execute_image() anymore, check the docs!");
#else
if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {