1999-04-22 02:48:28 +00:00
/*
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2004-01-08 08:18:22 +00:00
| PHP Version 5 |
1999-04-22 02:48:28 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2004-01-08 08:18:22 +00:00
| Copyright ( c ) 1997 - 2004 The PHP Group |
1999-04-22 02:48:28 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2003-06-10 20:04:29 +00:00
| This source file is subject to version 3.0 of the PHP license , |
2001-01-03 16:05:45 +00:00
| that is bundled with this package in the file LICENSE , and is |
2003-06-10 20:04:29 +00:00
| available through the world - wide - web at the following url : |
| http : //www.php.net/license/3_0.txt. |
2001-01-03 16:05:45 +00:00
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world - wide - web , please send a note to |
| license @ php . net so we can mail you a copy immediately . |
1999-04-22 02:48:28 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Authors : Uwe Steinmann < Uwe . Steinmann @ fernuni - hagen . de > |
2001-02-01 07:07:10 +00:00
| Rainer Schaaf < rjs @ pdflib . com > |
1999-04-22 02:48:28 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2001-01-03 16:05:45 +00:00
*/
1999-04-22 02:48:28 +00:00
/* $Id$ */
2001-01-26 08:20:24 +00:00
/* pdflib 2.02 ... 3.0x is subject to the ALADDIN FREE PUBLIC LICENSE.
Copyright ( C ) 1997 - 1999 Thomas Merz . 2000 - 2001 PDFlib GmbH */
1999-04-22 02:48:28 +00:00
/* Note that there is no code from the pdflib package in this file */
2001-06-05 13:12:10 +00:00
/* {{{ includes
*/
2001-05-24 10:07:29 +00:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
1999-04-22 02:48:28 +00:00
# include "php.h"
2001-01-03 16:05:45 +00:00
# include "php_ini.h"
1999-08-05 16:25:10 +00:00
# include "php_globals.h"
2001-05-21 22:35:56 +00:00
# include "zend_list.h"
2000-02-15 08:10:32 +00:00
# include "ext/standard/head.h"
2000-04-06 21:07:44 +00:00
# include "ext/standard/info.h"
2000-11-03 20:11:38 +00:00
# include "ext/standard/file.h"
2002-03-15 21:03:08 +00:00
# include "php_streams.h"
1999-08-05 16:25:10 +00:00
# if HAVE_LIBGD13
2001-02-12 17:50:39 +00:00
# include "ext/gd/php_gd.h"
2002-08-30 02:41:52 +00:00
# if HAVE_GD_BUNDLED
# include "ext/gd/libgd/gd.h"
# else
1999-08-05 16:25:10 +00:00
# include "gd.h"
2002-08-30 02:41:52 +00:00
# endif
2001-05-21 21:06:08 +00:00
static int le_gd ;
1999-04-22 02:48:28 +00:00
# endif
1999-08-05 16:25:10 +00:00
# ifdef HAVE_UNISTD_H
1999-04-22 02:48:28 +00:00
# include <unistd.h>
# endif
2000-06-15 23:45:05 +00:00
# ifdef PHP_WIN32
1999-04-22 02:48:28 +00:00
# include <io.h>
# include <fcntl.h>
# endif
2001-06-05 13:12:10 +00:00
/* }}} */
1999-04-22 02:48:28 +00:00
2001-11-30 04:46:36 +00:00
# if HAVE_PDFLIB
2001-11-08 23:38:38 +00:00
1999-12-04 19:19:57 +00:00
# include "php_pdf.h"
1999-08-05 16:25:10 +00:00
2001-01-26 08:20:24 +00:00
static int le_pdf ;
2001-06-05 13:12:10 +00:00
/* {{{ constants
2001-01-26 08:20:24 +00:00
* to adopt the php way of error handling to PDFlib
* The image related functions in PDFlib return - 1 on error
* but they may return 0 ( FALSE ) in normal cases
* so this offset will repair this
*/
# define PDFLIB_IMAGE_OFFSET 1
# define PDFLIB_FONT_OFFSET 1
2001-03-01 19:51:55 +00:00
# define PDFLIB_PDI_OFFSET 1
# define PDFLIB_PATTERN_OFFSET 1
# define PDFLIB_SPOT_OFFSET 1
2001-06-05 13:12:10 +00:00
/* }}} */
1999-04-22 02:48:28 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ pdf_functions[]
*/
1999-04-22 02:48:28 +00:00
function_entry pdf_functions [ ] = {
2001-01-26 08:20:24 +00:00
PHP_FE ( pdf_new , NULL ) /* new function */
PHP_FE ( pdf_delete , NULL ) /* new function */
PHP_FE ( pdf_open_file , NULL ) /* new function */
PHP_FE ( pdf_get_buffer , NULL ) /* new function */
PHP_FE ( pdf_close , NULL )
PHP_FE ( pdf_begin_page , NULL )
PHP_FE ( pdf_end_page , NULL )
2001-08-21 13:33:16 +00:00
PHP_FE ( pdf_get_majorversion , NULL )
PHP_FE ( pdf_get_minorversion , NULL )
2001-01-26 08:20:24 +00:00
PHP_FE ( pdf_get_value , NULL )
PHP_FE ( pdf_set_value , NULL )
PHP_FE ( pdf_get_parameter , NULL )
PHP_FE ( pdf_set_parameter , NULL )
PHP_FE ( pdf_findfont , NULL ) /* new function */
PHP_FE ( pdf_setfont , NULL ) /* new function */
PHP_FE ( pdf_show , NULL )
PHP_FE ( pdf_show_xy , NULL )
PHP_FE ( pdf_continue_text , NULL )
PHP_FE ( pdf_show_boxed , NULL )
PHP_FE ( pdf_stringwidth , NULL ) /* new parameters: [int font, float size] */
PHP_FE ( pdf_set_text_pos , NULL )
PHP_FE ( pdf_setdash , NULL )
PHP_FE ( pdf_setpolydash , NULL ) /* new function: not yet finished */
PHP_FE ( pdf_setflat , NULL )
PHP_FE ( pdf_setlinejoin , NULL )
PHP_FE ( pdf_setlinecap , NULL )
PHP_FE ( pdf_setmiterlimit , NULL )
PHP_FE ( pdf_setlinewidth , NULL )
PHP_FE ( pdf_save , NULL )
PHP_FE ( pdf_restore , NULL )
PHP_FE ( pdf_translate , NULL )
PHP_FE ( pdf_scale , NULL )
PHP_FE ( pdf_rotate , NULL )
PHP_FE ( pdf_skew , NULL )
PHP_FE ( pdf_concat , NULL ) /* new function */
PHP_FE ( pdf_moveto , NULL )
PHP_FE ( pdf_lineto , NULL )
PHP_FE ( pdf_curveto , NULL )
PHP_FE ( pdf_circle , NULL )
PHP_FE ( pdf_arc , NULL )
PHP_FE ( pdf_rect , NULL )
PHP_FE ( pdf_closepath , NULL )
PHP_FE ( pdf_stroke , NULL )
PHP_FE ( pdf_closepath_stroke , NULL )
PHP_FE ( pdf_fill , NULL )
PHP_FE ( pdf_fill_stroke , NULL )
PHP_FE ( pdf_closepath_fill_stroke , NULL )
PHP_FE ( pdf_clip , NULL )
PHP_FE ( pdf_endpath , NULL )
PHP_FE ( pdf_open_image_file , NULL ) /* new parameters: [char *stringpram, int intparam] */
2001-01-26 18:52:38 +00:00
PHP_FE ( pdf_open_ccitt , NULL ) /* new function */
2001-01-26 08:20:24 +00:00
PHP_FE ( pdf_open_image , NULL ) /* new function */
PHP_FE ( pdf_close_image , NULL )
PHP_FE ( pdf_place_image , NULL )
PHP_FE ( pdf_add_bookmark , NULL )
PHP_FE ( pdf_set_info , NULL )
PHP_FE ( pdf_attach_file , NULL ) /* new function */
PHP_FE ( pdf_add_note , NULL ) /* new function */
PHP_FE ( pdf_add_pdflink , NULL )
PHP_FE ( pdf_add_locallink , NULL ) /* new function */
PHP_FE ( pdf_add_launchlink , NULL ) /* new function */
PHP_FE ( pdf_add_weblink , NULL )
PHP_FE ( pdf_set_border_style , NULL )
PHP_FE ( pdf_set_border_color , NULL )
PHP_FE ( pdf_set_border_dash , NULL )
/* End of the official PDFLIB V3.x API */
/* aliases for compatibility reasons */
PHP_FALIAS ( pdf_add_outline , pdf_add_bookmark , NULL )
/* old font handling */
PHP_FE ( pdf_set_font , NULL ) /* deprecated */
PHP_FE ( pdf_get_font , NULL ) /* deprecated */
PHP_FE ( pdf_get_fontname , NULL ) /* deprecated */
PHP_FE ( pdf_get_fontsize , NULL ) /* deprecated */
/* old way of starting a PDF document */
PHP_FE ( pdf_open , NULL ) /* deprecated */
/* old stuff for setting infos */
PHP_FE ( pdf_set_info_creator , NULL ) /* deprecated */
PHP_FE ( pdf_set_info_title , NULL ) /* deprecated */
PHP_FE ( pdf_set_info_subject , NULL ) /* deprecated */
PHP_FE ( pdf_set_info_author , NULL ) /* deprecated */
PHP_FE ( pdf_set_info_keywords , NULL ) /* deprecated */
PHP_FE ( pdf_set_leading , NULL ) /* deprecated */
PHP_FE ( pdf_set_text_rendering , NULL ) /* deprecated */
PHP_FE ( pdf_set_horiz_scaling , NULL ) /* deprecated */
PHP_FE ( pdf_set_text_rise , NULL ) /* deprecated */
PHP_FE ( pdf_set_char_spacing , NULL ) /* deprecated */
PHP_FE ( pdf_set_word_spacing , NULL ) /* deprecated */
PHP_FE ( pdf_set_transition , NULL ) /* deprecated */
PHP_FE ( pdf_set_duration , NULL ) /* deprecated */
PHP_FE ( pdf_get_image_height , NULL ) /* deprecated */
PHP_FE ( pdf_get_image_width , NULL ) /* deprecated */
/* old stuff for opening images */
PHP_FE ( pdf_open_jpeg , NULL ) /* deprecated */
PHP_FE ( pdf_open_tiff , NULL ) /* deprecated */
PHP_FE ( pdf_open_png , NULL ) /* deprecated */
PHP_FE ( pdf_open_gif , NULL ) /* deprecated */
/* some more stuff for compatibility */
PHP_FE ( pdf_add_annotation , NULL )
1999-08-05 16:25:10 +00:00
# if HAVE_LIBGD13
2001-01-26 08:20:24 +00:00
PHP_FE ( pdf_open_memory_image , NULL )
1999-08-05 16:25:10 +00:00
# endif
2001-03-01 19:51:55 +00:00
/* 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 )
2001-03-21 20:55:35 +00:00
PHP_FE ( pdf_place_pdi_page , NULL )
2001-03-01 19:51:55 +00:00
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 */
2001-01-26 08:20:24 +00:00
1999-04-22 02:48:28 +00:00
{ NULL , NULL , NULL }
} ;
2001-06-05 13:12:10 +00:00
/* }}} */
1999-04-22 02:48:28 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ pdf_module_entry
*/
1999-12-17 20:55:31 +00:00
zend_module_entry pdf_module_entry = {
2001-10-11 23:33:59 +00:00
STANDARD_MODULE_HEADER ,
2001-01-03 16:05:45 +00:00
" pdf " ,
pdf_functions ,
PHP_MINIT ( pdf ) ,
PHP_MSHUTDOWN ( pdf ) ,
NULL ,
NULL ,
PHP_MINFO ( pdf ) ,
2001-10-11 23:33:59 +00:00
NO_VERSION_YET ,
2001-01-03 16:05:45 +00:00
STANDARD_MODULE_PROPERTIES
1999-04-22 02:48:28 +00:00
} ;
2001-06-05 13:12:10 +00:00
/* }}} */
1999-04-22 02:48:28 +00:00
2000-05-23 09:33:51 +00:00
# ifdef COMPILE_DL_PDF
2000-05-02 00:30:36 +00:00
ZEND_GET_MODULE ( pdf )
1999-04-22 02:48:28 +00:00
# endif
2001-06-05 13:12:10 +00:00
/* {{{ _free_pdf_doc
*/
2001-07-31 05:44:11 +00:00
static void _free_pdf_doc ( zend_rsrc_list_entry * rsrc TSRMLS_DC )
1999-04-22 02:48:28 +00:00
{
2001-02-12 17:50:39 +00:00
PDF * pdf = ( PDF * ) rsrc - > ptr ;
2001-09-10 17:14:38 +00:00
PDF_delete ( pdf ) ;
1999-04-22 02:48:28 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
1999-04-22 02:48:28 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ custom_errorhandler
*/
2001-01-03 16:05:45 +00:00
static void custom_errorhandler ( PDF * p , int type , const char * shortmsg )
2000-11-01 19:55:13 +00:00
{
2003-01-19 00:45:53 +00:00
TSRMLS_FETCH ( ) ;
2003-08-11 02:32:17 +00:00
if ( type = = PDF_NonfatalError ) {
/*
* PDFlib warnings should be visible to the user .
* If he decides to live with PDFlib warnings
* he may use the PDFlib function
* pdf_set_parameter ( $ p , " warning " 0 ) to switch off
* the warnings inside PDFlib .
*/
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Internal PDFlib warning: %s " , shortmsg ) ;
return ;
} else {
/* give up in all other cases */
php_error_docref ( NULL TSRMLS_CC , E_ERROR , " PDFlib error: %s " , shortmsg ) ;
}
2000-02-02 11:18:06 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-02-02 11:18:06 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ pdf_emalloc
*/
2000-11-01 19:55:13 +00:00
static void * pdf_emalloc ( PDF * p , size_t size , const char * caller )
{
2000-02-02 11:18:06 +00:00
return ( emalloc ( size ) ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-02-02 11:18:06 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ pdf_realloc
*/
2000-11-01 19:55:13 +00:00
static void * pdf_realloc ( PDF * p , void * mem , size_t size , const char * caller )
{
2000-02-02 11:18:06 +00:00
return ( erealloc ( mem , size ) ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-02-02 11:18:06 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ pdf_efree
*/
2000-11-01 19:55:13 +00:00
static void pdf_efree ( PDF * p , void * mem )
{
2000-09-08 06:47:04 +00:00
efree ( mem ) ;
2000-02-02 11:18:06 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-02-02 11:18:06 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ pdf_flushwrite
*/
2000-11-01 19:55:13 +00:00
static size_t pdf_flushwrite ( PDF * p , void * data , size_t size )
{
2001-08-05 16:21:33 +00:00
TSRMLS_FETCH ( ) ;
return ( php_write ( data , size TSRMLS_CC ) ) ;
2000-02-02 11:18:06 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-02-02 11:18:06 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ PHP_MINFO_FUNCTION
*/
2000-04-06 21:07:44 +00:00
PHP_MINFO_FUNCTION ( pdf )
{
char tmp [ 32 ] ;
snprintf ( tmp , 31 , " %d.%02d " , PDF_get_majorversion ( ) , PDF_get_minorversion ( ) ) ;
2000-04-07 18:50:08 +00:00
tmp [ 31 ] = 0 ;
2000-04-06 21:07:44 +00:00
php_info_print_table_start ( ) ;
php_info_print_table_row ( 2 , " PDF Support " , " enabled " ) ;
2001-03-01 19:51:55 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
php_info_print_table_row ( 2 , " PDFlib GmbH Version " , PDFLIB_VERSIONSTRING ) ;
# else
2001-01-26 08:20:24 +00:00
php_info_print_table_row ( 2 , " PDFlib GmbH Version " , tmp ) ;
2001-03-01 19:51:55 +00:00
# endif
2001-02-01 07:07:10 +00:00
php_info_print_table_row ( 2 , " Revision " , " $Revision$ " ) ;
2000-04-06 21:07:44 +00:00
php_info_print_table_end ( ) ;
2000-02-15 08:10:32 +00:00
1999-08-05 16:25:10 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
1999-04-22 02:48:28 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ PHP_MINIT_FUNCTION
*/
2001-01-03 16:05:45 +00:00
PHP_MINIT_FUNCTION ( pdf )
{
2001-03-01 19:51:55 +00:00
if ( ( PDF_get_majorversion ( ) ! = PDFLIB_MAJORVERSION ) | |
( PDF_get_minorversion ( ) ! = PDFLIB_MINORVERSION ) ) {
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_ERROR , " PDFlib error: Version mismatch in wrapper code " ) ;
2001-03-01 19:51:55 +00:00
}
2001-02-01 07:07:10 +00:00
le_pdf = zend_register_list_destructors_ex ( _free_pdf_doc , NULL , " pdf object " , module_number ) ;
2001-01-26 08:20:24 +00:00
/* this does something like setlocale("C", ...) in PDFlib 3.x */
PDF_boot ( ) ;
1999-08-05 16:25:10 +00:00
return SUCCESS ;
1999-04-22 02:48:28 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
1999-04-22 02:48:28 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
2001-01-03 16:05:45 +00:00
PHP_MSHUTDOWN_FUNCTION ( pdf )
{
2001-01-26 08:20:24 +00:00
PDF_shutdown ( ) ;
2001-01-03 16:05:45 +00:00
return SUCCESS ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-06-07 18:06:11 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ _php_pdf_set_info
*/
2001-01-03 16:05:45 +00:00
static void _php_pdf_set_info ( INTERNAL_FUNCTION_PARAMETERS , char * field )
{
zval * * arg1 , * * arg2 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
2000-06-07 18:06:11 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2000-06-07 18:06:11 +00:00
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg2 ) ;
PDF_set_info ( pdf , field , Z_STRVAL_PP ( arg2 ) ) ;
2000-06-07 18:06:11 +00:00
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-06-07 18:06:11 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_info(resource pdfdoc, string fieldname, string value)
2001-01-03 16:05:45 +00:00
Fills an info field of the document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_set_info )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
PDF_set_info ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_info_creator(resource pdfdoc, string creator)
2001-01-03 16:05:45 +00:00
Fills the creator field of the document */
PHP_FUNCTION ( pdf_set_info_creator )
{
_php_pdf_set_info ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " Creator " ) ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_info_title(resource pdfdoc, string title)
2000-06-06 19:59:30 +00:00
Fills the title field of the document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_info_title )
{
_php_pdf_set_info ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " Title " ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_info_subject(resource pdfdoc, string subject)
2000-06-06 19:59:30 +00:00
Fills the subject field of the document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_info_subject )
{
_php_pdf_set_info ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " Subject " ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_info_author(resource pdfdoc, string author)
2000-06-06 19:59:30 +00:00
Fills the author field of the document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_info_author )
{
_php_pdf_set_info ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " Author " ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_info_keywords(resource pdfdoc, string keywords)
2000-06-06 19:59:30 +00:00
Fills the keywords field of the document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_set_info_keywords )
{
2001-01-03 16:05:45 +00:00
_php_pdf_set_info ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " Keywords " ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto resource pdf_open([resource filedesc])
2001-01-26 18:52:38 +00:00
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 */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_open )
2001-01-03 16:05:45 +00:00
{
zval * * file ;
2002-03-15 21:03:08 +00:00
FILE * fp = NULL ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
int argc = ZEND_NUM_ARGS ( ) ;
1999-04-22 02:48:28 +00:00
2002-09-25 15:46:47 +00:00
if ( argc > 1 ) {
2000-02-02 11:18:06 +00:00
WRONG_PARAM_COUNT ;
2002-09-25 15:46:47 +00:00
} else if ( argc ! = 1 | | zend_get_parameters_ex ( 1 , & file ) = = FAILURE ) {
2000-02-02 11:18:06 +00:00
fp = NULL ;
2000-03-09 14:41:15 +00:00
} else {
2002-09-25 15:46:47 +00:00
php_stream * stream ;
php_stream_from_zval ( stream , file ) ;
2002-03-15 21:03:08 +00:00
2002-09-25 15:46:47 +00:00
if ( php_stream_cast ( stream , PHP_STREAM_AS_STDIO , ( void * ) & fp , 1 ) = = FAILURE ) {
2002-03-15 21:03:08 +00:00
RETURN_FALSE ;
}
2000-03-09 14:41:15 +00:00
}
1999-04-22 02:48:28 +00:00
2000-02-02 11:18:06 +00:00
pdf = PDF_new2 ( custom_errorhandler , pdf_emalloc , pdf_realloc , pdf_efree , NULL ) ;
if ( fp ) {
2002-09-25 15:46:47 +00:00
if ( PDF_open_fp ( pdf , fp ) < 0 ) {
RETURN_FALSE ;
}
2000-02-02 11:18:06 +00:00
} else {
2000-03-09 14:53:30 +00:00
PDF_open_mem ( pdf , pdf_flushwrite ) ;
1999-04-22 02:48:28 +00:00
}
2001-06-06 09:58:22 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
2001-02-01 07:07:10 +00:00
PDF_set_parameter ( pdf , " imagewarning " , " true " ) ;
2001-06-06 09:58:22 +00:00
# endif
2001-02-12 17:50:39 +00:00
PDF_set_parameter ( pdf , " binding " , " PHP " ) ;
2001-02-01 07:07:10 +00:00
2001-01-03 16:05:45 +00:00
ZEND_REGISTER_RESOURCE ( return_value , pdf , le_pdf ) ;
1999-04-22 02:48:28 +00:00
}
2000-06-28 11:44:32 +00:00
1999-04-22 02:48:28 +00:00
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_close(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Closes the pdf document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_close )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-26 08:20:24 +00:00
PDF_close ( pdf ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
2000-06-28 11:44:32 +00:00
1999-04-22 02:48:28 +00:00
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_begin_page(resource pdfdoc, float width, float height)
1999-04-22 02:48:28 +00:00
Starts page */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_begin_page )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_begin_page ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_end_page(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Ends page */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_end_page )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_end_page ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_show(resource pdfdoc, string text)
1999-04-22 02:48:28 +00:00
Output text at current position */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_show )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg2 ) ;
2001-03-01 19:51:55 +00:00
PDF_show2 ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRLEN_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_show_xy(resource pdfdoc, string text, float x_koor, float y_koor)
1999-04-22 02:48:28 +00:00
Output text at position */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_show_xy )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
2001-03-01 19:51:55 +00:00
PDF_show_xy2 ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRLEN_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_show_boxed(resource pdfdoc, string text, float x_koor, float y_koor, float width, float height, string mode [, string feature])
2000-02-26 11:58:49 +00:00
Output text formated in a boxed */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_show_boxed )
2001-01-03 16:05:45 +00:00
{
zval * * argv [ 8 ] ;
int argc = ZEND_NUM_ARGS ( ) ;
2000-05-18 05:35:11 +00:00
int nr ;
2000-10-10 07:42:55 +00:00
char * feature ;
2000-02-26 11:58:49 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ( ( argc < 7 ) | | ( argc > 8 ) ) | | zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) {
2000-02-26 11:58:49 +00:00
WRONG_PARAM_COUNT ;
2001-01-03 16:05:45 +00:00
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , argv [ 0 ] , - 1 , " pdf object " , le_pdf ) ;
2000-02-26 11:58:49 +00:00
2000-10-10 07:42:55 +00:00
convert_to_string_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
convert_to_double_ex ( argv [ 4 ] ) ;
convert_to_double_ex ( argv [ 5 ] ) ;
convert_to_string_ex ( argv [ 6 ] ) ;
2001-01-03 16:05:45 +00:00
2000-10-10 07:42:55 +00:00
if ( argc = = 8 ) {
convert_to_string_ex ( argv [ 7 ] ) ;
2001-01-03 16:05:45 +00:00
feature = Z_STRVAL_PP ( argv [ 7 ] ) ;
2000-10-10 07:42:55 +00:00
} else {
feature = NULL ;
}
2000-02-26 11:58:49 +00:00
2001-01-03 16:05:45 +00:00
nr = PDF_show_boxed ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) ,
( float ) Z_DVAL_PP ( argv [ 2 ] ) ,
( float ) Z_DVAL_PP ( argv [ 3 ] ) ,
( float ) Z_DVAL_PP ( argv [ 4 ] ) ,
( float ) Z_DVAL_PP ( argv [ 5 ] ) ,
Z_STRVAL_PP ( argv [ 6 ] ) ,
feature ) ;
2000-02-26 11:58:49 +00:00
2000-05-18 05:35:11 +00:00
RETURN_LONG ( nr ) ;
2000-02-26 11:58:49 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_font(resource pdfdoc, string font, float size, string encoding [, int embed])
1999-08-05 16:25:10 +00:00
Select the current font face , size and encoding */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_set_font )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 ;
int font , embed ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-06-05 19:47:54 +00:00
switch ( ZEND_NUM_ARGS ( ) ) {
1999-09-09 06:19:01 +00:00
case 4 :
2000-08-28 15:19:23 +00:00
if ( zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-09-09 06:19:01 +00:00
WRONG_PARAM_COUNT ;
}
embed = 0 ;
break ;
case 5 :
2000-08-28 15:19:23 +00:00
if ( zend_get_parameters_ex ( 5 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 ) = = FAILURE ) {
1999-09-09 06:19:01 +00:00
WRONG_PARAM_COUNT ;
}
2000-08-28 15:19:23 +00:00
convert_to_long_ex ( arg5 ) ;
2001-01-03 16:05:45 +00:00
embed = Z_LVAL_PP ( arg5 ) ;
1999-09-09 06:19:01 +00:00
break ;
default :
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_string_ex ( arg4 ) ;
2000-02-15 08:10:32 +00:00
2001-01-03 16:05:45 +00:00
font = PDF_findfont ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRVAL_PP ( arg4 ) , embed ) ;
2001-01-26 08:20:24 +00:00
if ( font = = - 1 ) {
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Font %s not found " , Z_STRVAL_PP ( arg2 ) ) ;
1999-08-05 16:25:10 +00:00
RETURN_FALSE ;
}
2001-01-03 16:05:45 +00:00
PDF_setfont ( pdf , font , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2001-06-05 13:12:10 +00:00
/* {{{ _php_pdf_set_value
*/
2001-01-03 16:05:45 +00:00
static void _php_pdf_set_value ( INTERNAL_FUNCTION_PARAMETERS , char * field )
{
zval * * arg1 , * * arg2 ;
1999-10-07 16:00:48 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-10-07 16:00:48 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-10-07 16:00:48 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
2001-02-01 07:07:10 +00:00
PDF_set_value ( pdf , field , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-10-07 16:00:48 +00:00
2001-01-03 16:05:45 +00:00
RETURN_TRUE ;
1999-10-07 16:00:48 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
1999-10-07 16:00:48 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_value(resource pdfdoc, string key, float value)
2001-01-03 16:05:45 +00:00
Sets arbitrary value */
PHP_FUNCTION ( pdf_set_value )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-02-01 07:07:10 +00:00
PDF_set_value ( pdf , Z_STRVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto float pdf_get_value(resource pdfdoc, string key, float modifier)
2001-01-03 16:05:45 +00:00
Gets arbitrary value */
PHP_FUNCTION ( pdf_get_value )
{
zval * * argv [ 3 ] ;
int argc = ZEND_NUM_ARGS ( ) ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
double value ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
if ( ( ( argc < 2 ) | | ( argc > 3 ) ) | | zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , argv [ 0 ] , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( argv [ 1 ] ) ;
2001-01-26 08:20:24 +00:00
if ( argc = = 3 )
convert_to_double_ex ( argv [ 2 ] ) ;
1999-04-22 02:48:28 +00:00
2001-01-26 08:20:24 +00:00
if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " imagewidth " ) ) ) {
2001-01-03 16:53:00 +00:00
if ( argc < 3 ) WRONG_PARAM_COUNT ;
2001-02-01 07:07:10 +00:00
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) - PDFLIB_IMAGE_OFFSET ) ;
2001-01-26 08:20:24 +00:00
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " imageheight " ) ) ) {
if ( argc < 3 ) WRONG_PARAM_COUNT ;
2001-02-01 07:07:10 +00:00
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) - PDFLIB_IMAGE_OFFSET ) ;
2001-01-26 08:20:24 +00:00
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " resx " ) ) ) {
if ( argc < 3 ) WRONG_PARAM_COUNT ;
2001-02-01 07:07:10 +00:00
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) - PDFLIB_IMAGE_OFFSET ) ;
2001-01-26 08:20:24 +00:00
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " resy " ) ) ) {
if ( argc < 3 ) WRONG_PARAM_COUNT ;
2001-02-01 07:07:10 +00:00
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) - PDFLIB_IMAGE_OFFSET ) ;
2001-10-08 16:12:12 +00:00
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " capheight " ) ) ) {
if ( argc < 3 ) WRONG_PARAM_COUNT ;
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) - PDFLIB_FONT_OFFSET ) ;
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " ascender " ) ) ) {
if ( argc < 3 ) WRONG_PARAM_COUNT ;
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) - PDFLIB_FONT_OFFSET ) ;
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " descender " ) ) ) {
if ( argc < 3 ) WRONG_PARAM_COUNT ;
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) - PDFLIB_FONT_OFFSET ) ;
2001-01-26 08:20:24 +00:00
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( argv [ 1 ] ) , " font " ) ) ) {
2001-07-03 14:35:08 +00:00
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , 0.0 ) + PDFLIB_FONT_OFFSET ;
2001-01-03 16:05:45 +00:00
} else {
if ( argc < 3 ) {
2001-01-26 08:20:24 +00:00
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , 0.0 ) ;
2001-01-03 16:05:45 +00:00
} else {
2001-02-01 07:07:10 +00:00
value = PDF_get_value ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
2001-01-03 16:05:45 +00:00
}
1999-04-22 02:48:28 +00:00
}
2001-01-03 16:05:45 +00:00
RETURN_DOUBLE ( value ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_get_font(resource pdfdoc)
2001-01-03 16:05:45 +00:00
Gets the current font */
PHP_FUNCTION ( pdf_get_font )
{
zval * * arg1 ;
int font ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
font = ( int ) PDF_get_value ( pdf , " font " , 0 ) ;
2001-01-26 08:20:24 +00:00
RETURN_LONG ( font + PDFLIB_FONT_OFFSET ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto string pdf_get_fontname(resource pdfdoc)
2001-01-03 16:05:45 +00:00
Gets the current font name */
PHP_FUNCTION ( pdf_get_fontname )
{
zval * * arg1 ;
char * fontname ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
1999-04-22 02:48:28 +00:00
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
fontname = ( char * ) PDF_get_parameter ( pdf , " fontname " , 0 ) ;
RETURN_STRING ( fontname , 1 ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto float pdf_get_fontsize(resource pdfdoc)
2001-01-03 16:05:45 +00:00
Gets the current font size */
PHP_FUNCTION ( pdf_get_fontsize )
{
zval * * arg1 ;
float fontsize ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
fontsize = PDF_get_value ( pdf , " fontsize " , 0 ) ;
RETURN_DOUBLE ( fontsize ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_leading(resource pdfdoc, float distance)
2001-01-03 16:05:45 +00:00
Sets distance between text lines */
PHP_FUNCTION ( pdf_set_leading )
{
_php_pdf_set_value ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " leading " ) ;
}
/* }}} */
1999-04-22 02:48:28 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_text_rendering(resource pdfdoc, int mode)
2001-01-03 16:05:45 +00:00
Determines how text is rendered */
PHP_FUNCTION ( pdf_set_text_rendering )
{
_php_pdf_set_value ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " textrendering " ) ;
}
/* }}} */
1999-04-22 02:48:28 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_horiz_scaling(resource pdfdoc, float scale)
2001-01-03 16:05:45 +00:00
Sets horizontal scaling of text */
PHP_FUNCTION ( pdf_set_horiz_scaling )
{
_php_pdf_set_value ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " horizscaling " ) ;
}
/* }}} */
1999-04-22 02:48:28 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_text_rise(resource pdfdoc, float value)
2001-01-03 16:05:45 +00:00
Sets the text rise */
PHP_FUNCTION ( pdf_set_text_rise )
{
_php_pdf_set_value ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " textrise " ) ;
}
/* }}} */
1999-04-22 02:48:28 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_char_spacing(resource pdfdoc, float space)
2001-01-03 16:05:45 +00:00
Sets character spacing */
PHP_FUNCTION ( pdf_set_char_spacing )
{
_php_pdf_set_value ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " charspacing " ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_word_spacing(resource pdfdoc, float space)
1999-04-22 02:48:28 +00:00
Sets spacing between words */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_word_spacing )
{
_php_pdf_set_value ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " wordspacing " ) ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_text_pos(resource pdfdoc, float x, float y)
2001-01-26 18:52:38 +00:00
Sets the position of text for the next pdf_show call */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_text_pos )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
PDF_set_text_pos ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_continue_text(resource pdfdoc, string text)
1999-04-22 02:48:28 +00:00
Output text in next line */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_continue_text )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg2 ) ;
2001-03-01 19:51:55 +00:00
PDF_continue_text2 ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRLEN_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto float pdf_stringwidth(resource pdfdoc, string text [, int font, float size])
2001-01-26 18:52:38 +00:00
Returns width of text in current font */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_stringwidth )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
int font ;
double width , size ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2001-01-26 08:20:24 +00:00
switch ( ZEND_NUM_ARGS ( ) ) {
case 2 :
if ( zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE )
WRONG_PARAM_COUNT ;
break ;
case 4 :
if ( zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE )
WRONG_PARAM_COUNT ;
2003-06-22 14:33:09 +00:00
/* double convert_to_long_ex(arg3) - look below . is this needed ? */
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg3 ) ;
break ;
default :
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg2 ) ;
2001-01-26 08:20:24 +00:00
if ( ZEND_NUM_ARGS ( ) = = 2 ) {
2001-02-01 07:07:10 +00:00
font = ( int ) PDF_get_value ( pdf , " font " , 0 ) + PDFLIB_FONT_OFFSET ;
2001-01-26 08:20:24 +00:00
size = PDF_get_value ( pdf , " fontsize " , 0 ) ;
} else {
convert_to_long_ex ( arg3 ) ;
font = Z_LVAL_PP ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
size = Z_DVAL_PP ( arg4 ) ;
}
2001-03-01 19:51:55 +00:00
width = ( double ) PDF_stringwidth2 ( pdf ,
Z_STRVAL_PP ( arg2 ) ,
Z_STRLEN_PP ( arg2 ) ,
font - PDFLIB_FONT_OFFSET ,
( float ) size ) ;
2001-01-03 16:05:45 +00:00
RETURN_DOUBLE ( ( double ) width ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_save(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Saves current enviroment */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_save )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_save ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_restore(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Restores formerly saved enviroment */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_restore )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_restore ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_translate(resource pdfdoc, float x, float y)
1999-04-22 02:48:28 +00:00
Sets origin of coordinate system */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_translate )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_translate ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_scale(resource pdfdoc, float x_scale, float y_scale)
1999-04-22 02:48:28 +00:00
Sets scaling */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_scale )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_scale ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_rotate(resource pdfdoc, float angle)
1999-04-22 02:48:28 +00:00
Sets rotation */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_rotate )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
PDF_rotate ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_skew(resource pdfdoc, float xangle, float yangle)
2000-02-26 11:58:49 +00:00
Skew the coordinate system */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_skew )
{
zval * * arg1 , * * arg2 , * * arg3 ;
2000-02-26 11:58:49 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
2000-02-26 11:58:49 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_skew ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
2000-02-26 11:58:49 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setflat(resource pdfdoc, float value)
1999-04-22 02:48:28 +00:00
Sets flatness */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setflat )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
2001-01-26 08:20:24 +00:00
/* pdflib will do this for you, will throw some exception
2001-01-03 16:05:45 +00:00
if ( ( Z_LVAL_PP ( arg2 ) > 100 ) & & ( Z_LVAL_PP ( arg2 ) < 0 ) ) {
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter of pdf_setflat() has to between 0 and 100 " ) ;
1999-04-22 02:48:28 +00:00
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
*/
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
PDF_setflat ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setlinejoin(resource pdfdoc, int value)
1999-04-22 02:48:28 +00:00
Sets linejoin parameter */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setlinejoin )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_long_ex ( arg2 ) ;
2001-01-26 08:20:24 +00:00
/* pdflib will do this for you, will throw some exception
2001-01-03 16:05:45 +00:00
if ( ( Z_LVAL_PP ( arg2 ) > 2 ) & & ( Z_LVAL_PP ( arg2 ) < 0 ) ) {
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter of pdf_setlinejoin() must be between 0 and 2 " ) ;
1999-04-22 02:48:28 +00:00
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
*/
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
PDF_setlinejoin ( pdf , Z_LVAL_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setlinecap(resource pdfdoc, int value)
1999-04-22 02:48:28 +00:00
Sets linecap parameter */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setlinecap )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_long_ex ( arg2 ) ;
2001-01-26 08:20:24 +00:00
/* pdflib will do this for you, will throw some exception
2001-01-03 16:05:45 +00:00
if ( ( Z_LVAL_PP ( arg2 ) > 2 ) & & ( Z_LVAL_PP ( arg2 ) < 0 ) ) {
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter of pdf_setlinecap() must be > 0 and <= 2 " ) ;
1999-04-22 02:48:28 +00:00
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
*/
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
PDF_setlinecap ( pdf , Z_LVAL_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setmiterlimit(resource pdfdoc, float value)
1999-04-22 02:48:28 +00:00
Sets miter limit */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setmiterlimit )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
2001-01-26 08:20:24 +00:00
/* pdflib will do this for you, will throw some exception
2001-01-03 16:05:45 +00:00
if ( Z_DVAL_PP ( arg2 ) < 1 ) {
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter of pdf_setmiterlimit() must be >= 1 " ) ;
1999-04-22 02:48:28 +00:00
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
*/
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
PDF_setmiterlimit ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setlinewidth(resource pdfdoc, float width)
1999-04-22 02:48:28 +00:00
Sets line width */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setlinewidth )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
PDF_setlinewidth ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setdash(resource pdfdoc, float black, float white)
1999-04-22 02:48:28 +00:00
Sets dash pattern */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setdash )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_setdash ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_moveto(resource pdfdoc, float x, float y)
1999-04-22 02:48:28 +00:00
Sets current point */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_moveto )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_moveto ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_curveto(resource pdfdoc, float x1, float y1, float x2, float y2, float x3, float y3)
1999-04-22 02:48:28 +00:00
Draws a curve */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_curveto )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 7 | | zend_get_parameters_ex ( 7 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_double_ex ( arg6 ) ;
convert_to_double_ex ( arg7 ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
PDF_curveto ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
( float ) Z_DVAL_PP ( arg6 ) ,
( float ) Z_DVAL_PP ( arg7 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_lineto(resource pdfdoc, float x, float y)
1999-04-22 02:48:28 +00:00
Draws a line */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_lineto )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_lineto ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_circle(resource pdfdoc, float x, float y, float radius)
1999-04-22 02:48:28 +00:00
Draws a circle */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_circle )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
2001-01-03 16:05:45 +00:00
PDF_circle ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_arc(resource pdfdoc, float x, float y, float radius, float start, float end)
1999-04-22 02:48:28 +00:00
Draws an arc */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_arc )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 6 | | zend_get_parameters_ex ( 6 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_double_ex ( arg6 ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
PDF_arc ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
( float ) Z_DVAL_PP ( arg6 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_rect(resource pdfdoc, float x, float y, float width, float height)
1999-04-22 02:48:28 +00:00
Draws a rectangle */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_rect )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 5 | | zend_get_parameters_ex ( 5 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
PDF_rect ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_closepath(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Close path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_closepath )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_closepath ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_closepath_stroke(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Close path and draw line along path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_closepath_stroke )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_closepath_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_stroke(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Draw line along path path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_stroke )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_fill(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Fill current path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_fill )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_fill ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_fill_stroke(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Fill and stroke current path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_fill_stroke )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_fill_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_closepath_fill_stroke(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Close , fill and stroke current path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_closepath_fill_stroke )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_closepath_fill_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_endpath(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Ends current path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_endpath )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
PDF_endpath ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_clip(resource pdfdoc)
1999-04-22 02:48:28 +00:00
Clips to current path */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_clip )
{
zval * * arg1 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2000-06-06 19:59:30 +00:00
2001-01-03 16:05:45 +00:00
PDF_clip ( pdf ) ;
RETURN_TRUE ;
2000-06-06 19:59:30 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_parameter(resource pdfdoc, string key, string value)
2001-01-03 16:05:45 +00:00
Sets arbitrary parameters */
PHP_FUNCTION ( pdf_set_parameter )
{
zval * * arg1 , * * arg2 , * * arg3 ;
2000-06-06 19:59:30 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
2000-06-06 19:59:30 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_string_ex ( arg2 ) ;
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg3 ) ;
PDF_set_parameter ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRVAL_PP ( arg3 ) ) ;
2000-06-06 19:59:30 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto string pdf_get_parameter(resource pdfdoc, string key, mixed modifier)
2001-01-03 16:05:45 +00:00
Gets arbitrary parameters */
PHP_FUNCTION ( pdf_get_parameter )
{
zval * * argv [ 3 ] ;
int argc = ZEND_NUM_ARGS ( ) ;
2000-06-06 19:59:30 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
char * value ;
2000-06-06 19:59:30 +00:00
2001-01-03 16:05:45 +00:00
if ( ( ( argc < 2 ) | | ( argc > 3 ) ) | | zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) {
2000-09-08 06:47:04 +00:00
WRONG_PARAM_COUNT ;
2000-06-06 19:59:30 +00:00
}
2001-01-03 16:05:45 +00:00
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , argv [ 0 ] , - 1 , " pdf object " , le_pdf ) ;
2000-06-06 19:59:30 +00:00
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( argv [ 1 ] ) ;
if ( argc = = 3 ) {
convert_to_double_ex ( argv [ 2 ] ) ;
value = ( char * ) PDF_get_parameter ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
} else {
value = ( char * ) PDF_get_parameter ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) , 0.0 ) ;
2000-09-08 06:47:04 +00:00
}
2000-06-06 19:59:30 +00:00
2001-01-03 16:05:45 +00:00
RETURN_STRING ( value , 1 ) ;
2000-06-06 19:59:30 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setgray_fill(resource pdfdoc, float value)
1999-04-22 02:48:28 +00:00
Sets filling color to gray value */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setgray_fill )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
2001-03-05 16:18:51 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
PDF_setcolor ( pdf , " fill " , " gray " , ( float ) Z_DVAL_PP ( arg2 ) , 0 , 0 , 0 ) ;
# else
2001-01-03 16:05:45 +00:00
PDF_setgray_fill ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
2001-03-05 16:18:51 +00:00
# endif
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setgray_stroke(resource pdfdoc, float value)
1999-04-22 02:48:28 +00:00
Sets drawing color to gray value */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setgray_stroke )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
2001-03-05 16:18:51 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
PDF_setcolor ( pdf , " stroke " , " gray " , ( float ) Z_DVAL_PP ( arg2 ) , 0 , 0 , 0 ) ;
# else
2001-01-03 16:05:45 +00:00
PDF_setgray_stroke ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
2001-03-05 16:18:51 +00:00
# endif
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setgray(resource pdfdoc, float value)
1999-04-22 02:48:28 +00:00
Sets drawing and filling color to gray value */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setgray )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
2001-03-05 16:18:51 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
PDF_setcolor ( pdf , " both " , " gray " , ( float ) Z_DVAL_PP ( arg2 ) , 0 , 0 , 0 ) ;
# else
2001-01-03 16:05:45 +00:00
PDF_setgray ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
2001-03-05 16:18:51 +00:00
# endif
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setrgbcolor_fill(resource pdfdoc, float red, float green, float blue)
2001-01-26 18:52:38 +00:00
Sets filling color to RGB color value */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setrgbcolor_fill )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
2001-03-05 16:18:51 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
PDF_setcolor ( pdf , " fill " , " rgb " , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) , 0 ) ;
# else
2001-01-03 16:05:45 +00:00
PDF_setrgbcolor_fill ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
2001-03-05 16:18:51 +00:00
# endif
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setrgbcolor_stroke(resource pdfdoc, float red, float green, float blue)
2001-01-26 18:52:38 +00:00
Sets drawing color to RGB color value */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setrgbcolor_stroke )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
2001-03-05 16:18:51 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
PDF_setcolor ( pdf , " stroke " , " rgb " , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) , 0 ) ;
# else
2001-01-03 16:05:45 +00:00
PDF_setrgbcolor_stroke ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
2001-03-05 16:18:51 +00:00
# endif
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setrgbcolor(resource pdfdoc, float red, float green, float blue)
2001-01-26 18:52:38 +00:00
Sets drawing and filling color to RGB color value */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_setrgbcolor )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
2001-03-05 16:18:51 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
PDF_setcolor ( pdf , " both " , " rgb " , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) , 0 ) ;
# else
2001-01-03 16:05:45 +00:00
PDF_setrgbcolor ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
2001-03-05 16:18:51 +00:00
# endif
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_add_bookmark(resource pdfdoc, string text [, int parent [, int open]])
2001-01-26 18:52:38 +00:00
Adds bookmark for current page */
2001-01-26 08:20:24 +00:00
PHP_FUNCTION ( pdf_add_bookmark )
2001-01-03 16:05:45 +00:00
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
2001-01-26 08:20:24 +00:00
int parentid , open , id ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-06-05 19:47:54 +00:00
switch ( ZEND_NUM_ARGS ( ) ) {
1999-08-05 16:25:10 +00:00
case 2 :
2000-08-28 15:19:23 +00:00
if ( zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
break ;
case 3 :
2000-08-28 15:19:23 +00:00
if ( zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
break ;
case 4 :
2000-08-28 15:19:23 +00:00
if ( zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
break ;
default :
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
1999-08-05 16:25:10 +00:00
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
convert_to_string_ex ( arg2 ) ;
1999-04-22 02:48:28 +00:00
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) > 2 ) {
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg3 ) ;
parentid = Z_LVAL_PP ( arg3 ) ;
1999-08-05 16:25:10 +00:00
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) > 3 ) {
2000-08-28 15:19:23 +00:00
convert_to_long_ex ( arg4 ) ;
2001-01-03 16:05:45 +00:00
open = Z_LVAL_PP ( arg4 ) ;
1999-08-05 16:25:10 +00:00
} else {
open = 0 ;
}
} else {
parentid = 0 ;
open = 0 ;
}
2001-01-26 08:20:24 +00:00
/* will never return 0 */
2001-01-03 16:05:45 +00:00
id = PDF_add_bookmark ( pdf , Z_STRVAL_PP ( arg2 ) , parentid , open ) ;
2001-01-26 08:20:24 +00:00
RETURN_LONG ( id ) ;
1999-04-22 02:48:28 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_transition(resource pdfdoc, int transition)
1999-04-22 02:48:28 +00:00
Sets transition between pages */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_transition )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_long_ex ( arg2 ) ;
1999-08-05 16:25:10 +00:00
2001-01-03 16:05:45 +00:00
switch ( Z_LVAL_PP ( arg2 ) ) {
1999-08-05 16:25:10 +00:00
case 0 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " none " ) ;
1999-08-05 16:25:10 +00:00
break ;
case 1 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " split " ) ;
1999-08-05 16:25:10 +00:00
break ;
case 2 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " blinds " ) ;
1999-08-05 16:25:10 +00:00
break ;
case 3 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " box " ) ;
1999-08-05 16:25:10 +00:00
break ;
case 4 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " wipe " ) ;
1999-08-05 16:25:10 +00:00
break ;
case 5 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " dissolve " ) ;
1999-08-05 16:25:10 +00:00
break ;
case 6 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " glitter " ) ;
1999-08-05 16:25:10 +00:00
break ;
case 7 :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " replace " ) ;
1999-08-05 16:25:10 +00:00
break ;
default :
2000-07-05 14:30:51 +00:00
PDF_set_parameter ( pdf , " transition " , " none " ) ;
1999-04-22 02:48:28 +00:00
}
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_duration(resource pdfdoc, float duration)
1999-04-22 02:48:28 +00:00
Sets duration between pages */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_duration )
{
zval * * arg1 , * * arg2 ;
1999-04-22 02:48:28 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-22 02:48:28 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-04-22 02:48:28 +00:00
2001-01-03 16:05:45 +00:00
convert_to_double_ex ( arg2 ) ;
PDF_set_value ( pdf , " duration " , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-04-22 02:48:28 +00:00
RETURN_TRUE ;
}
/* }}} */
2001-06-05 13:12:10 +00:00
/* {{{ _php_pdf_open_image
*/
2001-01-03 16:05:45 +00:00
static void _php_pdf_open_image ( INTERNAL_FUNCTION_PARAMETERS , char * type )
{
zval * * arg1 , * * arg2 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2001-02-01 07:07:10 +00:00
int pdf_image ;
2000-11-21 07:08:01 +00:00
char * image ;
1999-08-05 16:25:10 +00:00
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_string_ex ( arg2 ) ;
1999-08-05 16:25:10 +00:00
2001-01-03 11:41:31 +00:00
# ifdef VIRTUAL_DIR
2001-08-05 01:43:02 +00:00
virtual_filepath ( Z_STRVAL_PP ( arg2 ) , & image TSRMLS_CC ) ;
2001-01-03 15:50:20 +00:00
# else
2001-01-03 16:05:45 +00:00
image = Z_STRVAL_PP ( arg2 ) ;
# endif
2003-05-20 00:37:00 +00:00
if ( php_check_open_basedir ( image TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( image , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2001-01-03 16:05:45 +00:00
pdf_image = PDF_open_image_file ( pdf , type , image , " " , 0 ) ;
1999-08-05 16:25:10 +00:00
2001-01-26 08:20:24 +00:00
RETURN_LONG ( pdf_image + PDFLIB_IMAGE_OFFSET ) ;
2001-01-03 16:05:45 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-01-03 16:05:45 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_gif(resource pdf, string giffile)
2001-02-01 07:07:10 +00:00
Opens a GIF file and returns an image for placement in a pdf object */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_open_gif )
{
_php_pdf_open_image ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " gif " ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_jpeg(resource pdf, string jpegfile)
2001-01-26 18:52:38 +00:00
Opens a JPEG file and returns an image for placement in a PDF document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_open_jpeg )
{
_php_pdf_open_image ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " jpeg " ) ;
2000-03-28 16:45:05 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_png(resource pdf, string pngfile)
2001-01-26 18:52:38 +00:00
Opens a PNG file and returns an image for placement in a PDF document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_open_png )
{
_php_pdf_open_image ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " png " ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_tiff(resource pdf, string tifffile)
2001-01-26 18:52:38 +00:00
Opens a TIFF file and returns an image for placement in a PDF document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_open_tiff )
{
_php_pdf_open_image ( INTERNAL_FUNCTION_PARAM_PASSTHRU , " tiff " ) ;
2000-03-28 16:45:05 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_image_file(resource pdf, string type, string file [, string stringparam, int intparam])
2001-01-26 18:52:38 +00:00
Opens an image file of the given type and returns an image for placement in a PDF document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_open_image_file )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 ;
2000-03-28 16:45:05 +00:00
PDF * pdf ;
2001-01-26 08:20:24 +00:00
int pdf_image , argc ;
2000-11-21 07:08:01 +00:00
char * image ;
2001-07-03 14:35:08 +00:00
char * stringparam ;
int intparam ;
2000-03-28 16:45:05 +00:00
2001-01-26 08:20:24 +00:00
switch ( ( argc = ZEND_NUM_ARGS ( ) ) ) {
case 3 :
if ( zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE )
WRONG_PARAM_COUNT ;
break ;
case 5 :
if ( zend_get_parameters_ex ( 5 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 ) = = FAILURE )
WRONG_PARAM_COUNT ;
break ;
default :
2000-03-28 16:45:05 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
2000-03-28 16:45:05 +00:00
2001-01-03 11:41:31 +00:00
# ifdef VIRTUAL_DIR
2001-08-05 01:43:02 +00:00
virtual_filepath ( Z_STRVAL_PP ( arg3 ) , & image TSRMLS_CC ) ;
2001-01-03 15:50:20 +00:00
# else
2001-01-03 16:05:45 +00:00
image = Z_STRVAL_PP ( arg3 ) ;
# endif
2000-11-21 07:08:01 +00:00
2003-05-20 00:37:00 +00:00
if ( php_check_open_basedir ( image TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( image , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
if ( argc = = 3 ) {
pdf_image = PDF_open_image_file ( pdf , Z_STRVAL_PP ( arg2 ) , image , " " , 0 ) ;
} else {
convert_to_string_ex ( arg4 ) ;
convert_to_long_ex ( arg5 ) ;
2001-07-03 14:35:08 +00:00
stringparam = Z_STRVAL_PP ( arg4 ) ;
intparam = Z_LVAL_PP ( arg5 ) ;
/* adjust the image handle */
if ( ! strcmp ( stringparam , " masked " ) )
intparam - = PDFLIB_IMAGE_OFFSET ;
pdf_image = PDF_open_image_file ( pdf , Z_STRVAL_PP ( arg2 ) , image , stringparam , intparam ) ;
2000-02-10 10:20:31 +00:00
}
2001-01-26 08:20:24 +00:00
if ( pdf_image = = - 1 ) {
/* pdflib will do this for you, will throw some exception
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not open image: %s " , image ) ;
2001-01-26 08:20:24 +00:00
*/
RETURN_FALSE ;
}
RETURN_LONG ( pdf_image + PDFLIB_IMAGE_OFFSET ) ;
2001-01-03 16:05:45 +00:00
2000-02-10 10:20:31 +00:00
}
/* }}} */
1999-08-05 16:25:10 +00:00
# if HAVE_LIBGD13
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_memory_image(resource pdf, resource image)
2001-01-26 18:52:38 +00:00
Takes an GD image and returns an image for placement in a PDF document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_open_memory_image )
{
zval * * arg1 , * * arg2 ;
2004-02-28 22:58:51 +00:00
int i , j , color ;
2001-05-21 22:37:47 +00:00
int pdf_image ;
1999-08-05 16:25:10 +00:00
gdImagePtr im ;
unsigned char * buffer , * ptr ;
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-01-03 16:05:45 +00:00
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-05-21 21:06:08 +00:00
ZEND_GET_RESOURCE_TYPE_ID ( le_gd , " gd " ) ;
if ( ! le_gd )
{
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_ERROR , " Unable to find handle for GD image stream. Please check the GD extension is loaded. " ) ;
2001-05-21 21:06:08 +00:00
}
ZEND_FETCH_RESOURCE ( im , gdImagePtr , arg2 , - 1 , " Image " , le_gd ) ;
1999-08-05 16:25:10 +00:00
2004-02-28 21:00:16 +00:00
buffer = ( unsigned char * ) safe_emalloc ( 3 * im - > sx , im - > sy , 0 ) ;
1999-08-05 16:25:10 +00:00
ptr = buffer ;
for ( i = 0 ; i < im - > sy ; i + + ) {
for ( j = 0 ; j < im - > sx ; j + + ) {
2002-12-03 19:25:17 +00:00
# if HAVE_LIBGD20
if ( gdImageTrueColor ( im ) ) {
if ( im - > tpixels & & gdImageBoundsSafe ( im , j , i ) ) {
color = gdImageTrueColorPixel ( im , j , i ) ;
* ptr + + = ( color > > 16 ) & 0xFF ;
* ptr + + = ( color > > 8 ) & 0xFF ;
* ptr + + = color & 0xFF ;
}
} else {
# endif
if ( im - > pixels & & gdImageBoundsSafe ( im , j , i ) ) {
2003-01-16 21:18:49 +00:00
color = im - > pixels [ i ] [ j ] ;
2002-12-03 19:25:17 +00:00
* ptr + + = im - > red [ color ] ;
* ptr + + = im - > green [ color ] ;
* ptr + + = im - > blue [ color ] ;
}
# if HAVE_LIBGD20
}
# endif
1999-08-05 16:25:10 +00:00
}
}
2000-03-09 14:41:15 +00:00
pdf_image = PDF_open_image ( pdf , " raw " , " memory " , buffer , im - > sx * im - > sy * 3 , im - > sx , im - > sy , 3 , 8 , NULL ) ;
1999-09-14 14:47:14 +00:00
efree ( buffer ) ;
1999-08-05 16:25:10 +00:00
2001-01-03 16:05:45 +00:00
if ( pdf_image = = - 1 ) {
2001-01-26 08:20:24 +00:00
/* pdflib will do this for you, will throw some exception
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not open image " ) ;
2001-01-26 08:20:24 +00:00
*/
1999-09-14 14:47:14 +00:00
efree ( buffer ) ;
1999-08-05 16:25:10 +00:00
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
RETURN_LONG ( pdf_image + PDFLIB_IMAGE_OFFSET ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
# endif /* HAVE_LIBGD13 */
2003-06-22 14:33:09 +00:00
/* {{{ proto void pdf_close_image(resource pdf, int pdfimage)
2001-01-26 18:52:38 +00:00
Closes the PDF image */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_close_image )
{
zval * * arg1 , * * arg2 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg2 ) ;
1999-08-05 16:25:10 +00:00
2001-01-26 08:20:24 +00:00
PDF_close_image ( pdf , Z_LVAL_PP ( arg2 ) - PDFLIB_IMAGE_OFFSET ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_place_image(resource pdf, int pdfimage, float x, float y, float scale)
2001-01-26 18:52:38 +00:00
Places image in the PDF document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_place_image )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 5 | | zend_get_parameters_ex ( 5 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
1999-08-05 16:25:10 +00:00
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg2 ) ;
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
2001-01-26 08:20:24 +00:00
2001-02-01 07:07:10 +00:00
PDF_place_image ( pdf , Z_LVAL_PP ( arg2 ) - PDFLIB_IMAGE_OFFSET , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) , ( float ) Z_DVAL_PP ( arg5 ) ) ;
1999-08-05 16:25:10 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_get_image_width(resource pdf, int pdfimage)
1999-08-05 16:25:10 +00:00
Returns the width of an image */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_get_image_width )
{
zval * * arg1 , * * arg2 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2001-01-26 08:20:24 +00:00
int width ;
1999-08-05 16:25:10 +00:00
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg2 ) ;
1999-08-05 16:25:10 +00:00
2001-03-01 19:51:55 +00:00
width = ( int ) PDF_get_value ( pdf , " imagewidth " , ( float ) Z_LVAL_PP ( arg2 ) - PDFLIB_IMAGE_OFFSET ) ;
1999-08-05 16:25:10 +00:00
RETURN_LONG ( width ) ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_get_image_height(resource pdf, int pdfimage)
1999-08-05 16:25:10 +00:00
Returns the height of an image */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_get_image_height )
{
zval * * arg1 , * * arg2 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2001-01-26 08:20:24 +00:00
int height ;
1999-08-05 16:25:10 +00:00
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg2 ) ;
1999-08-05 16:25:10 +00:00
2001-03-01 19:51:55 +00:00
height = ( int ) PDF_get_value ( pdf , " imageheight " , ( float ) Z_LVAL_PP ( arg2 ) - PDFLIB_IMAGE_OFFSET ) ;
1999-08-05 16:25:10 +00:00
RETURN_LONG ( height ) ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_add_weblink(resource pdfdoc, float llx, float lly, float urx, float ury, string url)
1999-08-05 16:25:10 +00:00
Adds link to web resource */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_add_weblink )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 6 | | zend_get_parameters_ex ( 6 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_string_ex ( arg6 ) ;
2001-01-03 16:05:45 +00:00
PDF_add_weblink ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
Z_STRVAL_PP ( arg6 ) ) ;
1999-08-05 16:25:10 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_add_pdflink(resource pdfdoc, float llx, float lly, float urx, float ury, string filename, int page, string dest)
2001-01-26 18:52:38 +00:00
Adds link to PDF document */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_add_pdflink )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 , * * arg8 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 8 | | zend_get_parameters_ex ( 8 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 , & arg8 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_string_ex ( arg6 ) ;
convert_to_long_ex ( arg7 ) ;
convert_to_string_ex ( arg8 ) ;
2001-01-03 16:05:45 +00:00
PDF_add_pdflink ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
Z_STRVAL_PP ( arg6 ) ,
Z_LVAL_PP ( arg7 ) ,
Z_STRVAL_PP ( arg8 ) ) ;
1999-08-05 16:25:10 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_border_style(resource pdfdoc, string style, float width)
2001-01-26 18:52:38 +00:00
Sets style of box surounding all kinds of annotations and link */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_border_style )
{
zval * * arg1 , * * arg2 , * * arg3 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_set_border_style ( pdf , Z_STRVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-08-05 16:25:10 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_border_color(resource pdfdoc, float red, float green, float blue)
2001-01-26 18:52:38 +00:00
Sets color of box surounded all kinds of annotations and links */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_border_color )
{
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
2001-01-03 16:05:45 +00:00
PDF_set_border_color ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
1999-08-05 16:25:10 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_set_border_dash(resource pdfdoc, float black, float white)
2001-01-26 18:52:38 +00:00
Sets the border dash style of all kinds of annotations and links */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_set_border_dash )
{
zval * * arg1 , * * arg2 , * * arg3 ;
2000-06-06 19:59:30 +00:00
PDF * pdf ;
2000-08-28 15:19:23 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
2000-06-06 19:59:30 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-03 16:05:45 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
2001-01-03 16:05:45 +00:00
PDF_set_border_dash ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
2000-06-06 19:59:30 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_add_annotation(resource pdfdoc, float xll, float yll, float xur, float xur, string title, string text)
2001-01-26 18:52:38 +00:00
Sets annotation ( depreciated use pdf_add_note instead ) */
2001-01-03 16:05:45 +00:00
PHP_FUNCTION ( pdf_add_annotation )
{
zval * * argv [ 7 ] ;
1999-08-05 16:25:10 +00:00
PDF * pdf ;
2001-01-03 16:05:45 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 7 | | zend_get_parameters_array_ex ( 7 , argv ) = = FAILURE ) {
1999-08-05 16:25:10 +00:00
WRONG_PARAM_COUNT ;
2001-01-03 16:05:45 +00:00
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , argv [ 0 ] , - 1 , " pdf object " , le_pdf ) ;
1999-08-05 16:25:10 +00:00
2000-08-28 15:19:23 +00:00
convert_to_double_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
convert_to_double_ex ( argv [ 4 ] ) ;
convert_to_string_ex ( argv [ 5 ] ) ;
convert_to_string_ex ( argv [ 6 ] ) ;
1999-08-05 16:25:10 +00:00
2001-01-03 16:05:45 +00:00
PDF_add_note ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) ,
( float ) Z_DVAL_PP ( argv [ 2 ] ) ,
( float ) Z_DVAL_PP ( argv [ 3 ] ) ,
( float ) Z_DVAL_PP ( argv [ 4 ] ) ,
Z_STRVAL_PP ( argv [ 6 ] ) ,
Z_STRVAL_PP ( argv [ 5 ] ) ,
" note " , 1 ) ;
1999-08-05 16:25:10 +00:00
RETURN_TRUE ;
}
/* }}} */
2001-01-26 08:20:24 +00:00
/* RJS: START OF NEW CODE */
2003-02-04 10:57:35 +00:00
/* {{{ proto resource pdf_new()
2001-01-26 18:52:38 +00:00
Creates a new PDF object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_new )
{
2001-01-26 08:20:24 +00:00
PDF * pdf ;
pdf = PDF_new2 ( custom_errorhandler , pdf_emalloc , pdf_realloc , pdf_efree , NULL ) ;
2001-06-06 09:58:22 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
2001-01-26 08:20:24 +00:00
PDF_set_parameter ( pdf , " imagewarning " , " true " ) ;
2001-06-06 09:58:22 +00:00
# endif
2001-02-12 17:50:39 +00:00
PDF_set_parameter ( pdf , " binding " , " PHP " ) ;
2001-01-26 08:20:24 +00:00
ZEND_REGISTER_RESOURCE ( return_value , pdf , le_pdf ) ;
}
/* }}} */
2001-08-21 13:33:16 +00:00
/* {{{ proto int pdf_get_majorversion()
Returns the major version number of the PDFlib */
PHP_FUNCTION ( pdf_get_majorversion )
{
if ( ZEND_NUM_ARGS ( ) ! = 0 ) {
WRONG_PARAM_COUNT ;
}
RETURN_LONG ( PDF_get_majorversion ( ) ) ;
}
2003-02-04 10:57:35 +00:00
/* }}} */
2001-08-21 13:33:16 +00:00
/* {{{ proto int pdf_get_minorversion()
Returns the minor version number of the PDFlib */
PHP_FUNCTION ( pdf_get_minorversion )
{
if ( ZEND_NUM_ARGS ( ) ! = 0 ) {
WRONG_PARAM_COUNT ;
}
RETURN_LONG ( PDF_get_minorversion ( ) ) ;
}
/* }}} */
2003-02-04 10:57:35 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_delete(resource pdfdoc)
2001-01-26 18:52:38 +00:00
Deletes the PDF object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_delete )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-09-10 19:28:50 +00:00
zend_list_delete ( Z_RESVAL_PP ( arg1 ) ) ;
2001-01-26 08:20:24 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_open_file(resource pdfdoc [, string filename])
2001-01-26 18:52:38 +00:00
Opens a new PDF document . If filename is NULL , document is created in memory . This is not yet fully supported */
2001-01-26 08:20:24 +00:00
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_open_file )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 ;
int pdf_file ;
char * filename ;
int argc ;
PDF * pdf ;
if ( ( argc = ZEND_NUM_ARGS ( ) ) > 2 )
WRONG_PARAM_COUNT ;
if ( argc = = 1 ) {
if ( zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE )
WRONG_PARAM_COUNT ;
} else {
if ( zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE )
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
if ( argc = = 2 ) {
convert_to_string_ex ( arg2 ) ;
filename = Z_STRVAL_PP ( arg2 ) ;
2003-05-21 00:57:34 +00:00
if ( php_check_open_basedir ( filename TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( filename , " wb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
pdf_file = PDF_open_file ( pdf , filename ) ;
} else {
/* open in memory */
pdf_file = PDF_open_file ( pdf , " " ) ;
}
if ( pdf_file = = - 1 )
RETURN_FALSE ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto string pdf_get_buffer(resource pdfdoc)
2001-01-26 18:52:38 +00:00
Fetches the full buffer containig the generated PDF data */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_get_buffer )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 ;
long size ;
PDF * pdf ;
const char * buffer ;
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
buffer = PDF_get_buffer ( pdf , & size ) ;
2001-02-21 23:30:21 +00:00
RETURN_STRINGL ( ( char * ) buffer , size , 1 ) ;
2001-01-26 08:20:24 +00:00
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_findfont(resource pdfdoc, string fontname, string encoding [, int embed])
2001-01-26 18:52:38 +00:00
Prepares the font fontname for later use with pdf_setfont ( ) */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_findfont )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
2001-02-01 07:07:10 +00:00
int embed , font ;
2001-01-26 08:20:24 +00:00
const char * fontname , * encoding ;
PDF * pdf ;
switch ( ZEND_NUM_ARGS ( ) ) {
case 3 :
if ( zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
embed = 0 ;
break ;
case 4 :
if ( zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
convert_to_long_ex ( arg4 ) ;
embed = Z_LVAL_PP ( arg4 ) ;
break ;
default :
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_string_ex ( arg2 ) ;
fontname = Z_STRVAL_PP ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
encoding = Z_STRVAL_PP ( arg3 ) ;
font = PDF_findfont ( pdf , fontname , encoding , embed ) ;
if ( font = = - 1 ) {
/* pdflib will do this for you, will throw some exception
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Font %s not found " , fontname ) ;
2001-01-26 08:20:24 +00:00
*/
RETURN_FALSE ;
}
RETURN_LONG ( font + PDFLIB_FONT_OFFSET ) ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setfont(resource pdfdoc, int font, float fontsize)
2001-01-26 18:52:38 +00:00
Sets the current font in the fiven fontsize */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_setfont )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 ;
2001-02-01 07:07:10 +00:00
int font ;
2001-01-26 08:20:24 +00:00
float fontsize ;
PDF * pdf ;
2001-02-01 07:07:10 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 )
2001-01-26 08:20:24 +00:00
WRONG_PARAM_COUNT ;
if ( zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE )
WRONG_PARAM_COUNT ;
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg2 ) ;
font = Z_LVAL_PP ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
fontsize = ( float ) Z_DVAL_PP ( arg3 ) ;
2001-02-01 07:07:10 +00:00
PDF_setfont ( pdf , font - PDFLIB_FONT_OFFSET , fontsize ) ;
2001-01-26 08:20:24 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setpolydash(resource pdfdoc, float darray)
2001-01-26 18:52:38 +00:00
Sets more complicated dash pattern */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_setpolydash )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 ;
HashTable * array ;
int len , i ;
float * darray ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_array_ex ( arg2 ) ;
array = Z_ARRVAL_PP ( arg2 ) ;
len = zend_hash_num_elements ( array ) ;
2003-04-30 21:53:53 +00:00
darray = safe_emalloc ( len , sizeof ( double ) , 0 ) ;
2001-01-26 08:20:24 +00:00
zend_hash_internal_pointer_reset ( array ) ;
for ( i = 0 ; i < len ; i + + ) {
zval * keydata , * * keydataptr ;
zend_hash_get_current_data ( array , ( void * * ) & keydataptr ) ;
keydata = * keydataptr ;
2001-09-25 21:58:48 +00:00
if ( Z_TYPE_P ( keydata ) = = IS_DOUBLE ) {
darray [ i ] = ( float ) Z_DVAL_P ( keydata ) ;
} else if ( Z_TYPE_P ( keydata ) = = IS_LONG ) {
darray [ i ] = ( float ) Z_LVAL_P ( keydata ) ;
2001-01-26 08:20:24 +00:00
} else {
2003-01-19 00:45:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " PDFlib set_polydash: illegal darray value " ) ;
2001-01-26 08:20:24 +00:00
}
zend_hash_move_forward ( array ) ;
}
PDF_setpolydash ( pdf , darray , len ) ;
efree ( darray ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_concat(resource pdf, float a, float b, float c, float d, float e, float f)
2001-01-26 18:52:38 +00:00
Concatenates a matrix to the current transformation matrix for text and graphics */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_concat )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 ;
PDF * pdf ;
2001-03-01 19:51:55 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 7 | | zend_get_parameters_ex ( 7 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 ) = = FAILURE ) {
2001-01-26 08:20:24 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_double_ex ( arg6 ) ;
2001-03-01 19:51:55 +00:00
convert_to_double_ex ( arg7 ) ;
2001-01-26 08:20:24 +00:00
PDF_concat ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
( float ) Z_DVAL_PP ( arg6 ) ,
( float ) Z_DVAL_PP ( arg7 ) ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_ccitt(resource pdf, string filename, int width, int height, int bitreverse, int k, int blackls1)
2001-01-26 18:52:38 +00:00
Opens an image file with raw CCITT G3 or G4 compresed bitmap data */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_open_ccitt )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 ;
PDF * pdf ;
2001-02-01 07:07:10 +00:00
int pdf_image ;
2001-01-26 08:20:24 +00:00
char * image ;
if ( ZEND_NUM_ARGS ( ) ! = 7 | | zend_get_parameters_ex ( 7 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_string_ex ( arg2 ) ;
# ifdef VIRTUAL_DIR
2001-08-05 01:43:02 +00:00
virtual_filepath ( Z_STRVAL_PP ( arg2 ) , & image TSRMLS_CC ) ;
2001-01-26 08:20:24 +00:00
# else
image = Z_STRVAL_PP ( arg2 ) ;
# endif
2003-05-20 00:37:00 +00:00
if ( php_check_open_basedir ( image TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( image , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
convert_to_long_ex ( arg5 ) ;
convert_to_long_ex ( arg6 ) ;
convert_to_long_ex ( arg7 ) ;
2001-01-31 17:00:11 +00:00
pdf_image = PDF_open_CCITT ( pdf ,
2001-01-26 08:20:24 +00:00
image ,
Z_LVAL_PP ( arg3 ) ,
Z_LVAL_PP ( arg4 ) ,
Z_LVAL_PP ( arg5 ) ,
Z_LVAL_PP ( arg6 ) ,
Z_LVAL_PP ( arg7 ) ) ;
RETURN_LONG ( pdf_image + PDFLIB_IMAGE_OFFSET ) ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_image(resource pdf, string type, string source, string data, long length, int width, int height, int components, int bpc, string params)
2001-01-26 18:52:38 +00:00
Opens an image of the given type and returns an image for placement in a PDF document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_open_image )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 , * * arg8 , * * arg9 , * * arg10 ;
PDF * pdf ;
2001-02-01 07:07:10 +00:00
int pdf_image ;
char * image ;
2001-01-26 08:20:24 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 10 | | zend_get_parameters_ex ( 10 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 , & arg8 , & arg9 , & arg10 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
convert_to_string_ex ( arg4 ) ;
convert_to_long_ex ( arg5 ) ;
convert_to_long_ex ( arg6 ) ;
convert_to_long_ex ( arg7 ) ;
convert_to_long_ex ( arg8 ) ;
convert_to_long_ex ( arg9 ) ;
convert_to_string_ex ( arg10 ) ;
# ifdef VIRTUAL_DIR
2001-08-05 01:43:02 +00:00
virtual_filepath ( Z_STRVAL_PP ( arg4 ) , & image TSRMLS_CC ) ;
2001-01-26 08:20:24 +00:00
# else
image = Z_STRVAL_PP ( arg4 ) ;
# endif
2003-05-20 00:37:00 +00:00
if ( php_check_open_basedir ( image TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( image , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
pdf_image = PDF_open_image ( pdf ,
Z_STRVAL_PP ( arg2 ) ,
Z_STRVAL_PP ( arg3 ) ,
image ,
Z_LVAL_PP ( arg5 ) ,
Z_LVAL_PP ( arg6 ) ,
Z_LVAL_PP ( arg7 ) ,
Z_LVAL_PP ( arg8 ) ,
Z_LVAL_PP ( arg9 ) ,
Z_STRVAL_PP ( arg10 ) ) ;
RETURN_LONG ( pdf_image + PDFLIB_IMAGE_OFFSET ) ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_attach_file(resource pdf, float lly, float lly, float urx, float ury, string filename, string description, string author, string mimetype, string icon)
2001-01-26 18:52:38 +00:00
Adds a file attachment annotation at the rectangle specified by his lower left and upper right corners */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_attach_file )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 , * * arg8 , * * arg9 , * * arg10 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 10 | | zend_get_parameters_ex ( 10 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 , & arg8 , & arg9 , & arg10 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_long_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
convert_to_long_ex ( arg5 ) ;
convert_to_string_ex ( arg6 ) ;
convert_to_string_ex ( arg7 ) ;
convert_to_string_ex ( arg8 ) ;
convert_to_string_ex ( arg9 ) ;
convert_to_string_ex ( arg10 ) ;
2003-05-20 00:37:00 +00:00
if ( php_check_open_basedir ( Z_STRVAL_PP ( arg6 ) TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( Z_STRVAL_PP ( arg6 ) , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2001-01-26 08:20:24 +00:00
PDF_attach_file ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
Z_STRVAL_PP ( arg6 ) ,
Z_STRVAL_PP ( arg7 ) ,
Z_STRVAL_PP ( arg8 ) ,
Z_STRVAL_PP ( arg9 ) ,
Z_STRVAL_PP ( arg10 ) ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_add_note(resource pdfdoc, float llx, float lly, float urx, float ury, string contents, string title, string icon, int open)
2001-01-26 08:20:24 +00:00
Sets annotation */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_add_note )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 , * * arg8 , * * arg9 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 9 | | zend_get_parameters_ex ( 9 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 , & arg8 , & arg9 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_string_ex ( arg6 ) ;
convert_to_string_ex ( arg7 ) ;
convert_to_string_ex ( arg8 ) ;
convert_to_long_ex ( arg9 ) ;
PDF_add_note ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
Z_STRVAL_PP ( arg6 ) ,
Z_STRVAL_PP ( arg7 ) ,
Z_STRVAL_PP ( arg8 ) ,
Z_LVAL_PP ( arg9 ) ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_add_locallink(resource pdfdoc, float llx, float lly, float urx, float ury, int page, string dest)
2003-08-11 11:27:27 +00:00
Adds link to local resource */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_add_locallink )
{
2001-01-26 08:20:24 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 ;
PDF * pdf ;
2001-02-01 07:07:10 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 7 | | zend_get_parameters_ex ( 7 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 ) = = FAILURE ) {
2001-01-26 08:20:24 +00:00
WRONG_PARAM_COUNT ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_long_ex ( arg6 ) ;
convert_to_string_ex ( arg7 ) ;
PDF_add_locallink ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
Z_LVAL_PP ( arg6 ) ,
Z_STRVAL_PP ( arg7 ) ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_add_launchlink(resource pdfdoc, float llx, float lly, float urx, float ury, string filename)
2001-01-26 08:20:24 +00:00
Adds link to web resource */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_add_launchlink )
{
2001-01-26 08:20:24 +00:00
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 ;
}
2001-02-01 07:07:10 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
2001-01-26 08:20:24 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_string_ex ( arg6 ) ;
PDF_add_launchlink ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
Z_STRVAL_PP ( arg6 ) ) ;
RETURN_TRUE ;
}
/* }}} */
2001-03-01 19:51:55 +00:00
# if (PDFLIB_MAJORVERSION >= 4)
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_pdi(resource pdf, string filename, string stringparam, int intparam);
2001-03-01 19:51:55 +00:00
* Open an existing PDF document and prepare it for later use . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_open_pdi )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
PDF * pdf ;
int pdi_handle ;
char * file ;
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
# ifdef VIRTUAL_DIR
2001-08-07 17:26:37 +00:00
virtual_filepath ( Z_STRVAL_PP ( arg2 ) , & file TSRMLS_CC ) ;
2001-03-01 19:51:55 +00:00
# else
file = Z_STRVAL_PP ( arg2 ) ;
# endif
2003-05-20 00:37:00 +00:00
if ( php_check_open_basedir ( file TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( file , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2001-03-01 19:51:55 +00:00
pdi_handle = PDF_open_pdi ( pdf ,
file ,
Z_STRVAL_PP ( arg3 ) ,
Z_LVAL_PP ( arg4 ) ) ;
RETURN_LONG ( pdi_handle + PDFLIB_PDI_OFFSET ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_close_pdi(resource pdf, int doc);
2001-03-01 19:51:55 +00:00
* Close all open page handles , and close the input PDF document . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_close_pdi )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 ;
PDF * pdf ;
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 ) ;
2003-06-22 14:33:09 +00:00
PDF_close_pdi ( pdf , Z_LVAL_PP ( arg2 ) - PDFLIB_PDI_OFFSET ) ;
2001-03-01 19:51:55 +00:00
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_open_pdi_page(resource pdf, int doc, int page, string label);
2001-03-01 19:51:55 +00:00
* Prepare a page for later use with PDF_place_image ( ) . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_open_pdi_page )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
PDF * pdf ;
int pdi_image ;
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = 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 ) ;
convert_to_string_ex ( arg4 ) ;
pdi_image = PDF_open_pdi_page ( pdf ,
Z_LVAL_PP ( arg2 ) - PDFLIB_PDI_OFFSET ,
Z_LVAL_PP ( arg3 ) ,
Z_STRVAL_PP ( arg4 ) ) ;
RETURN_LONG ( pdi_image + PDFLIB_IMAGE_OFFSET ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_place_pdi_page(resource pdf, int page, float x, float y, float sx, float sy)
2001-03-21 20:55:35 +00:00
* Place a PDF page with the lower left corner at ( x , y ) , and scale it . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_place_pdi_page )
{
2001-03-21 20:55:35 +00:00
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 ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-21 20:55:35 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_close_pdi_page(resource pdf, int page);
2001-03-01 19:51:55 +00:00
* Close the page handle , and free all page - related resources . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_close_pdi_page )
{
2001-03-21 20:55:35 +00:00
zval * * arg1 , * * arg2 ;
2001-03-01 19:51:55 +00:00
PDF * pdf ;
2001-03-21 20:55:35 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
2001-03-01 19:51:55 +00:00
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
convert_to_long_ex ( arg2 ) ;
2003-06-22 14:33:09 +00:00
PDF_close_pdi_page ( pdf , Z_LVAL_PP ( arg2 ) - PDFLIB_IMAGE_OFFSET ) ;
2001-03-01 19:51:55 +00:00
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto string pdf_get_pdi_parameter(resource pdf, string key, int doc, int page, int index);
2001-03-01 19:51:55 +00:00
* Get the contents of some PDI document parameter with string type . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_get_pdi_parameter )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 ;
PDF * pdf ;
const char * buffer ;
int size ;
if ( ZEND_NUM_ARGS ( ) ! = 5 | | zend_get_parameters_ex ( 5 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
convert_to_long_ex ( arg5 ) ;
buffer = PDF_get_pdi_parameter ( pdf ,
Z_STRVAL_PP ( arg2 ) ,
Z_LVAL_PP ( arg3 ) - PDFLIB_PDI_OFFSET ,
Z_LVAL_PP ( arg4 ) - PDFLIB_IMAGE_OFFSET ,
Z_LVAL_PP ( arg5 ) ,
& size ) ;
RETURN_STRINGL ( ( char * ) buffer , size , 1 ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto float pdf_get_pdi_value(resource pdf, string key, int doc, int page, int index);
2001-03-01 19:51:55 +00:00
* Get the contents of some PDI document parameter with numerical type . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_get_pdi_value )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 ;
PDF * pdf ;
double value ;
if ( ZEND_NUM_ARGS ( ) ! = 5 | | zend_get_parameters_ex ( 5 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
convert_to_long_ex ( arg5 ) ;
value = ( double ) PDF_get_pdi_value ( pdf ,
Z_STRVAL_PP ( arg2 ) ,
Z_LVAL_PP ( arg3 ) - PDFLIB_PDI_OFFSET ,
Z_LVAL_PP ( arg4 ) - PDFLIB_IMAGE_OFFSET ,
Z_LVAL_PP ( arg5 ) ) ;
RETURN_DOUBLE ( value ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_begin_pattern(resource pdf, float width, float height, float xstep, float ystep, int painttype);
2001-03-01 19:51:55 +00:00
* Start a new pattern definition . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_begin_pattern )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 ;
PDF * pdf ;
int pattern_image ;
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_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_long_ex ( arg6 ) ;
pattern_image = PDF_begin_pattern ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
Z_LVAL_PP ( arg6 ) ) ;
RETURN_LONG ( pattern_image + PDFLIB_PATTERN_OFFSET ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_end_pattern(resource pdf);
2001-03-01 19:51:55 +00:00
* Finish the pattern definition . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_end_pattern )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
PDF_end_pattern ( pdf ) ;
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_begin_template(resource pdf, float width, float height);
2001-03-01 19:51:55 +00:00
* Start a new template definition . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_begin_template )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 ;
PDF * pdf ;
int tmpl_image ;
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
tmpl_image = PDF_begin_template ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ) ;
RETURN_LONG ( tmpl_image + PDFLIB_IMAGE_OFFSET ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_end_template(resource pdf);
2001-03-01 19:51:55 +00:00
* Finish the template definition . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_end_template )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
PDF_end_template ( pdf ) ;
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setcolor(resource pdf, string type, string colorspace, float c1 [, float c2 [, float c3 [, float c4]]]);
2001-03-01 19:51:55 +00:00
* Set the current color space and color . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_setcolor )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 ;
PDF * pdf ;
2001-03-21 20:55:35 +00:00
double c1 ;
2001-05-27 00:01:55 +00:00
int argc = ZEND_NUM_ARGS ( ) ;
2001-03-01 19:51:55 +00:00
2001-05-27 00:01:55 +00:00
if ( argc < 4 | | argc > 7 ) {
2001-03-01 19:51:55 +00:00
WRONG_PARAM_COUNT ;
}
2001-05-27 00:01:55 +00:00
switch ( argc ) {
case 4 :
if ( zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
break ;
case 5 :
if ( zend_get_parameters_ex ( 5 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
break ;
case 6 :
if ( zend_get_parameters_ex ( 6 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
break ;
case 7 :
2001-05-30 12:30:14 +00:00
if ( zend_get_parameters_ex ( 7 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 ) = = FAILURE ) {
2001-05-27 00:01:55 +00:00
WRONG_PARAM_COUNT ;
}
break ;
}
2001-03-01 19:51:55 +00:00
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
2001-05-27 00:01:55 +00:00
if ( argc > 4 ) convert_to_double_ex ( arg5 ) ;
if ( argc > 5 ) convert_to_double_ex ( arg6 ) ;
if ( argc > 6 ) convert_to_double_ex ( arg7 ) ;
2001-03-01 19:51:55 +00:00
if ( 0 = = ( strcmp ( Z_STRVAL_PP ( arg3 ) , " spot " ) ) ) {
2001-03-21 20:55:35 +00:00
c1 = Z_DVAL_PP ( arg4 ) - PDFLIB_SPOT_OFFSET ;
2001-03-01 19:51:55 +00:00
} else if ( 0 = = ( strcmp ( Z_STRVAL_PP ( arg3 ) , " pattern " ) ) ) {
2001-03-21 20:55:35 +00:00
c1 = Z_DVAL_PP ( arg4 ) - PDFLIB_PATTERN_OFFSET ;
2001-03-01 19:51:55 +00:00
} else {
2001-03-21 20:55:35 +00:00
c1 = Z_DVAL_PP ( arg4 ) ;
2001-03-01 19:51:55 +00:00
}
PDF_setcolor ( pdf ,
Z_STRVAL_PP ( arg2 ) ,
Z_STRVAL_PP ( arg3 ) ,
( float ) c1 ,
2001-05-27 00:01:55 +00:00
( float ) ( ( argc > 4 ) ? Z_DVAL_PP ( arg5 ) : 0 ) ,
( float ) ( ( argc > 5 ) ? Z_DVAL_PP ( arg6 ) : 0 ) ,
( float ) ( ( argc > 6 ) ? Z_DVAL_PP ( arg7 ) : 0 ) ) ;
2001-03-01 19:51:55 +00:00
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto int pdf_makespotcolor(resource pdf, string spotname);
2001-03-01 19:51:55 +00:00
* Make a named spot color from the current color . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_makespotcolor )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 ;
PDF * pdf ;
int spotcolor ;
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_string_ex ( arg2 ) ;
spotcolor = PDF_makespotcolor ( pdf ,
Z_STRVAL_PP ( arg2 ) ,
Z_STRLEN_PP ( arg2 ) ) ;
RETURN_LONG ( spotcolor + PDFLIB_SPOT_OFFSET ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_arcn(resource pdf, float x, float y, float r, float alpha, float beta);
2001-03-01 19:51:55 +00:00
* Draw a clockwise circular arc from alpha to beta degrees . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_arcn )
{
2001-03-01 19:51:55 +00:00
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_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_double_ex ( arg6 ) ;
PDF_arcn ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
( float ) Z_DVAL_PP ( arg6 ) ) ;
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_initgraphics(resource pdf);
2001-03-01 19:51:55 +00:00
* Reset all implicit color and graphics state parameters to their defaults . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_initgraphics )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
PDF_initgraphics ( pdf ) ;
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_add_thumbnail(resource pdf, int image);
2001-03-01 19:51:55 +00:00
* Add an existing image as thumbnail for the current page . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_add_thumbnail )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 ;
PDF * pdf ;
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 ) ;
PDF_add_thumbnail ( pdf ,
Z_LVAL_PP ( arg2 ) - PDFLIB_IMAGE_OFFSET ) ;
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
2003-06-22 14:33:09 +00:00
/* {{{ proto bool pdf_setmatrix(resource pdf, float a, float b, float c, float d, float e, float f)
2001-03-01 19:51:55 +00:00
Explicitly set the current transformation matrix . */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( pdf_setmatrix )
{
2001-03-01 19:51:55 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 , * * arg7 ;
PDF * pdf ;
if ( ZEND_NUM_ARGS ( ) ! = 7 | | zend_get_parameters_ex ( 7 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 , & arg7 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
ZEND_FETCH_RESOURCE ( pdf , PDF * , arg1 , - 1 , " pdf object " , le_pdf ) ;
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_double_ex ( arg5 ) ;
convert_to_double_ex ( arg6 ) ;
convert_to_double_ex ( arg7 ) ;
PDF_setmatrix ( pdf ,
( float ) Z_DVAL_PP ( arg2 ) ,
( float ) Z_DVAL_PP ( arg3 ) ,
( float ) Z_DVAL_PP ( arg4 ) ,
( float ) Z_DVAL_PP ( arg5 ) ,
( float ) Z_DVAL_PP ( arg6 ) ,
( float ) Z_DVAL_PP ( arg7 ) ) ;
RETURN_TRUE ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-03-01 19:51:55 +00:00
# endif /* PDFlib >= V4 */
1999-04-22 02:48:28 +00:00
# endif
/*
* Local variables :
* tab - width : 4
* c - basic - offset : 4
* End :
2001-09-09 13:29:31 +00:00
* vim600 : sw = 4 ts = 4 fdm = marker
* vim < 600 : sw = 4 ts = 4
1999-04-22 02:48:28 +00:00
*/