1999-11-22 15:28:26 +00:00
/*
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2004-01-08 08:18:22 +00:00
| PHP Version 5 |
1999-11-22 15:28:26 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2004-01-08 08:18:22 +00:00
| Copyright ( c ) 1997 - 2004 The PHP Group |
1999-11-22 15:28:26 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2003-06-10 20:04:29 +00:00
| This source file is subject to version 3.0 of the PHP license , |
2001-06-06 13:06:12 +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-06-06 13:06:12 +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-11-22 15:28:26 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2002-02-28 08:29:35 +00:00
| Author : Uwe Steinmann < Uwe . Steinmann @ fernuni - hagen . de > |
1999-11-22 15:28:26 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
*/
/* $Id$ */
/* cpdflib.h -- C language API definitions for ClibPDF library
* Copyright ( C ) 1998 FastIO Systems , All Rights Reserved .
*/
/* Note that there is no code from the cpdflib package in this file */
2002-08-13 21:35:54 +00:00
# if defined(THREAD_SAFE)
1999-11-22 15:28:26 +00:00
# undef THREAD_SAFE
# endif
2001-05-24 10:07:29 +00:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
1999-11-22 15:28:26 +00:00
# include "php.h"
# include "php_globals.h"
2001-06-28 21:59:26 +00:00
# include "zend_list.h"
2000-02-02 11:18:06 +00:00
# include "ext/standard/php_standard.h"
# include "ext/standard/head.h"
1999-11-22 15:28:26 +00:00
# include <math.h>
2002-12-06 16:33:57 +00:00
# if HAVE_GD_BUNDLED
# include ".. / gd / libgd / gd.h"
# else
# if HAVE_LIBGD13
# include <gd.h>
# endif
1999-11-22 15:28:26 +00:00
# endif
2003-01-15 00:52:06 +00:00
# include <cpdflib.h>
1999-11-22 15:28:26 +00:00
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
2000-06-15 23:45:05 +00:00
# ifdef PHP_WIN32
1999-11-22 15:28:26 +00:00
# include <io.h>
# include <fcntl.h>
# endif
# if HAVE_CPDFLIB
1999-12-04 19:19:57 +00:00
# include "php_cpdf.h"
2000-04-05 22:30:19 +00:00
# include "ext/standard/info.h"
1999-11-22 15:28:26 +00:00
# ifdef THREAD_SAFE
DWORD CPDFlibTls ;
static int numthreads = 0 ;
typedef struct cpdflib_global_struct {
int le_cpdf ;
int le_outline ;
2001-05-21 21:06:08 +00:00
# if HAVE_LIBGD13
int le_gd ;
# endif
1999-11-22 15:28:26 +00:00
} cpdflib_global_struct ;
2001-07-28 11:36:37 +00:00
# define CPDF_GLOBAL(v) TSRMG(CPDFlibTls, cpdflib_global_struct *, v)
1999-11-22 15:28:26 +00:00
# else
2001-07-28 11:36:37 +00:00
# define CPDF_GLOBAL(a) a
1999-11-22 15:28:26 +00:00
static int le_cpdf ;
static int le_outline ;
2001-05-21 21:06:08 +00:00
# if HAVE_LIBGD13
static int le_gd ;
# endif
1999-11-22 15:28:26 +00:00
# endif
2003-01-14 15:15:53 +00:00
# define CPDF_FETCH_CPDFDOC(pdf_zval) \
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( pdf_zval ) ; \
id = Z_LVAL_PP ( pdf_zval ) ; \
2003-01-14 15:15:53 +00:00
pdf = zend_list_find ( id , & type ) ; \
if ( ! pdf | | type ! = CPDF_GLOBAL ( le_cpdf ) ) { \
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Unable to find identifier %d " , id ) ; \
RETURN_FALSE ; \
} \
1999-11-22 15:28:26 +00:00
function_entry cpdf_functions [ ] = {
2000-01-10 12:42:05 +00:00
PHP_FE ( cpdf_global_set_document_limits , NULL )
1999-11-22 15:28:26 +00:00
PHP_FE ( cpdf_set_creator , NULL )
PHP_FE ( cpdf_set_title , NULL )
PHP_FE ( cpdf_set_subject , NULL )
PHP_FE ( cpdf_set_keywords , NULL )
PHP_FE ( cpdf_open , NULL )
PHP_FE ( cpdf_close , NULL )
PHP_FE ( cpdf_set_viewer_preferences , NULL )
PHP_FE ( cpdf_page_init , NULL )
PHP_FE ( cpdf_finalize_page , NULL )
PHP_FE ( cpdf_set_current_page , NULL )
PHP_FE ( cpdf_begin_text , NULL )
PHP_FE ( cpdf_end_text , NULL )
PHP_FE ( cpdf_show , NULL )
PHP_FE ( cpdf_show_xy , NULL )
PHP_FE ( cpdf_text , NULL )
PHP_FE ( cpdf_continue_text , NULL )
PHP_FE ( cpdf_set_font , NULL )
2001-03-30 20:36:18 +00:00
PHP_FE ( cpdf_set_font_directories , NULL )
PHP_FE ( cpdf_set_font_map_file , NULL )
1999-11-22 15:28:26 +00:00
PHP_FE ( cpdf_set_leading , NULL )
PHP_FE ( cpdf_set_text_rendering , NULL )
PHP_FE ( cpdf_set_horiz_scaling , NULL )
PHP_FE ( cpdf_set_text_rise , NULL )
PHP_FE ( cpdf_set_text_matrix , NULL )
PHP_FE ( cpdf_set_text_pos , NULL )
PHP_FE ( cpdf_rotate_text , NULL )
PHP_FE ( cpdf_set_char_spacing , NULL )
PHP_FE ( cpdf_set_word_spacing , NULL )
PHP_FE ( cpdf_stringwidth , NULL )
PHP_FE ( cpdf_save , NULL )
PHP_FE ( cpdf_restore , NULL )
PHP_FE ( cpdf_translate , NULL )
PHP_FE ( cpdf_scale , NULL )
PHP_FE ( cpdf_rotate , NULL )
PHP_FE ( cpdf_setflat , NULL )
PHP_FE ( cpdf_setlinejoin , NULL )
PHP_FE ( cpdf_setlinecap , NULL )
PHP_FE ( cpdf_setmiterlimit , NULL )
PHP_FE ( cpdf_setlinewidth , NULL )
PHP_FE ( cpdf_setdash , NULL )
PHP_FE ( cpdf_moveto , NULL )
PHP_FE ( cpdf_rmoveto , NULL )
PHP_FE ( cpdf_lineto , NULL )
PHP_FE ( cpdf_rlineto , NULL )
PHP_FE ( cpdf_curveto , NULL )
PHP_FE ( cpdf_circle , NULL )
PHP_FE ( cpdf_arc , NULL )
PHP_FE ( cpdf_rect , NULL )
PHP_FE ( cpdf_newpath , NULL )
PHP_FE ( cpdf_closepath , NULL )
PHP_FE ( cpdf_stroke , NULL )
PHP_FE ( cpdf_closepath_stroke , NULL )
PHP_FE ( cpdf_fill , NULL )
PHP_FE ( cpdf_fill_stroke , NULL )
PHP_FE ( cpdf_closepath_fill_stroke , NULL )
PHP_FE ( cpdf_clip , NULL )
PHP_FE ( cpdf_setgray_fill , NULL )
PHP_FE ( cpdf_setgray_stroke , NULL )
PHP_FE ( cpdf_setgray , NULL )
PHP_FE ( cpdf_setrgbcolor_fill , NULL )
PHP_FE ( cpdf_setrgbcolor_stroke , NULL )
PHP_FE ( cpdf_setrgbcolor , NULL )
PHP_FE ( cpdf_set_page_animation , NULL )
PHP_FE ( cpdf_finalize , NULL )
PHP_FE ( cpdf_output_buffer , NULL )
PHP_FE ( cpdf_save_to_file , NULL )
PHP_FE ( cpdf_import_jpeg , NULL )
# if HAVE_LIBGD13
PHP_FE ( cpdf_place_inline_image , NULL )
# endif
PHP_FE ( cpdf_add_annotation , NULL )
PHP_FE ( cpdf_add_outline , NULL )
PHP_FE ( cpdf_set_action_url , NULL )
{ NULL , NULL , NULL }
} ;
1999-12-17 20:55:31 +00:00
zend_module_entry cpdf_module_entry = {
2001-10-11 23:33:59 +00:00
STANDARD_MODULE_HEADER ,
" cpdf " ,
cpdf_functions ,
PHP_MINIT ( cpdf ) ,
PHP_MSHUTDOWN ( cpdf ) ,
PHP_RINIT ( cpdf ) ,
NULL ,
PHP_MINFO ( cpdf ) ,
NO_VERSION_YET ,
STANDARD_MODULE_PROPERTIES
1999-11-22 15:28:26 +00:00
} ;
2000-05-23 09:33:51 +00:00
# ifdef COMPILE_DL_CPDF
2000-05-02 00:30:36 +00:00
ZEND_GET_MODULE ( cpdf )
1999-11-22 15:28:26 +00:00
# endif
2001-07-31 05:44:11 +00:00
static void _free_outline ( zend_rsrc_list_entry * rsrc TSRMLS_DC )
1999-11-22 15:28:26 +00:00
{
}
2001-07-31 05:44:11 +00:00
static void _free_doc ( zend_rsrc_list_entry * rsrc TSRMLS_DC )
1999-11-22 15:28:26 +00:00
{
2000-10-20 18:25:16 +00:00
CPDFdoc * pdf = ( CPDFdoc * ) rsrc - > ptr ;
2001-07-31 05:44:11 +00:00
1999-11-22 15:28:26 +00:00
cpdf_close ( pdf ) ;
}
PHP_MINIT_FUNCTION ( cpdf )
{
2000-10-25 17:44:02 +00:00
CPDF_GLOBAL ( le_outline ) = zend_register_list_destructors_ex ( _free_outline , NULL , " cpdf outline " , module_number ) ;
CPDF_GLOBAL ( le_cpdf ) = zend_register_list_destructors_ex ( _free_doc , NULL , " cpdf " , module_number ) ;
2001-03-30 20:36:18 +00:00
REGISTER_LONG_CONSTANT ( " CPDF_PM_NONE " , PM_NONE , CONST_CS | CONST_PERSISTENT ) ;
REGISTER_LONG_CONSTANT ( " CPDF_PM_OUTLINES " , PM_OUTLINES , CONST_CS | CONST_PERSISTENT ) ;
REGISTER_LONG_CONSTANT ( " CPDF_PM_THUMBS " , PM_THUMBS , CONST_CS | CONST_PERSISTENT ) ;
REGISTER_LONG_CONSTANT ( " CPDF_PM_FULLSCREEN " , PM_FULLSCREEN , CONST_CS | CONST_PERSISTENT ) ;
REGISTER_LONG_CONSTANT ( " CPDF_PL_SINGLE " , PL_SINGLE , CONST_CS | CONST_PERSISTENT ) ;
REGISTER_LONG_CONSTANT ( " CPDF_PL_1COLUMN " , PL_1COLUMN , CONST_CS | CONST_PERSISTENT ) ;
REGISTER_LONG_CONSTANT ( " CPDF_PL_2LCOLUMN " , PL_2LCOLUMN , CONST_CS | CONST_PERSISTENT ) ;
REGISTER_LONG_CONSTANT ( " CPDF_PL_2RCOLUMN " , PL_2RCOLUMN , CONST_CS | CONST_PERSISTENT ) ;
1999-11-22 15:28:26 +00:00
return SUCCESS ;
}
PHP_RINIT_FUNCTION ( cpdf )
{
/* CPDF_GLOBAL(le_outline) = NULL; */
return SUCCESS ;
}
PHP_MINFO_FUNCTION ( cpdf ) {
/* need to use a PHPAPI function here because it is external module in windows */
2000-04-05 22:30:19 +00:00
/* (don't knwo if that still applies (cmv) */
php_info_print_table_start ( ) ;
php_info_print_table_row ( 2 , " CPDF Support " , " enabled " ) ;
php_info_print_table_row ( 2 , " Version " , cpdf_version ( ) ) ;
php_info_print_table_end ( ) ;
1999-11-22 15:28:26 +00:00
}
2001-07-30 06:18:13 +00:00
PHP_MSHUTDOWN_FUNCTION ( cpdf )
{
1999-11-22 15:28:26 +00:00
return SUCCESS ;
}
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_global_set_document_limits(int maxPages, int maxFonts, int maxImages, int maxAnnots, int maxObjects)
2000-01-10 11:01:56 +00:00
Sets document settings for all documents */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_global_set_document_limits )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 5 ] ;
2000-01-10 11:01:56 +00:00
2003-01-14 19:59:48 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 5 | | ( zend_get_parameters_array_ex ( 5 , argv ) = = FAILURE ) ) {
2000-01-10 11:01:56 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
2000-01-10 11:01:56 +00:00
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 0 ] ) ;
convert_to_long_ex ( argv [ 1 ] ) ;
convert_to_long_ex ( argv [ 2 ] ) ;
convert_to_long_ex ( argv [ 3 ] ) ;
convert_to_long_ex ( argv [ 4 ] ) ;
2000-01-10 11:01:56 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setGlobalDocumentLimits ( Z_LVAL_PP ( argv [ 0 ] ) , Z_LVAL_PP ( argv [ 1 ] ) , Z_LVAL_PP ( argv [ 2 ] ) , Z_LVAL_PP ( argv [ 3 ] ) , Z_LVAL_PP ( argv [ 4 ] ) ) ;
2000-01-10 11:01:56 +00:00
RETURN_TRUE ;
}
/* }}} */
1999-11-22 15:28:26 +00:00
/* {{{ proto bool cpdf_set_creator(int pdfdoc, string creator)
Sets the creator field */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_creator )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | ( zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setCreator ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto bool cpdf_set_title(int pdfptr, string title)
Fills the title field of the info structure */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_title )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setTitle ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto bool cpdf_set_subject(int pdfptr, string subject)
Fills the subject field of the info structure */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_subject )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setSubject ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto bool cpdf_set_keywords(int pdfptr, string keywords)
Fills the keywords field of the info structure */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_keywords )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setKeywords ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_viewer_preferences(int pdfdoc, array preferences)
2001-03-30 20:36:18 +00:00
How to show the document in the viewer */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_viewer_preferences )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
2001-03-30 20:36:18 +00:00
zval * * zvalue ;
int id , type ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2001-03-30 20:36:18 +00:00
CPDFviewerPrefs vP = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | ( zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_array_ex ( arg2 ) ;
2001-03-30 20:36:18 +00:00
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " pagemode " , sizeof ( " pagemode " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . pageMode = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " hidetoolbar " , sizeof ( " hidetoolbar " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . hideToolbar = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " hidemenubar " , sizeof ( " hidemenubar " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . hideMenubar = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " hidewindowui " , sizeof ( " hidewindowui " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . hideWindowUI = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " fitwindow " , sizeof ( " fitwindow " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . fitWindow = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " centerwindow " , sizeof ( " centerwindow " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . centerWindow = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " pagelayout " , sizeof ( " pagelayout " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . pageLayout = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
2003-01-14 18:54:44 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( arg2 ) , " nonfspagemode " , sizeof ( " nonfspagemode " ) , ( void * * ) & zvalue ) = = SUCCESS ) {
convert_to_long_ex ( zvalue ) ;
vP . nonFSPageMode = Z_LVAL_PP ( zvalue ) ;
2001-03-30 20:36:18 +00:00
}
cpdf_setViewerPreferences ( pdf , & vP ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto int cpdf_open(int compression [, string filename [, array doc_limits]])
Opens a new pdf document */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_open )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 = NULL , * * arg3 = NULL ;
int id ;
1999-11-22 15:28:26 +00:00
CPDFdoc * cpdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) < 1 | | ZEND_NUM_ARGS ( ) > 3 | | ( zend_get_parameters_ex ( ZEND_NUM_ARGS ( ) , & arg1 , & arg2 , & arg3 ) = = FAILURE ) ) {
WRONG_PARAM_COUNT ;
1999-11-22 15:28:26 +00:00
}
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf = cpdf_open ( 0 , NULL ) ;
if ( ! cpdf )
RETURN_FALSE ;
2003-01-14 18:54:44 +00:00
if ( Z_LVAL_PP ( arg1 ) = = 1 )
1999-11-22 15:28:26 +00:00
cpdf_enableCompression ( cpdf , YES ) ;
else
cpdf_enableCompression ( cpdf , NO ) ;
2003-01-14 18:54:44 +00:00
if ( arg2 ) {
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
# if APACHE
2003-01-14 18:54:44 +00:00
if ( strcmp ( Z_STRVAL_PP ( arg2 ) , " - " ) = = 0 )
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Writing to stdout as described in the ClibPDF manual is not possible if php is used as an Apache module. Write to a memory stream and use cpdf_output_buffer() instead. " ) ;
1999-11-22 15:28:26 +00:00
# endif
2003-05-21 00:57:34 +00:00
if ( php_check_open_basedir ( Z_STRVAL_PP ( arg2 ) TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( Z_STRVAL_PP ( arg2 ) , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
2004-02-19 02:19:11 +00:00
cpdf_close ( cpdf ) ;
2003-05-21 00:57:34 +00:00
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
cpdf_setOutputFilename ( cpdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
}
cpdf_init ( cpdf ) ;
1999-12-17 19:51:39 +00:00
id = zend_list_insert ( cpdf , CPDF_GLOBAL ( le_cpdf ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_LONG ( id ) ;
}
/* }}} */
2003-08-15 12:08:15 +00:00
/* {{{ proto bool cpdf_close(int pdfdoc)
1999-11-22 15:28:26 +00:00
Closes the pdf document */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_close )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-12-17 19:51:39 +00:00
zend_list_delete ( id ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
# define BUFFERLEN 40
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_page_init(int pdfdoc, int pagenr, int orientation, int height, int width [, float unit])
1999-11-22 15:28:26 +00:00
Starts page */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_page_init )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 6 ] ;
1999-11-22 15:28:26 +00:00
int id , type , pagenr , orientation ;
2003-01-14 18:54:44 +00:00
int height , width ;
1999-11-22 15:28:26 +00:00
char buffer [ BUFFERLEN ] ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
int argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
if ( argc < 5 | | argc > 6 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 1 ] ) ;
convert_to_long_ex ( argv [ 2 ] ) ;
convert_to_long_ex ( argv [ 3 ] ) ;
convert_to_long_ex ( argv [ 4 ] ) ;
pagenr = Z_LVAL_PP ( argv [ 1 ] ) ;
orientation = Z_LVAL_PP ( argv [ 2 ] ) ;
height = Z_LVAL_PP ( argv [ 3 ] ) ;
width = Z_LVAL_PP ( argv [ 4 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 5 ) {
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 5 ] ) ;
if ( Z_DVAL_PP ( argv [ 5 ] ) > 0.0 )
cpdf_setDefaultDomainUnit ( pdf , Z_DVAL_PP ( argv [ 5 ] ) ) ;
1999-11-22 15:28:26 +00:00
}
snprintf ( buffer , BUFFERLEN , " 0 0 %d %d " , width , height ) ;
cpdf_pageInit ( pdf , pagenr , orientation , buffer , buffer ) ;
RETURN_TRUE ;
}
/* }}} */
# undef BUFFERLEN
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_finalize_page(int pdfdoc, int pagenr)
1999-11-22 15:28:26 +00:00
Ends the page to save memory */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_finalize_page )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type , pagenr ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg2 ) ;
pagenr = Z_LVAL_PP ( arg2 ) ;
2003-01-14 15:15:53 +00:00
1999-11-22 15:28:26 +00:00
cpdf_finalizePage ( pdf , pagenr ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_current_page(int pdfdoc, int pagenr)
1999-11-22 15:28:26 +00:00
Sets page for output */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_current_page )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type , pagenr ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg2 ) ;
pagenr = Z_LVAL_PP ( arg2 ) ;
1999-11-22 15:28:26 +00:00
cpdf_setCurrentPage ( pdf , pagenr ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_begin_text(int pdfdoc)
1999-11-22 15:28:26 +00:00
Starts text section */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_begin_text )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_beginText ( pdf , 0 ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_end_text(int pdfdoc)
1999-11-22 15:28:26 +00:00
Ends text section */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_end_text )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_endText ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_show(int pdfdoc, string text)
1999-11-22 15:28:26 +00:00
Output text at current position */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_show )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_textShow ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_show_xy(int pdfdoc, string text, float x-koor, float y-koor [, int mode])
1999-11-22 15:28:26 +00:00
Output text at position */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_show_xy )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 5 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
2003-01-14 18:54:44 +00:00
if ( argc < 4 | | argc > 5 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc = = 5 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 4 ] ) ;
mode = Z_LVAL_PP ( argv [ 4 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawText ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , 0.0 , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_text ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , 0.0 , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_continue_text(int pdfdoc, string text)
2001-12-02 09:41:27 +00:00
Outputs text in next line */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_continue_text )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_textCRLFshow ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_text(int pdfdoc, string text [, float x-koor, float y-koor [, int mode [, float orientation [, int alignmode]]]])
2001-12-02 09:41:27 +00:00
Outputs text */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_text )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 7 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 2 | | argc = = 3 | | argc > 7 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
WRONG_PARAM_COUNT ;
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( argv [ 1 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 4 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 4 ] ) ;
mode = Z_LVAL_PP ( argv [ 2 ] ) ;
1999-11-22 15:28:26 +00:00
}
switch ( argc ) {
case 2 :
2003-01-14 18:54:44 +00:00
cpdf_textShow ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
break ;
case 4 :
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
cpdf_text ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , 0.0 , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
break ;
case 5 :
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawText ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , 0.0 , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_text ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , 0.0 , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
break ;
case 6 :
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
convert_to_double_ex ( argv [ 5 ] ) ;
1999-11-22 15:28:26 +00:00
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawText ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , ( float ) Z_DVAL_PP ( argv [ 5 ] ) , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_text ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , ( float ) Z_DVAL_PP ( argv [ 5 ] ) , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
break ;
case 7 :
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
convert_to_double_ex ( argv [ 5 ] ) ;
convert_to_long_ex ( argv [ 6 ] ) ;
1999-11-22 15:28:26 +00:00
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawTextAligned ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , ( float ) Z_DVAL_PP ( argv [ 5 ] ) , Z_LVAL_PP ( argv [ 6 ] ) , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_textAligned ( pdf , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) , ( float ) Z_DVAL_PP ( argv [ 5 ] ) , Z_LVAL_PP ( argv [ 6 ] ) , Z_STRVAL_PP ( argv [ 1 ] ) ) ;
1999-11-22 15:28:26 +00:00
break ;
}
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_font(int pdfdoc, string font, float size, string encoding)
2001-12-02 09:41:27 +00:00
Selects the current font face , size and encoding */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_font )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2004-07-01 04:43:29 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_string_ex ( arg4 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
/* if(Z_LVAL_PP(arg4) > 6) {
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Font encoding set to 5 " ) ;
2003-01-14 18:54:44 +00:00
Z_LVAL_PP ( arg4 ) = 5 ;
1999-11-22 15:28:26 +00:00
}
2000-03-09 14:59:05 +00:00
*/
2003-01-14 18:54:44 +00:00
cpdf_setFont ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRVAL_PP ( arg4 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_font_directories(int pdfdoc, string pfmdir, string pfbdir)
2001-12-02 09:41:27 +00:00
Sets directories to search when using external fonts */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_font_directories )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 ;
2001-03-30 20:36:18 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
2001-03-30 20:36:18 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
2001-03-30 20:36:18 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setFontDirectories ( pdf , Z_STRVAL_PP ( arg2 ) , Z_STRVAL_PP ( arg3 ) ) ;
2001-03-30 20:36:18 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_font_map_file(int pdfdoc, string filename)
2001-12-02 09:41:27 +00:00
Sets fontname to filename translation map when using external fonts */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_font_map_file )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
2001-03-30 20:36:18 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
2001-03-30 20:36:18 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
2001-03-30 20:36:18 +00:00
2003-05-21 00:57:34 +00:00
if ( php_check_open_basedir ( Z_STRVAL_PP ( arg2 ) TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( Z_STRVAL_PP ( arg2 ) , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
cpdf_setFontMapFile ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
2001-03-30 20:36:18 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_leading(int pdfdoc, float distance)
1999-11-22 15:28:26 +00:00
Sets distance between text lines */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_leading )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setTextLeading ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_text_rendering(int pdfdoc, int rendermode)
1999-11-22 15:28:26 +00:00
Determines how text is rendered */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_text_rendering )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setTextRenderingMode ( pdf , Z_LVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_horiz_scaling(int pdfdoc, float scale)
1999-11-22 15:28:26 +00:00
Sets horizontal scaling of text */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_horiz_scaling )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setHorizontalScaling ( pdf , ( float ) Z_DVAL_PP ( arg2 ) * 100.0 ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_text_rise(int pdfdoc, float value)
1999-11-22 15:28:26 +00:00
Sets the text rise */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_text_rise )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setTextRise ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_text_matrix(int pdfdoc, arry matrix)
1999-11-22 15:28:26 +00:00
Sets the text matrix */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_text_matrix )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * data ;
1999-11-22 15:28:26 +00:00
int id , type , i ;
HashTable * matrix ;
CPDFdoc * pdf ;
float * pdfmatrixptr ;
float pdfmatrix [ 6 ] ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_array_ex ( arg2 ) ;
2003-01-14 20:02:42 +00:00
matrix = Z_ARRVAL_PP ( arg2 ) ;
1999-11-22 15:28:26 +00:00
1999-12-17 20:55:31 +00:00
if ( zend_hash_num_elements ( matrix ) ! = 6 ) {
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Text matrix must have 6 elements " ) ;
1999-11-22 15:28:26 +00:00
RETURN_FALSE ;
}
pdfmatrixptr = pdfmatrix ;
1999-12-17 20:55:31 +00:00
zend_hash_internal_pointer_reset ( matrix ) ;
for ( i = 0 ; i < zend_hash_num_elements ( matrix ) ; i + + ) {
zend_hash_get_current_data ( matrix , ( void * ) & data ) ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_P ( data ) ) {
1999-11-22 15:28:26 +00:00
case IS_DOUBLE :
2001-09-25 21:58:48 +00:00
* pdfmatrixptr + + = ( float ) Z_DVAL_P ( data ) ;
1999-11-22 15:28:26 +00:00
break ;
default :
* pdfmatrixptr + + = 0.0 ;
break ;
}
1999-12-17 20:55:31 +00:00
zend_hash_move_forward ( matrix ) ;
1999-11-22 15:28:26 +00:00
}
cpdf_setTextMatrix ( pdf , pdfmatrix [ 0 ] , pdfmatrix [ 1 ] ,
pdfmatrix [ 2 ] , pdfmatrix [ 3 ] ,
pdfmatrix [ 4 ] , pdfmatrix [ 5 ] ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_text_pos(int pdfdoc, float x, float y [, int mode])
2001-12-02 09:41:27 +00:00
Sets the position of text for the next cpdf_show call */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_text_pos )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 4 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 3 | | argc > 4 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 3 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 3 ] ) ;
mode = Z_LVAL_PP ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawSetTextPosition ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_setTextPosition ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_rotate_text(int pdfdoc, float angle)
2001-12-15 14:12:33 +00:00
Sets text rotation angle */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_rotate_text )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_rotateText ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_char_spacing(int pdfdoc, float space)
1999-11-22 15:28:26 +00:00
Sets character spacing */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_char_spacing )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setCharacterSpacing ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_word_spacing(int pdfdoc, float space)
1999-11-22 15:28:26 +00:00
Sets spacing between words */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_word_spacing )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setWordSpacing ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2001-09-21 21:59:27 +00:00
/* {{{ proto float cpdf_stringwidth(int pdfdoc, string text)
1999-11-22 15:28:26 +00:00
Returns width of text in current font */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_stringwidth )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
double width ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
width = ( double ) cpdf_stringWidth ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_DOUBLE ( ( double ) width ) ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_save(int pdfdoc)
1999-11-22 15:28:26 +00:00
Saves current enviroment */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_save )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_gsave ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_restore(int pdfdoc)
1999-11-22 15:28:26 +00:00
Restores formerly saved enviroment */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_restore )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_grestore ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_translate(int pdfdoc, float x, float y)
1999-11-22 15:28:26 +00:00
Sets origin of coordinate system */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_translate )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_rawTranslate ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_scale(int pdfdoc, float x_scale, float y_scale)
1999-11-22 15:28:26 +00:00
Sets scaling */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_scale )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_scale ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_rotate(int pdfdoc, float angle)
1999-11-22 15:28:26 +00:00
Sets rotation */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_rotate )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_rotate ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setflat(int pdfdoc, float value)
1999-11-22 15:28:26 +00:00
Sets flatness */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setflat )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
if ( ( Z_LVAL_PP ( arg2 ) > 100 ) & & ( Z_LVAL_PP ( arg2 ) < 0 ) ) {
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter has to between 0 and 100 " ) ;
1999-11-22 15:28:26 +00:00
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
cpdf_setflat ( pdf , ( int ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setlinejoin(int pdfdoc, int value)
1999-11-22 15:28:26 +00:00
Sets linejoin parameter */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setlinejoin )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
if ( ( Z_LVAL_PP ( arg2 ) > 2 ) & & ( Z_LVAL_PP ( arg2 ) < 0 ) ) {
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter has to between 0 and 2 " ) ;
1999-11-22 15:28:26 +00:00
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
cpdf_setlinejoin ( pdf , Z_LVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setlinecap(int pdfdoc, int value)
1999-11-22 15:28:26 +00:00
Sets linecap parameter */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setlinecap )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
if ( ( Z_LVAL_PP ( arg2 ) > 2 ) & & ( Z_LVAL_PP ( arg2 ) < 0 ) ) {
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter has to be > 0 and =< 2 " ) ;
1999-11-22 15:28:26 +00:00
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
cpdf_setlinecap ( pdf , Z_LVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setmiterlimit(int pdfdoc, float value)
1999-11-22 15:28:26 +00:00
Sets miter limit */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setmiterlimit )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
if ( Z_DVAL_PP ( arg2 ) < 1 ) {
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Parameter has to be >= 1 " ) ;
1999-11-22 15:28:26 +00:00
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
cpdf_setmiterlimit ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setlinewidth(int pdfdoc, float width)
1999-11-22 15:28:26 +00:00
Sets line width */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setlinewidth )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setlinewidth ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
# define BUFFERLEN 20
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setdash(int pdfdoc, long white, long black)
1999-11-22 15:28:26 +00:00
Sets dash pattern */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setdash )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 ;
1999-11-22 15:28:26 +00:00
int id , type ;
char buffer [ BUFFERLEN ] ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
snprintf ( buffer , BUFFERLEN , " [%d %d] 0 " , ( int ) Z_LVAL_PP ( arg2 ) , ( int ) Z_LVAL_PP ( arg3 ) ) ;
1999-11-22 15:28:26 +00:00
cpdf_setdash ( pdf , buffer ) ;
RETURN_TRUE ;
}
/* }}} */
# undef BUFFERLEN
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_moveto(int pdfdoc, float x, float y [, int mode])
1999-11-22 15:28:26 +00:00
Sets current point */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_moveto )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 4 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 3 | | argc > 4 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 3 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 3 ] ) ;
mode = Z_LVAL_PP ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawMoveto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_moveto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_rmoveto(int pdfdoc, float x, float y [, int mode])
1999-11-22 15:28:26 +00:00
Sets current point */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_rmoveto )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 4 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 3 | | argc > 4 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 3 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 3 ] ) ;
mode = Z_LVAL_PP ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawRmoveto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_rmoveto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_curveto(int pdfdoc, float x1, float y1, float x2, float y2, float x3, float y3 [, int mode])
1999-11-22 15:28:26 +00:00
Draws a curve */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_curveto )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 8 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 7 | | argc > 8 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +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_double_ex ( argv [ 5 ] ) ;
convert_to_double_ex ( argv [ 6 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 7 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 7 ] ) ;
mode = Z_LVAL_PP ( argv [ 7 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawCurveto ( 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 ] ) ,
( float ) Z_DVAL_PP ( argv [ 5 ] ) ,
( float ) Z_DVAL_PP ( argv [ 6 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_curveto ( 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 ] ) ,
( float ) Z_DVAL_PP ( argv [ 5 ] ) ,
( float ) Z_DVAL_PP ( argv [ 6 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_lineto(int pdfdoc, float x, float y [, int mode])
1999-11-22 15:28:26 +00:00
Draws a line */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_lineto )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 4 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 3 | | argc > 4 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 3 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 3 ] ) ;
mode = Z_LVAL_PP ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawLineto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_lineto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_rlineto(int pdfdoc, float x, float y [, int mode])
1999-11-22 15:28:26 +00:00
Draws a line relative to current point */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_rlineto )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 4 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 3 | | argc > 4 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 3 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 3 ] ) ;
mode = Z_LVAL_PP ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawRlineto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_rlineto ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_circle(int pdfdoc, float x, float y, float radius [, int mode])
1999-11-22 15:28:26 +00:00
Draws a circle */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_circle )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 5 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 4 | | argc > 5 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 1 ] ) ;
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 4 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 4 ] ) ;
mode = Z_LVAL_PP ( argv [ 4 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawCircle ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_circle ( pdf , ( float ) Z_DVAL_PP ( argv [ 1 ] ) , ( float ) Z_DVAL_PP ( argv [ 2 ] ) , ( float ) Z_DVAL_PP ( argv [ 3 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_arc(int pdfdoc, float x, float y, float radius, float start, float end [, int mode])
1999-11-22 15:28:26 +00:00
Draws an arc */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_arc )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 7 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 6 | | argc > 7 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +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_double_ex ( argv [ 5 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 6 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 6 ] ) ;
mode = Z_LVAL_PP ( argv [ 6 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawArc ( 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 ] ) , ( float ) Z_DVAL_PP ( argv [ 5 ] ) , 1 ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_arc ( 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 ] ) , ( float ) Z_DVAL_PP ( argv [ 5 ] ) , 1 ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_rect(int pdfdoc, float x, float y, float width, float height [, int mode])
1999-11-22 15:28:26 +00:00
Draws a rectangle */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_rect )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 6 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 5 | | argc > 6 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +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 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 5 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 5 ] ) ;
mode = Z_LVAL_PP ( argv [ 5 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawRect ( 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 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_rect ( 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 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_newpath(int pdfdoc)
1999-11-22 15:28:26 +00:00
Starts new path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_newpath )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_newpath ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_closepath(int pdfdoc)
1999-11-22 15:28:26 +00:00
Close path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_closepath )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_closepath ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_closepath_stroke(int pdfdoc)
1999-11-22 15:28:26 +00:00
Close path and draw line along path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_closepath_stroke )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_closepath ( pdf ) ;
cpdf_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_stroke(int pdfdoc)
2001-12-02 09:41:27 +00:00
Draws line along path path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_stroke )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_fill(int pdfdoc)
2001-12-02 09:41:27 +00:00
Fills current path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_fill )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_fill ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_fill_stroke(int pdfdoc)
2001-12-02 09:41:27 +00:00
Fills and stroke current path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_fill_stroke )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_fill ( pdf ) ;
cpdf_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_closepath_fill_stroke(int pdfdoc)
1999-11-22 15:28:26 +00:00
Close , fill and stroke current path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_closepath_fill_stroke )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_closepath ( pdf ) ;
cpdf_fill ( pdf ) ;
cpdf_stroke ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_clip(int pdfdoc)
1999-11-22 15:28:26 +00:00
Clips to current path */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_clip )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_clip ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setgray_fill(int pdfdoc, float value)
1999-11-22 15:28:26 +00:00
Sets filling color to gray value */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setgray_fill )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setgrayFill ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setgray_stroke(int pdfdoc, float value)
1999-11-22 15:28:26 +00:00
Sets drawing color to gray value */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setgray_stroke )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setgrayStroke ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setgray(int pdfdoc, float value)
1999-11-22 15:28:26 +00:00
Sets drawing and filling color to gray value */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setgray )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setgray ( pdf , ( float ) Z_DVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setrgbcolor_fill(int pdfdoc, float red, float green, float blue)
1999-11-22 15:28:26 +00:00
Sets filling color to rgb color value */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setrgbcolor_fill )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setrgbcolorFill ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setrgbcolor_stroke(int pdfdoc, float red, float green, float blue)
2001-12-02 09:41:27 +00:00
Sets drawing color to RGB color value */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setrgbcolor_stroke )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setrgbcolorStroke ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_setrgbcolor(int pdfdoc, float red, float green, float blue)
2001-12-02 09:41:27 +00:00
Sets drawing and filling color to RGB color value */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_setrgbcolor )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setrgbcolor ( pdf , ( float ) Z_DVAL_PP ( arg2 ) , ( float ) Z_DVAL_PP ( arg3 ) , ( float ) Z_DVAL_PP ( arg4 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_set_page_animation(int pdfdoc, int transition, float duration, float direction, int orientation, int inout)
1999-11-22 15:28:26 +00:00
Sets transition between pages */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_page_animation )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 , * * arg3 , * * arg4 , * * arg5 , * * arg6 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 6 | | zend_get_parameters_ex ( 6 , & arg1 , & arg2 , & arg3 , & arg4 , & arg5 , & arg6 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( arg2 ) ;
convert_to_double_ex ( arg3 ) ;
convert_to_double_ex ( arg4 ) ;
convert_to_long_ex ( arg5 ) ;
convert_to_long_ex ( arg6 ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
cpdf_setPageTransition ( pdf , Z_LVAL_PP ( arg2 ) , Z_DVAL_PP ( arg3 ) , Z_DVAL_PP ( arg4 ) ,
Z_LVAL_PP ( arg5 ) , Z_LVAL_PP ( arg6 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_finalize(int pdfdoc)
2001-12-02 09:41:27 +00:00
Creates PDF doc in memory */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_finalize )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
cpdf_finalizeAll ( pdf ) ;
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_output_buffer(int pdfdoc)
1999-11-22 15:28:26 +00:00
Returns the internal memory stream as string */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_output_buffer )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 ;
1999-11-22 15:28:26 +00:00
int id , type , lenght ;
CPDFdoc * pdf ;
char * buffer ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
1999-11-22 15:28:26 +00:00
buffer = cpdf_getBufferForPDF ( pdf , & lenght ) ;
2001-02-15 14:49:01 +00:00
2001-08-05 16:21:33 +00:00
php_write ( buffer , lenght TSRMLS_CC ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_save_to_file(int pdfdoc, string filename)
1999-11-22 15:28:26 +00:00
Saves the internal memory stream to a file */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_save_to_file )
{
2003-01-14 18:54:44 +00:00
zval * * arg1 , * * arg2 ;
1999-11-22 15:28:26 +00:00
int id , type ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
}
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( arg1 ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( arg2 ) ;
1999-11-22 15:28:26 +00:00
# if APACHE
2003-05-21 00:57:34 +00:00
if ( strcmp ( Z_STRVAL_PP ( arg2 ) , " - " ) = = 0 )
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Writing to stdout as described in the ClibPDF manual is not possible if php is used as an Apache module. Use cpdf_output_buffer() instead. " ) ;
1999-11-22 15:28:26 +00:00
# endif
2003-05-21 00:57:34 +00:00
if ( php_check_open_basedir ( Z_STRVAL_PP ( arg2 ) TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( Z_STRVAL_PP ( arg2 ) , " wb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
cpdf_savePDFmemoryStreamToFile ( pdf , Z_STRVAL_PP ( arg2 ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_import_jpeg(int pdfdoc, string filename, float x, float y, float angle, float width, float height, float x_scale, float y_scale, int gsave [, int mode])
2001-12-02 09:41:27 +00:00
Includes JPEG image */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_import_jpeg )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 11 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
float width , height , xscale , yscale ;
CPDFdoc * pdf ;
2003-01-14 18:54:44 +00:00
if ( argc < 10 | | argc > 11 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_string_ex ( argv [ 1 ] ) ;
2003-05-21 00:57:34 +00:00
if ( php_check_open_basedir ( Z_STRVAL_PP ( argv [ 1 ] ) TSRMLS_CC ) | | ( PG ( safe_mode ) & & ! php_checkuid ( Z_STRVAL_PP ( argv [ 1 ] ) , " rb+ " , CHECKUID_CHECK_MODE_PARAM ) ) ) {
RETURN_FALSE ;
}
2003-01-14 18:54:44 +00:00
convert_to_double_ex ( argv [ 2 ] ) ;
convert_to_double_ex ( argv [ 3 ] ) ;
convert_to_double_ex ( argv [ 4 ] ) ;
convert_to_double_ex ( argv [ 5 ] ) ;
width = ( float ) Z_DVAL_PP ( argv [ 5 ] ) ;
convert_to_double_ex ( argv [ 6 ] ) ;
height = ( float ) Z_DVAL_PP ( argv [ 6 ] ) ;
convert_to_double_ex ( argv [ 7 ] ) ;
xscale = ( float ) Z_DVAL_PP ( argv [ 7 ] ) ;
convert_to_double_ex ( argv [ 8 ] ) ;
yscale = ( float ) Z_DVAL_PP ( argv [ 8 ] ) ;
convert_to_long_ex ( argv [ 9 ] ) ;
1999-11-22 15:28:26 +00:00
if ( argc > 10 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 10 ] ) ;
mode = Z_LVAL_PP ( argv [ 10 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawImportImage ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) ,
1999-11-22 15:28:26 +00:00
JPEG_IMG ,
2003-01-14 18:54:44 +00:00
( float ) Z_DVAL_PP ( argv [ 2 ] ) ,
( float ) Z_DVAL_PP ( argv [ 3 ] ) ,
( float ) Z_DVAL_PP ( argv [ 4 ] ) ,
1999-11-22 15:28:26 +00:00
& width ,
& height ,
& xscale ,
& yscale ,
2003-01-14 18:54:44 +00:00
Z_LVAL_PP ( argv [ 9 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
2003-01-14 18:54:44 +00:00
cpdf_rawImportImage ( pdf , Z_STRVAL_PP ( argv [ 1 ] ) ,
1999-11-22 15:28:26 +00:00
JPEG_IMG ,
2003-01-14 18:54:44 +00:00
( float ) Z_DVAL_PP ( argv [ 2 ] ) ,
( float ) Z_DVAL_PP ( argv [ 3 ] ) ,
( float ) Z_DVAL_PP ( argv [ 4 ] ) ,
1999-11-22 15:28:26 +00:00
& width ,
& height ,
& xscale ,
& yscale ,
2003-01-14 18:54:44 +00:00
Z_LVAL_PP ( argv [ 9 ] ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_TRUE ;
}
/* }}} */
# if HAVE_LIBGD13
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_place_inline_image(int pdfdoc, int gdimage, float x, float y, float angle, fload width, float height, int gsave [, int mode])
1999-11-22 15:28:26 +00:00
Includes image */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_place_inline_image )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 11 ] ;
int id , gid , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
int count , i , j , color ;
CPDFdoc * pdf ;
unsigned char * buffer , * ptr ;
gdImagePtr im ;
2003-01-14 18:54:44 +00:00
if ( argc < 8 | | argc > 9 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_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_double_ex ( argv [ 6 ] ) ;
convert_to_long_ex ( argv [ 7 ] ) ;
gid = Z_LVAL_PP ( argv [ 1 ] ) ;
1999-12-17 19:51:39 +00:00
im = zend_list_find ( gid , & type ) ;
2001-05-21 21:06:08 +00:00
2001-08-11 16:39:07 +00:00
ZEND_GET_RESOURCE_TYPE_ID ( CPDF_GLOBAL ( le_gd ) , " gd " ) ;
2001-05-21 21:06:08 +00:00
if ( ! CPDF_GLOBAL ( le_gd ) )
{
2003-01-14 15:15: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
}
if ( ! im | | type ! = CPDF_GLOBAL ( le_gd ) ) {
2003-01-14 15:15:53 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Unable to find image pointer " ) ;
1999-11-22 15:28:26 +00:00
RETURN_FALSE ;
}
if ( argc > 8 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 8 ] ) ;
mode = Z_LVAL_PP ( argv [ 8 ] ) ;
1999-11-22 15:28:26 +00:00
}
count = 3 * im - > sx * im - > sy ;
2004-05-10 22:13:08 +00:00
buffer = ( unsigned char * ) safe_emalloc ( 3 * im - > sx , im - > sy , 0 ) ;
1999-11-22 15:28:26 +00:00
ptr = buffer ;
for ( i = 0 ; i < im - > sy ; i + + ) {
for ( j = 0 ; j < im - > sx ; j + + ) {
2004-05-10 22:13:08 +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 ) ) {
color = im - > pixels [ i ] [ j ] ;
* ptr + + = im - > red [ color ] ;
* ptr + + = im - > green [ color ] ;
* ptr + + = im - > blue [ color ] ;
}
# if HAVE_LIBGD20
}
# endif
1999-11-22 15:28:26 +00:00
}
}
if ( mode = = 1 )
cpdf_placeInLineImage ( pdf , buffer , count ,
2003-01-14 18:54:44 +00:00
( float ) Z_DVAL_PP ( argv [ 2 ] ) ,
( float ) Z_DVAL_PP ( argv [ 3 ] ) ,
( float ) Z_DVAL_PP ( argv [ 4 ] ) ,
( float ) Z_DVAL_PP ( argv [ 5 ] ) ,
( float ) Z_DVAL_PP ( argv [ 6 ] ) ,
1999-11-22 15:28:26 +00:00
im - > sx ,
im - > sy ,
2003-01-14 18:54:44 +00:00
8 , 2 , Z_LVAL_PP ( argv [ 7 ] ) ) ;
1999-11-22 15:28:26 +00:00
else
cpdf_rawPlaceInLineImage ( pdf , buffer , count ,
2003-01-14 18:54:44 +00:00
( float ) Z_DVAL_PP ( argv [ 2 ] ) ,
( float ) Z_DVAL_PP ( argv [ 3 ] ) ,
( float ) Z_DVAL_PP ( argv [ 4 ] ) ,
( float ) Z_DVAL_PP ( argv [ 5 ] ) ,
( float ) Z_DVAL_PP ( argv [ 6 ] ) ,
1999-11-22 15:28:26 +00:00
im - > sx ,
im - > sy ,
2003-01-14 18:54:44 +00:00
8 , 2 , Z_LVAL_PP ( argv [ 7 ] ) ) ;
1999-11-22 15:28:26 +00:00
efree ( buffer ) ;
RETURN_TRUE ;
}
/* }}} */
# endif
2003-06-12 14:04:31 +00:00
/* {{{ proto bool cpdf_add_annotation(int pdfdoc, float xll, float yll, float xur, float xur, string title, string text [, int mode])
1999-11-22 15:28:26 +00:00
Sets annotation */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_add_annotation )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 11 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
CPDFannotAttrib attrib ;
2003-01-14 18:54:44 +00:00
if ( argc < 7 | | argc > 8 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +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-11-22 15:28:26 +00:00
attrib . flags = AF_NOZOOM | AF_NOROTATE | AF_READONLY ;
attrib . border_array = " [0 0 1 [4 2]] " ;
attrib . BS = NULL ;
attrib . r = 0.00 ;
attrib . g = 1.00 ;
attrib . b = 1.00 ;
if ( argc > 7 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 7 ] ) ;
mode = Z_LVAL_PP ( argv [ 7 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawSetAnnotation ( 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 [ 5 ] ) ,
Z_STRVAL_PP ( argv [ 6 ] ) ,
1999-11-22 15:28:26 +00:00
& attrib ) ;
else
2003-01-14 18:54:44 +00:00
cpdf_setAnnotation ( 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 [ 5 ] ) ,
Z_STRVAL_PP ( argv [ 6 ] ) ,
1999-11-22 15:28:26 +00:00
& attrib ) ;
RETURN_TRUE ;
}
/* }}} */
2003-08-15 12:08:15 +00:00
/* {{{ proto bool cpdf_set_action_url(int pdfdoc, float xll, float yll, float xur, float xur, string url [, int mode])
2001-12-02 09:41:27 +00:00
Sets hyperlink */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_set_action_url )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 11 ] ;
int id , type , mode = 0 , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
CPDFannotAttrib attrib ;
2003-01-14 18:54:44 +00:00
if ( argc < 6 | | argc > 7 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +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 ] ) ;
1999-11-22 15:28:26 +00:00
attrib . flags = AF_NOZOOM | AF_NOROTATE | AF_READONLY ;
attrib . border_array = " [0 0 1 [4 0]] " ;
attrib . BS = NULL ;
attrib . r = 0.00 ;
attrib . g = 0.00 ;
attrib . b = 1.00 ;
if ( argc > 6 ) {
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 6 ] ) ;
mode = Z_LVAL_PP ( argv [ 6 ] ) ;
1999-11-22 15:28:26 +00:00
}
if ( mode = = 1 )
2003-01-14 18:54:44 +00:00
cpdf_rawSetActionURL ( 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 [ 5 ] ) ,
1999-11-22 15:28:26 +00:00
& attrib ) ;
else
2003-01-14 18:54:44 +00:00
cpdf_setActionURL ( 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 [ 5 ] ) ,
1999-11-22 15:28:26 +00:00
& attrib ) ;
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto int cpdf_add_outline(int pdfdoc, int lastoutline, int sublevel, int open, int pagenr, string title)
2001-12-02 09:41:27 +00:00
Adds outline */
2001-07-28 11:36:37 +00:00
PHP_FUNCTION ( cpdf_add_outline )
{
2003-01-14 18:54:44 +00:00
zval * * argv [ 11 ] ;
int id , oid , type , argc = ZEND_NUM_ARGS ( ) ;
1999-11-22 15:28:26 +00:00
CPDFdoc * pdf ;
CPDFoutlineEntry * lastoutline ;
2003-01-14 18:54:44 +00:00
if ( argc ! = 6 | | ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) ) {
1999-11-22 15:28:26 +00:00
WRONG_PARAM_COUNT ;
2003-01-14 18:54:44 +00:00
}
1999-11-22 15:28:26 +00:00
2003-01-14 15:15:53 +00:00
CPDF_FETCH_CPDFDOC ( argv [ 0 ] ) ;
2003-01-14 18:54:44 +00:00
convert_to_long_ex ( argv [ 1 ] ) ;
convert_to_long_ex ( argv [ 2 ] ) ;
convert_to_long_ex ( argv [ 3 ] ) ;
convert_to_long_ex ( argv [ 4 ] ) ;
convert_to_string_ex ( argv [ 5 ] ) ;
1999-11-22 15:28:26 +00:00
2003-01-14 18:54:44 +00:00
oid = Z_LVAL_PP ( argv [ 1 ] ) ;
2001-08-11 16:39:07 +00:00
lastoutline = zend_list_find ( oid , & type ) ;
1999-11-22 15:28:26 +00:00
if ( ! lastoutline | | type ! = CPDF_GLOBAL ( le_outline ) ) {
lastoutline = NULL ;
2003-01-14 15:15:53 +00:00
/* php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find last outline entry %d", id);
1999-11-22 15:28:26 +00:00
RETURN_FALSE ; */
}
lastoutline = cpdf_addOutlineEntry ( pdf , lastoutline ,
2003-01-14 18:54:44 +00:00
Z_LVAL_PP ( argv [ 2 ] ) ,
Z_LVAL_PP ( argv [ 3 ] ) ,
Z_LVAL_PP ( argv [ 4 ] ) ,
Z_STRVAL_PP ( argv [ 5 ] ) ,
1999-11-22 15:28:26 +00:00
1 , 0.0 , 0.0 , 0.0 , 0.0 ) ;
2001-08-11 16:39:07 +00:00
id = zend_list_insert ( lastoutline , CPDF_GLOBAL ( le_outline ) ) ;
1999-11-22 15:28:26 +00:00
RETURN_LONG ( id ) ;
}
/* }}} */
# 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-11-22 15:28:26 +00:00
*/