This is what I already submitted as a comment to the cpdf_text function. Maybe you can 
include this 
simple patch in one of the following releases... it would be great. Here's the text I 
submitted as 
comment:

Unfortunately there hasn't been anyone else adding the textBox feature to the php CPDF 
functions, so 
I had to it. ;)

Do the following, in order to get a cpdf_textbox function, so that you don't have to 
call the 
cpdf_text function for every single line of text you want to print.

Add the following line to <php-source-dir>/ext/cpdf/php_cpdf.h line 58:
PHP_FUNCTION(cpdf_textbox);

Add the following line to <php-source-dir>/ext/cpdf/cpdf.c line 96:
PHP_FE(cpdf_textbox, NULL)

Add the code block below to <php-source-dir>/ext/cpdf/cpdf.c somewhere after the 
cpdf_text function 
(i.e. line 847)

snip-----------

/*  {{{ proto void cpdf_textbox(int pdfdoc, double x-koor, double y-koor, double 
width, double 
height, double angle, double linespace, string text [, int alignmode [, float 
paragraphspacing [, 
int newlinemode]]]);
    Output a textbox */
PHP_FUNCTION(cpdf_textbox)
{
         pval *argv[11];
         int id, type, argc, mode=0;
         CPDFdoc *pdf;
        CPDFtboxAttr tbattr;
        
         argc = ZEND_NUM_ARGS();
         if((argc < 8) || (argc > 11))
                 WRONG_PARAM_COUNT;
         if (getParametersArray(ht, argc, argv) == FAILURE)
                 WRONG_PARAM_COUNT;
        
        convert_to_long(argv[0]);
        convert_to_double(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_string(argv[7]);
        
         id=argv[0]->value.lval;
         pdf = zend_list_find(id, &type);
         if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) {
                 php_error(E_WARNING, "Unable to find identifier %d", id);
                 RETURN_FALSE;
         }
        
        tbattr.alignmode = TBOX_LEFT;
        tbattr.NLmode = 0;
        tbattr.paragraphSpacing = 0.0;
        tbattr.noMark = 0;
        
        switch(argc) {
                case 9:
                        convert_to_long(argv[8]);
                        tbattr.alignmode = argv[8]->value.lval;
                         break;
                case 10:
                        convert_to_long(argv[8]);
                        convert_to_double(argv[9]);
                        tbattr.alignmode = argv[8]->value.lval;
                        tbattr.paragraphSpacing = (float) argv[9]->value.dval;
                        break;
                case 11:
                        convert_to_long(argv[8]);
                        convert_to_double(argv[9]);
                        convert_to_long(argv[10]);
                        tbattr.alignmode = argv[8]->value.lval;
                        tbattr.paragraphSpacing = (float) argv[9]->value.dval;
                        tbattr.NLmode = argv[10]->value.lval;
                        break;
        }
        
        cpdf_textBox(pdf,
                        (float) argv[1]->value.dval,    // x
                        (float) argv[2]->value.dval,    // y
                        (float) argv[3]->value.dval,    // width
                        (float) argv[4]->value.dval,    // height
                        (float) argv[5]->value.dval,    // angle
                        (float) argv[6]->value.dval,    // linespace
                        &tbattr,                        // Attributes prespecified
                        argv[7]->value.str.val);        // Text string
        
         RETURN_TRUE;
}
/* }}} */

snap-----------

Then recompile php with cpdf support and use the new function.
It has to be called in between the cpdf_begin_text and cpdf_end_text tags

cpdf_textbox(int pdfdoc, double x-koor, double y-koor, double width, double height, 
double angle, 
double linespace, string text [, int alignmode [, float paragraphspacing [, int 
newlinemode]]]);

Notes:

Alignmode aligns the text within the box:
0 -- left (default)
1 -- center
2 -- right
3 -- justify

Newline mode:
if non-zero, NL ("\n") is is a line break, if 0 reformatted (default 0)

Have fun with it. It works great for me.

regards,

lars


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to