├── CREDITS ├── config.w32 ├── tests └── 001.phpt ├── haru.php ├── php_haru.h ├── config.m4 ├── LICENSE ├── package.xml └── haru.c /CREDITS: -------------------------------------------------------------------------------- 1 | haru 2 | Antony Dovgal 3 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | // vim:ft=javascript 3 | 4 | ARG_WITH("haru", "Haru PDF support", "no"); 5 | 6 | if (PHP_HARU != "no") { 7 | if (CHECK_LIB("libhpdf.lib", "haru") && 8 | CHECK_LIB("libpng_a.lib", "haru") && 9 | CHECK_LIB("zlib_a.lib", "haru") && 10 | CHECK_HEADER_ADD_INCLUDE("hpdf.h", "CFLAGS_HARU", PHP_HARU + ";" + PHP_PHP_BUILD + "\\include\\libharu") 11 | ) { 12 | 13 | EXTENSION("haru", "haru.c"); 14 | AC_DEFINE('HAVE_HARU', 1, "Have haru support"); 15 | } 16 | else { 17 | WARNING("haru not enabled; libraries and headers not found"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for haru presence 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 20 | --EXPECT-- 21 | haru extension is available 22 | -------------------------------------------------------------------------------- /haru.php: -------------------------------------------------------------------------------- 1 | addPage(); 5 | 6 | /* set the color (dark blue) */ 7 | $p->setRGBFill(0.2, 0.2, 0.5); 8 | /* draw a rectangle */ 9 | $p->rectangle(150, 400, 300, 200); 10 | /* fill it */ 11 | $p->fill(); 12 | 13 | /* se the color (white) */ 14 | $p->setRGBFill(1, 1, 1); 15 | 16 | /* enter text mode */ 17 | $p->beginText(); 18 | 19 | /* choose the font and its size */ 20 | $font = $doc->getFont("Helvetica"); 21 | $p->setFontAndSize($font, 35); 22 | 23 | /* move text position */ 24 | $p->moveTextPos(200,500); 25 | /* print a well-known phrase */ 26 | $p->showText("Hello world!"); 27 | 28 | /* leave text mode */ 29 | $p->endText(); 30 | 31 | /* save the result */ 32 | $doc->save("/tmp/test.pdf"); 33 | 34 | ?> 35 | -------------------------------------------------------------------------------- /php_haru.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 5 | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 1997-2008 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: Antony Dovgal | 16 | +----------------------------------------------------------------------+ 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef PHP_HARU_H 22 | #define PHP_HARU_H 23 | 24 | extern zend_module_entry haru_module_entry; 25 | #define phpext_haru_ptr &haru_module_entry 26 | 27 | #define PHP_HARU_VERSION "1.0.5" 28 | 29 | #ifdef ZTS 30 | #include "TSRM.h" 31 | #endif 32 | 33 | #endif /* PHP_HARU_H */ 34 | 35 | /* 36 | * Local variables: 37 | * tab-width: 4 38 | * c-basic-offset: 4 39 | * End: 40 | * vim600: noet sw=4 ts=4 fdm=marker 41 | * vim<600: noet sw=4 ts=4 42 | */ 43 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl $Id$ 2 | 3 | PHP_ARG_WITH(haru, for Haru PDF support, 4 | [ --with-haru Include Haru PDF library support]) 5 | 6 | if test -z "$PHP_ZLIB_DIR"; then 7 | PHP_ARG_WITH(zlib-dir, for the location of libz, 8 | [ --with-zlib-dir[=DIR] Haru: Set the path to libz install prefix], no, no) 9 | fi 10 | 11 | if test -z "$PHP_PNG_DIR"; then 12 | PHP_ARG_WITH(png-dir, for the location of libpng, 13 | [ --with-png-dir[=DIR] Haru: Set the path to libpng install prefix], no, no) 14 | fi 15 | 16 | if test "$PHP_HARU" != "no"; then 17 | 18 | SEARCH_PATH="/usr/local/ /usr/" 19 | SEARCH_FOR="include/hpdf.h" 20 | if test "$PHP_HARU" = "yes"; then 21 | AC_MSG_CHECKING([for Haru in default path]) 22 | for i in $SEARCH_PATH; do 23 | if test -r "$i/$SEARCH_FOR"; then 24 | HARU_DIR="$i" 25 | AC_MSG_RESULT(found in $i) 26 | fi 27 | done 28 | if test -z "$HARU_DIR"; then 29 | AC_MSG_RESULT([not found]) 30 | AC_MSG_ERROR([Please specify prefix for your Haru PDF library installation]) 31 | fi 32 | elif test -r $PHP_HARU/$SEARCH_FOR; then 33 | HARU_DIR=$PHP_HARU 34 | fi 35 | 36 | if test -z "$HARU_DIR"; then 37 | AC_MSG_RESULT([not found]) 38 | AC_MSG_ERROR([Could not find Haru PDF library in $PHP_HARU]) 39 | fi 40 | 41 | PHP_ADD_INCLUDE($HARU_DIR/include) 42 | 43 | LIBNAME=hpdf 44 | LIBSYMBOL=HPDF_Stream_WriteToStreamWithDeflate 45 | 46 | if test "$PHP_ZLIB_DIR" != "no"; then 47 | PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, HARU_SHARED_LIBADD) 48 | PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, [], [ 49 | AC_MSG_ERROR([Haru configure failed. Please check config.log for more information.]) 50 | ], [ 51 | -L$PHP_ZLIB_DIR/$PHP_LIBDIR -L$HARU_DIR/$PHP_LIBDIR 52 | ]) 53 | else 54 | PHP_ADD_LIBRARY(z,, HARU_SHARED_LIBADD) 55 | PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, [], [ 56 | AC_MSG_ERROR([Please check if the prefix is correct and try adding --with-zlib-dir=. See config.log for more information.]) 57 | ], [ 58 | -L$HARU_DIR/$PHP_LIBDIR 59 | ]) 60 | fi 61 | 62 | LIBNAME=hpdf 63 | LIBSYMBOL=HPDF_LoadPngImageFromFile 64 | 65 | if test "$PHP_PNG_DIR" != "no"; then 66 | PHP_ADD_LIBRARY_WITH_PATH(png, $PHP_PNG_DIR/$PHP_LIBDIR, HARU_SHARED_LIBADD) 67 | PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, [], [ 68 | AC_MSG_ERROR([Haru configure failed. Please check config.log for more information.]) 69 | ], [ 70 | -L$PHP_PNG_DIR/$PHP_LIBDIR -L$HARU_DIR/$PHP_LIBDIR 71 | ]) 72 | else 73 | PHP_ADD_LIBRARY(png,, HARU_SHARED_LIBADD) 74 | PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, [], [ 75 | AC_MSG_ERROR([Try adding --with-png-dir=. Please check config.log for more information.]) 76 | ], [ 77 | -L$HARU_DIR/$PHP_LIBDIR 78 | ]) 79 | fi 80 | 81 | PHP_ADD_LIBRARY_WITH_PATH(hpdf, $HARU_DIR/$PHP_LIBDIR, HARU_SHARED_LIBADD) 82 | 83 | PHP_SUBST(HARU_SHARED_LIBADD) 84 | PHP_NEW_EXTENSION(haru, haru.c, $ext_shared) 85 | fi 86 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------- 2 | The PHP License, version 3.01 3 | Copyright (c) 1999 - 2010 The PHP Group. All rights reserved. 4 | -------------------------------------------------------------------- 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, is permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in 15 | the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | 3. The name "PHP" must not be used to endorse or promote products 19 | derived from this software without prior written permission. For 20 | written permission, please contact group@php.net. 21 | 22 | 4. Products derived from this software may not be called "PHP", nor 23 | may "PHP" appear in their name, without prior written permission 24 | from group@php.net. You may indicate that your software works in 25 | conjunction with PHP by saying "Foo for PHP" instead of calling 26 | it "PHP Foo" or "phpfoo" 27 | 28 | 5. The PHP Group may publish revised and/or new versions of the 29 | license from time to time. Each version will be given a 30 | distinguishing version number. 31 | Once covered code has been published under a particular version 32 | of the license, you may always continue to use it under the terms 33 | of that version. You may also choose to use such covered code 34 | under the terms of any subsequent version of the license 35 | published by the PHP Group. No one other than the PHP Group has 36 | the right to modify the terms applicable to covered code created 37 | under this License. 38 | 39 | 6. Redistributions of any form whatsoever must retain the following 40 | acknowledgment: 41 | "This product includes PHP software, freely available from 42 | ". 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND 45 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP 48 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 50 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 51 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 53 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 55 | OF THE POSSIBILITY OF SUCH DAMAGE. 56 | 57 | -------------------------------------------------------------------- 58 | 59 | This software consists of voluntary contributions made by many 60 | individuals on behalf of the PHP Group. 61 | 62 | The PHP Group can be contacted via Email at group@php.net. 63 | 64 | For more information on the PHP Group and the PHP project, 65 | please see . 66 | 67 | PHP includes the Zend Engine, freely available at 68 | . 69 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | haru 7 | pecl.php.net 8 | Haru PDF functions 9 | These functions allow you to create PDF documents using the Haru Free PDF Library. 10 | 11 | 12 | Antony Dovgal 13 | tony2001 14 | tony2001@php.net 15 | yes 16 | 17 | 2014-03-31 18 | 19 | 20 | 1.0.5 21 | 1.0.5 22 | 23 | 24 | stable 25 | stable 26 | 27 | PHP 28 | - Added HaruPage::clip(), HaruPage::saveGS() and HaruPage::restoreGS() (patch by Ben Mewburn) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 5.1.3 46 | 6.0.0 47 | 6.0.0 48 | 49 | 50 | 1.4.0b1 51 | 52 | 53 | 54 | haru 55 | 56 | 57 | 58 | 59 | 60 | stablestable 61 | 1.0.41.0.3 62 | 2012-12-23 63 | - Fixed bug #63817 (CreateOutline encoder argument is always NULL) 64 | - Fixed version number. 65 | 66 | 67 | 68 | stablestable 69 | 1.0.31.0.3 70 | 2012-02-02 71 | - Fixed PECL bug #15960 (Cannot access to object properties when extending HaruDoc class) 72 | - Allow compiling with PHP 5.4+. (philip) 73 | 74 | 75 | 76 | stablestable 77 | 1.0.11.0.1 78 | 2009-01-12 79 | 80 | - Added HaruPage::setZoom() and HaruPage::addSMask() (available when compiled with libHaru >= 2.2.0). 81 | - Fixed build with PHP 5.4.x. 82 | 83 | 84 | 85 | stablestable 86 | 1.0.01.0.0 87 | 2008-11-19 88 | - Fixed build with PHP 5.3.x. 89 | - Fixed possible issue in HaruDoc::output() (thanks to Matt Underwood) 90 | 91 | 92 | 93 | betabeta 94 | 0.0.10.0.1 95 | 2007-03-26 96 | - Initial PECL release 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /haru.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 5 | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 1997-2008 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: Antony Dovgal | 16 | +----------------------------------------------------------------------+ 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "php_ini.h" 27 | #include "ext/standard/info.h" 28 | #include "zend_exceptions.h" 29 | #include "php_haru.h" 30 | #include 31 | 32 | #define PHP_HARU_BUF_SIZE 32768 33 | 34 | #ifdef Z_SET_REFCOUNT_P 35 | # define HARU_SET_REFCOUNT_AND_IS_REF(z) \ 36 | Z_SET_REFCOUNT_P(z, 1); \ 37 | Z_SET_ISREF_P(z); 38 | #else 39 | # define HARU_SET_REFCOUNT_AND_IS_REF(z) \ 40 | z->refcount = 1; \ 41 | z->is_ref = 1; 42 | #endif 43 | 44 | /* {{{ structs and static vars */ 45 | static zend_class_entry *ce_haruexception; 46 | static zend_class_entry *ce_harudoc; 47 | static zend_class_entry *ce_harupage; 48 | static zend_class_entry *ce_harufont; 49 | static zend_class_entry *ce_haruimage; 50 | static zend_class_entry *ce_harudestination; 51 | static zend_class_entry *ce_haruannotation; 52 | static zend_class_entry *ce_haruencoder; 53 | static zend_class_entry *ce_haruoutline; 54 | 55 | static zend_object_handlers php_harudoc_handlers; 56 | static zend_object_handlers php_harupage_handlers; 57 | static zend_object_handlers php_harufont_handlers; 58 | static zend_object_handlers php_haruimage_handlers; 59 | static zend_object_handlers php_harudestination_handlers; 60 | static zend_object_handlers php_haruannotation_handlers; 61 | static zend_object_handlers php_haruencoder_handlers; 62 | static zend_object_handlers php_haruoutline_handlers; 63 | 64 | typedef struct _php_harudoc { 65 | zend_object std; 66 | HPDF_Doc h; 67 | } php_harudoc; 68 | 69 | typedef struct _php_harupage { 70 | zend_object std; 71 | zval doc; 72 | HPDF_Page h; 73 | } php_harupage; 74 | 75 | typedef struct _php_harufont { 76 | zend_object std; 77 | zval doc; 78 | HPDF_Font h; 79 | } php_harufont; 80 | 81 | typedef struct _php_haruimage { 82 | zend_object std; 83 | zval doc; 84 | HPDF_Image h; 85 | char *filename; 86 | } php_haruimage; 87 | 88 | typedef struct _php_harudestination { 89 | zend_object std; 90 | zval page; 91 | HPDF_Destination h; 92 | } php_harudestination; 93 | 94 | typedef struct _php_haruannotation { 95 | zend_object std; 96 | zval page; 97 | HPDF_Annotation h; 98 | } php_haruannotation; 99 | 100 | typedef struct _php_haruencoder { 101 | zend_object std; 102 | zval doc; 103 | HPDF_Encoder h; 104 | } php_haruencoder; 105 | 106 | typedef struct _php_haruoutline { 107 | zend_object std; 108 | zval doc; 109 | HPDF_Outline h; 110 | } php_haruoutline; 111 | 112 | /* }}} */ 113 | 114 | /* macros {{{ */ 115 | 116 | #if PHP_API_VERSION < 20100412 117 | #define HARU_CHECK_FILE(filename) \ 118 | do { \ 119 | php_set_error_handling(EH_THROW, ce_haruexception TSRMLS_CC); \ 120 | if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { \ 121 | php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); \ 122 | return; \ 123 | } \ 124 | if (php_check_open_basedir(filename TSRMLS_CC)) { \ 125 | php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); \ 126 | return; \ 127 | } \ 128 | php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); \ 129 | } while(0) 130 | #else 131 | #define HARU_CHECK_FILE(filename) \ 132 | do { \ 133 | zend_replace_error_handling(EH_THROW, ce_haruexception, NULL TSRMLS_CC); \ 134 | if (php_check_open_basedir(filename TSRMLS_CC)) { \ 135 | zend_replace_error_handling(EH_NORMAL, NULL, NULL TSRMLS_CC); \ 136 | return; \ 137 | } \ 138 | zend_replace_error_handling(EH_NORMAL, NULL, NULL TSRMLS_CC); \ 139 | } while(0) 140 | #endif 141 | 142 | #define PHP_HARU_NULL_CHECK(ret, message) \ 143 | do { \ 144 | if (!ret) { \ 145 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, message); \ 146 | return; \ 147 | } \ 148 | } while(0) 149 | 150 | /* }}} */ 151 | 152 | /* constructors and destructors {{{ */ 153 | 154 | static void php_harudoc_dtor(void *object TSRMLS_DC) /* {{{ */ 155 | { 156 | php_harudoc *doc = (php_harudoc *)object; 157 | 158 | if (doc->h) { 159 | HPDF_Free(doc->h); 160 | doc->h = NULL; 161 | } 162 | 163 | zend_object_std_dtor(&doc->std TSRMLS_CC); 164 | efree(doc); 165 | } 166 | 167 | /* }}} */ 168 | 169 | static zend_object_value php_harudoc_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 170 | { 171 | php_harudoc *doc; 172 | zend_object_value retval; 173 | #if ZEND_MODULE_API_NO < 20100409 174 | zval *tmp; 175 | #endif 176 | 177 | doc = ecalloc(1, sizeof(*doc)); 178 | zend_object_std_init(&doc->std, ce TSRMLS_CC); 179 | 180 | #if ZEND_MODULE_API_NO >= 20100409 181 | object_properties_init(&doc->std, ce); 182 | #else 183 | zend_hash_copy(doc->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 184 | #endif 185 | 186 | retval.handle = zend_objects_store_put(doc, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_harudoc_dtor, NULL TSRMLS_CC); 187 | retval.handlers = &php_harudoc_handlers; 188 | 189 | return retval; 190 | } 191 | 192 | /* }}} */ 193 | 194 | static void php_harupage_dtor(void *object TSRMLS_DC) /* {{{ */ 195 | { 196 | php_harupage *page = (php_harupage *)object; 197 | 198 | if (page->h) { 199 | page->h = NULL; 200 | } 201 | 202 | zend_objects_store_del_ref(&page->doc TSRMLS_CC); 203 | 204 | zend_object_std_dtor(&page->std TSRMLS_CC); 205 | efree(page); 206 | } 207 | 208 | /* }}} */ 209 | 210 | static zend_object_value php_harupage_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 211 | { 212 | php_harupage *page; 213 | zend_object_value retval; 214 | #if ZEND_MODULE_API_NO < 20100409 215 | zval *tmp; 216 | #endif 217 | 218 | page = ecalloc(1, sizeof(*page)); 219 | zend_object_std_init(&page->std, ce TSRMLS_CC); 220 | 221 | #if ZEND_MODULE_API_NO >= 20100409 222 | object_properties_init(&page->std, ce); 223 | #else 224 | zend_hash_copy(page->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 225 | #endif 226 | 227 | retval.handle = zend_objects_store_put(page, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_harupage_dtor, NULL TSRMLS_CC); 228 | retval.handlers = &php_harupage_handlers; 229 | return retval; 230 | } 231 | 232 | /* }}} */ 233 | 234 | static void php_harufont_dtor(void *object TSRMLS_DC) /* {{{ */ 235 | { 236 | php_harufont *font = (php_harufont *)object; 237 | 238 | if (font->h) { 239 | font->h = NULL; 240 | } 241 | 242 | zend_objects_store_del_ref(&font->doc TSRMLS_CC); 243 | 244 | zend_object_std_dtor(&font->std TSRMLS_CC); 245 | efree(font); 246 | } 247 | 248 | /* }}} */ 249 | 250 | static zend_object_value php_harufont_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 251 | { 252 | php_harufont *font; 253 | zend_object_value retval; 254 | #if ZEND_MODULE_API_NO < 20100409 255 | zval *tmp; 256 | #endif 257 | 258 | font = ecalloc(1, sizeof(*font)); 259 | zend_object_std_init(&font->std, ce TSRMLS_CC); 260 | 261 | #if ZEND_MODULE_API_NO >= 20100409 262 | object_properties_init(&font->std, ce); 263 | #else 264 | zend_hash_copy(font->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 265 | #endif 266 | 267 | retval.handle = zend_objects_store_put(font, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_harufont_dtor, NULL TSRMLS_CC); 268 | retval.handlers = &php_harufont_handlers; 269 | return retval; 270 | } 271 | 272 | /* }}} */ 273 | 274 | static void php_haruimage_dtor(void *object TSRMLS_DC) /* {{{ */ 275 | { 276 | php_haruimage *image = (php_haruimage *)object; 277 | 278 | if (image->h) { 279 | image->h = NULL; 280 | } 281 | 282 | if (image->filename) { 283 | efree(image->filename); 284 | image->filename = NULL; 285 | } 286 | 287 | zend_objects_store_del_ref(&image->doc TSRMLS_CC); 288 | 289 | zend_object_std_dtor(&image->std TSRMLS_CC); 290 | efree(image); 291 | } 292 | 293 | /* }}} */ 294 | 295 | static zend_object_value php_haruimage_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 296 | { 297 | php_haruimage *image; 298 | zend_object_value retval; 299 | #if ZEND_MODULE_API_NO < 20100409 300 | zval *tmp; 301 | #endif 302 | 303 | image = ecalloc(1, sizeof(*image)); 304 | zend_object_std_init(&image->std, ce TSRMLS_CC); 305 | 306 | #if ZEND_MODULE_API_NO >= 20100409 307 | object_properties_init(&image->std, ce); 308 | #else 309 | zend_hash_copy(image->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 310 | #endif 311 | 312 | retval.handle = zend_objects_store_put(image, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_haruimage_dtor, NULL TSRMLS_CC); 313 | retval.handlers = &php_haruimage_handlers; 314 | return retval; 315 | } 316 | 317 | /* }}} */ 318 | 319 | static void php_harudestination_dtor(void *object TSRMLS_DC) /* {{{ */ 320 | { 321 | php_harudestination *destination = (php_harudestination *)object; 322 | 323 | if (destination->h) { 324 | destination->h = NULL; 325 | } 326 | 327 | zend_objects_store_del_ref(&destination->page TSRMLS_CC); 328 | 329 | zend_object_std_dtor(&destination->std TSRMLS_CC); 330 | efree(destination); 331 | } 332 | 333 | /* }}} */ 334 | 335 | static zend_object_value php_harudestination_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 336 | { 337 | php_harudestination *destination; 338 | zend_object_value retval; 339 | #if ZEND_MODULE_API_NO < 20100409 340 | zval *tmp; 341 | #endif 342 | 343 | destination = ecalloc(1, sizeof(*destination)); 344 | zend_object_std_init(&destination->std, ce TSRMLS_CC); 345 | 346 | #if ZEND_MODULE_API_NO >= 20100409 347 | object_properties_init(&destination->std, ce); 348 | #else 349 | zend_hash_copy(destination->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 350 | #endif 351 | 352 | retval.handle = zend_objects_store_put(destination, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_harudestination_dtor, NULL TSRMLS_CC); 353 | retval.handlers = &php_harudestination_handlers; 354 | return retval; 355 | } 356 | 357 | /* }}} */ 358 | 359 | static void php_haruannotation_dtor(void *object TSRMLS_DC) /* {{{ */ 360 | { 361 | php_haruannotation *annotation = (php_haruannotation *)object; 362 | 363 | if (annotation->h) { 364 | annotation->h = NULL; 365 | } 366 | 367 | zend_objects_store_del_ref(&annotation->page TSRMLS_CC); 368 | 369 | zend_object_std_dtor(&annotation->std TSRMLS_CC); 370 | efree(annotation); 371 | } 372 | 373 | /* }}} */ 374 | 375 | static zend_object_value php_haruannotation_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 376 | { 377 | php_haruannotation *annotation; 378 | zend_object_value retval; 379 | #if ZEND_MODULE_API_NO < 20100409 380 | zval *tmp; 381 | #endif 382 | 383 | annotation = ecalloc(1, sizeof(*annotation)); 384 | zend_object_std_init(&annotation->std, ce TSRMLS_CC); 385 | 386 | #if ZEND_MODULE_API_NO >= 20100409 387 | object_properties_init(&annotation->std, ce); 388 | #else 389 | zend_hash_copy(annotation->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 390 | #endif 391 | 392 | retval.handle = zend_objects_store_put(annotation, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_haruannotation_dtor, NULL TSRMLS_CC); 393 | retval.handlers = &php_haruannotation_handlers; 394 | return retval; 395 | } 396 | 397 | /* }}} */ 398 | 399 | static void php_haruencoder_dtor(void *object TSRMLS_DC) /* {{{ */ 400 | { 401 | php_haruencoder *encoder = (php_haruencoder *)object; 402 | 403 | if (encoder->h) { 404 | encoder->h = NULL; 405 | } 406 | 407 | zend_objects_store_del_ref(&encoder->doc TSRMLS_CC); 408 | 409 | zend_object_std_dtor(&encoder->std TSRMLS_CC); 410 | efree(encoder); 411 | } 412 | 413 | /* }}} */ 414 | 415 | static zend_object_value php_haruencoder_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 416 | { 417 | php_haruencoder *encoder; 418 | zend_object_value retval; 419 | #if ZEND_MODULE_API_NO < 20100409 420 | zval *tmp; 421 | #endif 422 | 423 | encoder = ecalloc(1, sizeof(*encoder)); 424 | zend_object_std_init(&encoder->std, ce TSRMLS_CC); 425 | 426 | #if ZEND_MODULE_API_NO >= 20100409 427 | object_properties_init(&encoder->std, ce); 428 | #else 429 | zend_hash_copy(encoder->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 430 | #endif 431 | 432 | retval.handle = zend_objects_store_put(encoder, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_haruencoder_dtor, NULL TSRMLS_CC); 433 | retval.handlers = &php_haruencoder_handlers; 434 | return retval; 435 | } 436 | 437 | /* }}} */ 438 | 439 | static void php_haruoutline_dtor(void *object TSRMLS_DC) /* {{{ */ 440 | { 441 | php_haruoutline *outline = (php_haruoutline *)object; 442 | 443 | if (outline->h) { 444 | outline->h = NULL; 445 | } 446 | 447 | zend_objects_store_del_ref(&outline->doc TSRMLS_CC); 448 | 449 | zend_object_std_dtor(&outline->std TSRMLS_CC); 450 | efree(outline); 451 | } 452 | 453 | /* }}} */ 454 | 455 | static zend_object_value php_haruoutline_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ 456 | { 457 | php_haruoutline *outline; 458 | zend_object_value retval; 459 | #if ZEND_MODULE_API_NO < 20100409 460 | zval *tmp; 461 | #endif 462 | 463 | outline = ecalloc(1, sizeof(*outline)); 464 | zend_object_std_init(&outline->std, ce TSRMLS_CC); 465 | 466 | #if ZEND_MODULE_API_NO >= 20100409 467 | object_properties_init(&outline->std, ce); 468 | #else 469 | zend_hash_copy(outline->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); 470 | #endif 471 | 472 | retval.handle = zend_objects_store_put(outline, (zend_objects_store_dtor_t)zend_objects_destroy_object, php_haruoutline_dtor, NULL TSRMLS_CC); 473 | retval.handlers = &php_haruoutline_handlers; 474 | return retval; 475 | } 476 | /* }}} */ 477 | 478 | /* }}} */ 479 | 480 | /* internal utilities {{{ */ 481 | 482 | static int php_haru_status_to_errmsg(HPDF_STATUS status, char **msg) /* {{{ */ 483 | { 484 | if (status == HPDF_OK) { 485 | *msg = estrdup("No error"); 486 | return 0; 487 | } 488 | switch(status) { 489 | case HPDF_ARRAY_COUNT_ERR: 490 | case HPDF_ARRAY_ITEM_NOT_FOUND: 491 | case HPDF_ARRAY_ITEM_UNEXPECTED_TYPE: 492 | case HPDF_DICT_ITEM_NOT_FOUND: 493 | case HPDF_DICT_ITEM_UNEXPECTED_TYPE: 494 | case HPDF_DICT_STREAM_LENGTH_NOT_FOUND: 495 | case HPDF_DOC_INVALID_OBJECT: 496 | case HPDF_ERR_UNKNOWN_CLASS: 497 | case HPDF_INVALID_FONTDEF_TYPE: 498 | case HPDF_INVALID_OBJ_ID: 499 | case HPDF_INVALID_STREAM: 500 | case HPDF_ITEM_NOT_FOUND: 501 | case HPDF_NAME_INVALID_VALUE: 502 | case HPDF_NAME_OUT_OF_RANGE: 503 | case HPDF_PAGES_MISSING_KIDS_ENTRY: 504 | case HPDF_PAGE_CANNOT_FIND_OBJECT: 505 | case HPDF_PAGE_CANNOT_GET_ROOT_PAGES: 506 | case HPDF_PAGE_CANNOT_SET_PARENT: 507 | case HPDF_PAGE_INVALID_INDEX: 508 | case HPDF_STREAM_READLN_CONTINUE: 509 | case HPDF_UNSUPPORTED_FONT_TYPE: 510 | case HPDF_XREF_COUNT_ERR: 511 | *msg = estrdup("libharu internal error. The consistency of the data was lost"); 512 | break; 513 | case HPDF_BINARY_LENGTH_ERR: 514 | *msg = estrdup("The length of the data exceeds HPDF_LIMIT_MAX_STRING_LEN"); 515 | break; 516 | case HPDF_CANNOT_GET_PALLET: 517 | *msg = estrdup("Cannot get a pallet data from PNG image"); 518 | break; 519 | case HPDF_DICT_COUNT_ERR: 520 | *msg = estrdup("The count of elements of a dictionary exceeds HPDF_LIMIT_MAX_DICT_ELEMENT"); 521 | break; 522 | case HPDF_DOC_ENCRYPTDICT_NOT_FOUND: 523 | *msg = estrdup("Cannot set permissions and encryption mode before a password is set"); 524 | break; 525 | case HPDF_DUPLICATE_REGISTRATION: 526 | *msg = estrdup("Tried to register a font that has been registered"); 527 | break; 528 | case HPDF_EXCEED_JWW_CODE_NUM_LIMIT: 529 | *msg = estrdup("Cannot register a character to the Japanese word wrap characters list"); 530 | break; 531 | case HPDF_ENCRYPT_INVALID_PASSWORD: 532 | *msg = estrdup("Tried to set the owner password to NULL or the owner password and user password are the same"); 533 | break; 534 | case HPDF_EXCEED_GSTATE_LIMIT: 535 | *msg = estrdup("The depth of the stack exceeded HPDF_LIMIT_MAX_GSTATE"); 536 | break; 537 | case HPDF_FAILD_TO_ALLOC_MEM: 538 | *msg = estrdup("Memory allocation failed"); 539 | break; 540 | case HPDF_FILE_IO_ERROR: 541 | *msg = estrdup("File processing failed"); 542 | break; 543 | case HPDF_FILE_OPEN_ERROR: 544 | *msg = estrdup("Cannot open a file"); 545 | break; 546 | case HPDF_FONT_EXISTS: 547 | *msg = estrdup("Tried to load a font that has been registered"); 548 | break; 549 | case HPDF_FONT_INVALID_WIDTHS_TABLE: 550 | *msg = estrdup("The format of a font-file is invalid"); 551 | break; 552 | case HPDF_INVALID_AFM_HEADER: 553 | *msg = estrdup("Cannot recognize a header of an afm file"); 554 | break; 555 | case HPDF_INVALID_ANNOTATION: 556 | *msg = estrdup("The specified annotation handle is invalid"); 557 | break; 558 | case HPDF_INVALID_BIT_PER_COMPONENT: 559 | *msg = estrdup("Bit-per-component of a image which was set as mask-image is invalid"); 560 | break; 561 | case HPDF_INVALID_CHAR_MATRICS_DATA: 562 | *msg = estrdup("Cannot recognize char-matrics-data of an afm file"); 563 | break; 564 | case HPDF_INVALID_COLOR_SPACE: 565 | *msg = estrdup("The color_space parameter is invalid, or color-space of the image which was set as mask-image is invalid or the function which is invalid in the present color-space was invoked"); 566 | break; 567 | case HPDF_INVALID_COMPRESSION_MODE: 568 | *msg = estrdup("Invalid compression mode specified"); 569 | break; 570 | case HPDF_INVALID_DATE_TIME: 571 | *msg = estrdup("An invalid date-time value was set"); 572 | break; 573 | case HPDF_INVALID_DESTINATION: 574 | *msg = estrdup("An invalid annotation handle was set"); 575 | break; 576 | case HPDF_INVALID_DOCUMENT: 577 | *msg = estrdup("An invalid document handle is set"); 578 | break; 579 | case HPDF_INVALID_DOCUMENT_STATE: 580 | *msg = estrdup("The function which is invalid in the present state was invoked"); 581 | break; 582 | case HPDF_INVALID_ENCODER: 583 | *msg = estrdup("An invalid encoder handle is set"); 584 | break; 585 | case HPDF_INVALID_ENCODER_TYPE: 586 | *msg = estrdup("A combination between font and encoder is wrong"); 587 | break; 588 | case HPDF_INVALID_ENCODING_NAME: 589 | *msg = estrdup("An invalid encoding name is specified"); 590 | break; 591 | case HPDF_INVALID_ENCRYPT_KEY_LEN: 592 | *msg = estrdup("The length of the key of encryption is invalid"); 593 | break; 594 | case HPDF_INVALID_FONTDEF_DATA: 595 | *msg = estrdup("An invalid font handle was set or the font format is unsupported"); 596 | break; 597 | case HPDF_INVALID_FONT_NAME: 598 | *msg = estrdup("A font which has the specified name is not found"); 599 | break; 600 | case HPDF_INVALID_IMAGE: 601 | case HPDF_INVALID_JPEG_DATA: 602 | *msg = estrdup("Unsupported or invalid image format"); 603 | break; 604 | case HPDF_INVALID_N_DATA: 605 | *msg = estrdup("Cannot read a postscript-name from an afm file"); 606 | break; 607 | case HPDF_INVALID_OBJECT: 608 | *msg = estrdup("An invalid object is set"); 609 | break; 610 | case HPDF_INVALID_OPERATION: 611 | *msg = estrdup("Invalid operation, cannot perform the requested action"); 612 | break; 613 | case HPDF_INVALID_OUTLINE: 614 | *msg = estrdup("An invalid outline-handle was specified"); 615 | break; 616 | case HPDF_INVALID_PAGE: 617 | *msg = estrdup("An invalid page-handle was specified"); 618 | break; 619 | case HPDF_INVALID_PAGES: 620 | *msg = estrdup("An invalid pages-handle was specified"); 621 | break; 622 | case HPDF_INVALID_PARAMETER: 623 | *msg = estrdup("An invalid value is set"); 624 | break; 625 | case HPDF_INVALID_PNG_IMAGE: 626 | *msg = estrdup("Invalid PNG image format"); 627 | break; 628 | case HPDF_MISSING_FILE_NAME_ENTRY: 629 | *msg = estrdup("libharu internal error. The _FILE_NAME entry for delayed loading is missing"); 630 | break; 631 | case HPDF_INVALID_TTC_FILE: 632 | *msg = estrdup("Invalid .TTC file format"); 633 | break; 634 | case HPDF_INVALID_TTC_INDEX: 635 | *msg = estrdup("The index parameter exceeds the number of included fonts"); 636 | break; 637 | case HPDF_INVALID_WX_DATA: 638 | *msg = estrdup("Cannot read a width-data from an afm file"); 639 | break; 640 | case HPDF_LIBPNG_ERROR: 641 | *msg = estrdup("An error has returned from PNGLIB while loading an image"); 642 | break; 643 | case HPDF_PAGE_CANNOT_RESTORE_GSTATE: 644 | *msg = estrdup("There are no graphics-states to be restored"); 645 | break; 646 | case HPDF_PAGE_FONT_NOT_FOUND: 647 | *msg = estrdup("The current font is not set"); 648 | break; 649 | case HPDF_PAGE_INVALID_FONT: 650 | *msg = estrdup("An invalid font-handle was specified"); 651 | break; 652 | case HPDF_PAGE_INVALID_FONT_SIZE: 653 | *msg = estrdup("An invalid font-size was set"); 654 | break; 655 | case HPDF_PAGE_INVALID_GMODE: 656 | *msg = estrdup("Invalid graphics mode"); 657 | break; 658 | case HPDF_PAGE_INVALID_ROTATE_VALUE: 659 | *msg = estrdup("The specified value is not a multiple of 90"); 660 | break; 661 | case HPDF_PAGE_INVALID_SIZE: 662 | *msg = estrdup("An invalid page-size was set"); 663 | break; 664 | case HPDF_PAGE_INVALID_XOBJECT: 665 | *msg = estrdup("An invalid image-handle was set"); 666 | break; 667 | case HPDF_PAGE_OUT_OF_RANGE: 668 | *msg = estrdup("The specified value is out of range"); 669 | break; 670 | case HPDF_REAL_OUT_OF_RANGE: 671 | *msg = estrdup("The specified value is out of range"); 672 | break; 673 | case HPDF_STREAM_EOF: 674 | *msg = estrdup("Unexpected EOF marker was detected"); 675 | break; 676 | case HPDF_STRING_OUT_OF_RANGE: 677 | *msg = estrdup("The length of the specified text is too big"); 678 | break; 679 | case HPDF_THIS_FUNC_WAS_SKIPPED: 680 | *msg = estrdup("The execution of a function was skipped because of other errors"); 681 | break; 682 | case HPDF_TTF_CANNOT_EMBEDDING_FONT: 683 | *msg = estrdup("This font cannot be embedded (restricted by license)"); 684 | break; 685 | case HPDF_TTF_INVALID_CMAP: 686 | *msg = estrdup("Unsupported or invalid ttf format (cannot find unicode cmap)"); 687 | break; 688 | case HPDF_TTF_INVALID_FOMAT: 689 | *msg = estrdup("Unsupported or invalid ttf format"); 690 | break; 691 | case HPDF_TTF_MISSING_TABLE: 692 | *msg = estrdup("Unsupported or invalid ttf format (cannot find a necessary table)"); 693 | break; 694 | case HPDF_UNSUPPORTED_FUNC: 695 | *msg = estrdup("The library is not configured to use PNGLIB or internal error occurred"); 696 | break; 697 | case HPDF_UNSUPPORTED_JPEG_FORMAT: 698 | *msg = estrdup("Unsupported or invalid JPEG format"); 699 | break; 700 | case HPDF_UNSUPPORTED_TYPE1_FONT: 701 | *msg = estrdup("Failed to parse .PFB file"); 702 | break; 703 | case HPDF_ZLIB_ERROR: 704 | *msg = estrdup("An error has occurred while executing a function of Zlib"); 705 | break; 706 | case HPDF_INVALID_PAGE_INDEX: 707 | *msg = estrdup("An error returned from Zlib"); 708 | break; 709 | case HPDF_INVALID_URI: 710 | *msg = estrdup("An invalid URI was set"); 711 | break; 712 | case HPDF_ANNOT_INVALID_ICON: 713 | *msg = estrdup("An invalid icon was set"); 714 | break; 715 | case HPDF_ANNOT_INVALID_BORDER_STYLE: 716 | *msg = estrdup("An invalid border-style was set"); 717 | break; 718 | case HPDF_PAGE_INVALID_DIRECTION: 719 | *msg = estrdup("An invalid page-direction was set"); 720 | break; 721 | case HPDF_INVALID_FONT: 722 | *msg = estrdup("An invalid font-handle was specified"); 723 | break; 724 | case HPDF_PAGE_INSUFFICIENT_SPACE: 725 | *msg = estrdup("Insufficient space for text"); 726 | break; 727 | default: 728 | *msg = estrdup("Unknown error occurred, please report"); 729 | break; 730 | } 731 | return 1; 732 | } 733 | 734 | /* }}} */ 735 | 736 | static int php_haru_status_to_exception(HPDF_STATUS status TSRMLS_DC) /* {{{ */ 737 | { 738 | if (status != HPDF_OK) { 739 | char *msg; 740 | php_haru_status_to_errmsg(status, &msg); 741 | zend_throw_exception_ex(ce_haruexception, status TSRMLS_CC, msg); 742 | efree(msg); 743 | return 1; 744 | } 745 | return 0; 746 | } 747 | 748 | /* }}} */ 749 | 750 | static int php_haru_check_error(HPDF_Error error TSRMLS_DC) /* {{{ */ 751 | { 752 | HPDF_STATUS status = HPDF_CheckError(error); 753 | 754 | return php_haru_status_to_exception(status TSRMLS_CC); 755 | } 756 | 757 | /* }}} */ 758 | 759 | static int php_haru_check_doc_error(php_harudoc *doc TSRMLS_DC) /* {{{ */ 760 | { 761 | HPDF_STATUS status = HPDF_GetError(doc->h); 762 | 763 | return php_haru_status_to_exception(status TSRMLS_CC); 764 | } 765 | 766 | /* }}} */ 767 | 768 | static HPDF_Rect php_haru_array_to_rect(zval *array) /* {{{ */ 769 | { 770 | int i = 0; 771 | zval **element, tmp, tmp_element; 772 | HPDF_Rect r; 773 | 774 | for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(array)); 775 | zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) &element) == SUCCESS; 776 | zend_hash_move_forward(Z_ARRVAL_P(array))) { 777 | if (Z_TYPE_PP(element) != IS_DOUBLE) { 778 | tmp = **element; 779 | zval_copy_ctor(&tmp); 780 | INIT_PZVAL(&tmp); 781 | convert_to_double(&tmp); 782 | tmp_element = tmp; 783 | } else { 784 | tmp_element = **element; 785 | } 786 | 787 | switch(i) { 788 | case 0: 789 | r.left = Z_DVAL(tmp_element); 790 | break; 791 | case 1: 792 | r.bottom = Z_DVAL(tmp_element); 793 | break; 794 | case 2: 795 | r.right = Z_DVAL(tmp_element); 796 | break; 797 | case 3: 798 | r.top = Z_DVAL(tmp_element); 799 | break; 800 | } 801 | 802 | if (Z_TYPE_PP(element) != IS_DOUBLE) { 803 | zval_dtor(&tmp); 804 | } 805 | i++; 806 | } 807 | 808 | return r; 809 | } 810 | /* }}} */ 811 | 812 | /* }}} */ 813 | 814 | /* HaruDoc methods {{{ */ 815 | 816 | /* {{{ proto void HaruDoc::__construct() 817 | Construct new HaruDoc instance */ 818 | static PHP_METHOD(HaruDoc, __construct) 819 | { 820 | zval *object = getThis(); 821 | php_harudoc *doc; 822 | 823 | if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")) { 824 | return; 825 | } 826 | 827 | doc = (php_harudoc *)zend_object_store_get_object(object TSRMLS_CC); 828 | 829 | if (doc->h) { 830 | /* called __construct() twice, bail out */ 831 | return; 832 | } 833 | 834 | doc->h = HPDF_New(NULL, NULL); 835 | 836 | PHP_HARU_NULL_CHECK(doc->h, "Cannot create HaruDoc handle"); 837 | } 838 | /* }}} */ 839 | 840 | /* {{{ proto bool HaruDoc::resetError() 841 | Reset error state in the document handle */ 842 | static PHP_METHOD(HaruDoc, resetError) 843 | { 844 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 845 | 846 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 847 | return; 848 | } 849 | 850 | HPDF_ResetError(doc->h); 851 | RETURN_TRUE; 852 | } 853 | /* }}} */ 854 | 855 | /* {{{ proto object HaruDoc::addPage() 856 | Add new page to the document */ 857 | static PHP_METHOD(HaruDoc, addPage) 858 | { 859 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 860 | php_harupage *page; 861 | HPDF_Page p; 862 | 863 | p = HPDF_AddPage(doc->h); 864 | 865 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 866 | return; 867 | } 868 | PHP_HARU_NULL_CHECK(p, "Cannot create HaruPage handle"); 869 | 870 | object_init_ex(return_value, ce_harupage); 871 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 872 | page = (php_harupage *)zend_object_store_get_object(return_value TSRMLS_CC); 873 | 874 | page->doc = *getThis(); 875 | page->h = p; 876 | 877 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 878 | } 879 | /* }}} */ 880 | 881 | /* {{{ proto object HaruDoc::insertPage(object page) 882 | Insert new page just before the specified page */ 883 | static PHP_METHOD(HaruDoc, insertPage) 884 | { 885 | zval *z_page; 886 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 887 | php_harupage *target, *page; 888 | HPDF_Page p; 889 | 890 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_page, ce_harupage) == FAILURE) { 891 | return; 892 | } 893 | 894 | target = (php_harupage *)zend_object_store_get_object(z_page TSRMLS_CC); 895 | 896 | p = HPDF_InsertPage(doc->h, target->h); 897 | 898 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 899 | return; 900 | } 901 | PHP_HARU_NULL_CHECK(p, "Cannot create HaruPage handle"); 902 | 903 | object_init_ex(return_value, ce_harupage); 904 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 905 | 906 | page = (php_harupage *)zend_object_store_get_object(return_value TSRMLS_CC); 907 | 908 | page->doc = *getThis(); 909 | page->h = p; 910 | 911 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 912 | } 913 | /* }}} */ 914 | 915 | /* {{{ proto object HaruDoc::getCurrentPage() 916 | Return current page of the document */ 917 | static PHP_METHOD(HaruDoc, getCurrentPage) 918 | { 919 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 920 | php_harupage *page; 921 | HPDF_Page p; 922 | 923 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 924 | return; 925 | } 926 | 927 | p = HPDF_GetCurrentPage(doc->h); 928 | 929 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 930 | return; 931 | } 932 | 933 | if (!p) { 934 | /* no current page is not an error */ 935 | RETURN_FALSE; 936 | } 937 | 938 | object_init_ex(return_value, ce_harupage); 939 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 940 | 941 | page = (php_harupage *)zend_object_store_get_object(return_value TSRMLS_CC); 942 | 943 | page->doc = *getThis(); 944 | page->h = p; 945 | 946 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 947 | } 948 | /* }}} */ 949 | 950 | /* {{{ proto object HaruDoc::getEncoder(string encoding) 951 | Return HaruEncoder instance with the specified encoding */ 952 | static PHP_METHOD(HaruDoc, getEncoder) 953 | { 954 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 955 | php_haruencoder *encoder; 956 | HPDF_Encoder e; 957 | char *enc; 958 | int enc_len; 959 | 960 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &enc, &enc_len) == FAILURE) { 961 | return; 962 | } 963 | 964 | e = HPDF_GetEncoder(doc->h, (const char *)enc); 965 | 966 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 967 | return; 968 | } 969 | PHP_HARU_NULL_CHECK(e, "Cannot create HaruEncoder handle"); 970 | 971 | object_init_ex(return_value, ce_haruencoder); 972 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 973 | 974 | encoder = (php_haruencoder *)zend_object_store_get_object(return_value TSRMLS_CC); 975 | 976 | encoder->doc = *getThis(); 977 | encoder->h = e; 978 | 979 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 980 | } 981 | /* }}} */ 982 | 983 | /* {{{ proto object HaruDoc::getCurrentEncoder() 984 | Return HaruEncoder currently used in the document */ 985 | static PHP_METHOD(HaruDoc, getCurrentEncoder) 986 | { 987 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 988 | php_haruencoder *encoder; 989 | HPDF_Encoder e; 990 | 991 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 992 | return; 993 | } 994 | 995 | e = HPDF_GetCurrentEncoder(doc->h); 996 | 997 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 998 | return; 999 | } 1000 | 1001 | if (!e) { 1002 | /* no encoder set */ 1003 | RETURN_FALSE; 1004 | } 1005 | 1006 | object_init_ex(return_value, ce_haruencoder); 1007 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 1008 | 1009 | encoder = (php_haruencoder *)zend_object_store_get_object(return_value TSRMLS_CC); 1010 | 1011 | encoder->doc = *getThis(); 1012 | encoder->h = e; 1013 | 1014 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 1015 | } 1016 | /* }}} */ 1017 | 1018 | /* {{{ proto bool HaruDoc::setCurrentEncoder(string encoding) 1019 | Set the current encoder for the document */ 1020 | static PHP_METHOD(HaruDoc, setCurrentEncoder) 1021 | { 1022 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1023 | char *enc; 1024 | int enc_len; 1025 | HPDF_STATUS status; 1026 | 1027 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &enc, &enc_len) == FAILURE) { 1028 | return; 1029 | } 1030 | 1031 | status = HPDF_SetCurrentEncoder(doc->h, (const char *)enc); 1032 | 1033 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1034 | return; 1035 | } 1036 | RETURN_TRUE; 1037 | } 1038 | /* }}} */ 1039 | 1040 | /* {{{ proto bool HaruDoc::save(string file) 1041 | Save the document into the specified file */ 1042 | static PHP_METHOD(HaruDoc, save) 1043 | { 1044 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1045 | char *filename; 1046 | int filename_len; 1047 | HPDF_STATUS status; 1048 | 1049 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { 1050 | return; 1051 | } 1052 | 1053 | HARU_CHECK_FILE(filename); 1054 | 1055 | status = HPDF_SaveToFile(doc->h, filename); 1056 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1057 | return; 1058 | } 1059 | RETURN_TRUE; 1060 | } 1061 | /* }}} */ 1062 | 1063 | /* {{{ proto bool HaruDoc::output() 1064 | Write the document data to the output buffer */ 1065 | static PHP_METHOD(HaruDoc, output) 1066 | { 1067 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1068 | HPDF_STATUS status; 1069 | HPDF_UINT32 size, requested_bytes; 1070 | char *buffer; 1071 | unsigned int buffer_size; 1072 | 1073 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1074 | return; 1075 | } 1076 | 1077 | status = HPDF_SaveToStream(doc->h); 1078 | 1079 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1080 | return; 1081 | } 1082 | 1083 | size = HPDF_GetStreamSize(doc->h); 1084 | 1085 | if (!size) { 1086 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Zero stream size, the PDF document contains no data"); 1087 | return; 1088 | } 1089 | 1090 | buffer_size = (size > PHP_HARU_BUF_SIZE) ? PHP_HARU_BUF_SIZE : size; 1091 | buffer = emalloc(buffer_size + 1); 1092 | 1093 | while (size > 0) { 1094 | requested_bytes = buffer_size; 1095 | 1096 | status = HPDF_ReadFromStream(doc->h, (HPDF_BYTE *)buffer, &requested_bytes); 1097 | if (status != HPDF_STREAM_EOF && php_haru_status_to_exception(status TSRMLS_CC)) { 1098 | efree(buffer); 1099 | return; 1100 | } 1101 | 1102 | if (requested_bytes > 0) { 1103 | PHPWRITE(buffer, requested_bytes); 1104 | size -= requested_bytes; 1105 | } 1106 | 1107 | if (status == HPDF_STREAM_EOF) { 1108 | /* reached the end of the stream */ 1109 | break; 1110 | } 1111 | } 1112 | efree(buffer); 1113 | RETURN_TRUE; 1114 | } 1115 | /* }}} */ 1116 | 1117 | /* {{{ proto bool HaruDoc::saveToStream() 1118 | Save the document data to a temporary stream */ 1119 | static PHP_METHOD(HaruDoc, saveToStream) 1120 | { 1121 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1122 | HPDF_STATUS status; 1123 | 1124 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1125 | return; 1126 | } 1127 | 1128 | status = HPDF_SaveToStream(doc->h); 1129 | 1130 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1131 | return; 1132 | } 1133 | RETURN_TRUE; 1134 | } 1135 | /* }}} */ 1136 | 1137 | /* {{{ proto bool HaruDoc::resetStream() 1138 | Rewind the temporary stream */ 1139 | static PHP_METHOD(HaruDoc, resetStream) 1140 | { 1141 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1142 | HPDF_STATUS status; 1143 | 1144 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1145 | return; 1146 | } 1147 | 1148 | status = HPDF_ResetStream(doc->h); 1149 | 1150 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1151 | return; 1152 | } 1153 | RETURN_TRUE; 1154 | } 1155 | /* }}} */ 1156 | 1157 | /* {{{ proto bool HaruDoc::getStreamSize() 1158 | Get the size of the temporary stream */ 1159 | static PHP_METHOD(HaruDoc, getStreamSize) 1160 | { 1161 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1162 | HPDF_UINT32 size; 1163 | 1164 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1165 | return; 1166 | } 1167 | 1168 | size = HPDF_GetStreamSize(doc->h); 1169 | 1170 | RETURN_LONG((long)size); 1171 | } 1172 | /* }}} */ 1173 | 1174 | /* {{{ proto bool HaruDoc::readFromStream(int bytes) 1175 | Reads data from the temporary stream */ 1176 | static PHP_METHOD(HaruDoc, readFromStream) 1177 | { 1178 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1179 | HPDF_STATUS status; 1180 | long size; 1181 | HPDF_UINT32 requested_bytes; 1182 | char *buffer; 1183 | 1184 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &size) == FAILURE) { 1185 | return; 1186 | } 1187 | 1188 | if (size <= 0 || (size + 1) <= 0) { 1189 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "number of bytes must be greater than zero"); 1190 | return; 1191 | } 1192 | 1193 | buffer = safe_emalloc(size, 1, 1); 1194 | requested_bytes = size; 1195 | 1196 | status = HPDF_ReadFromStream(doc->h, (HPDF_BYTE *)buffer, &requested_bytes); 1197 | 1198 | if (status != HPDF_STREAM_EOF && php_haru_status_to_exception(status TSRMLS_CC)) { 1199 | efree(buffer); 1200 | return; 1201 | } 1202 | 1203 | if (requested_bytes > 0) { 1204 | buffer[requested_bytes] = '\0'; 1205 | RETURN_STRINGL(buffer, requested_bytes, 0); 1206 | } 1207 | efree(buffer); 1208 | RETURN_FALSE; 1209 | } 1210 | /* }}} */ 1211 | 1212 | /* {{{ proto bool HaruDoc::setPageLayout(int layout) 1213 | Set how pages should be displayed */ 1214 | static PHP_METHOD(HaruDoc, setPageLayout) 1215 | { 1216 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1217 | HPDF_STATUS status; 1218 | long layout; 1219 | 1220 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &layout) == FAILURE) { 1221 | return; 1222 | } 1223 | 1224 | switch(layout) { 1225 | case HPDF_PAGE_LAYOUT_SINGLE: 1226 | case HPDF_PAGE_LAYOUT_ONE_COLUMN: 1227 | case HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT: 1228 | case HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT: 1229 | /* only these are valid */ 1230 | break; 1231 | default: 1232 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid page layout value"); 1233 | return; 1234 | } 1235 | 1236 | status = HPDF_SetPageLayout(doc->h, (HPDF_PageLayout)layout); 1237 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1238 | return; 1239 | } 1240 | RETURN_TRUE; 1241 | } 1242 | /* }}} */ 1243 | 1244 | /* {{{ proto int HaruDoc::getPageLayout() 1245 | Return current page layout */ 1246 | static PHP_METHOD(HaruDoc, getPageLayout) 1247 | { 1248 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1249 | HPDF_PageLayout layout; 1250 | 1251 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1252 | return; 1253 | } 1254 | 1255 | layout = HPDF_GetPageLayout(doc->h); 1256 | if (layout == HPDF_PAGE_LAYOUT_EOF) { 1257 | RETURN_FALSE; 1258 | } 1259 | RETURN_LONG((long)layout); 1260 | } 1261 | /* }}} */ 1262 | 1263 | /* {{{ proto bool HaruDoc::setPageMode(int mode) 1264 | Set how the document should be displayed */ 1265 | static PHP_METHOD(HaruDoc, setPageMode) 1266 | { 1267 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1268 | HPDF_STATUS status; 1269 | long mode; 1270 | 1271 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { 1272 | return; 1273 | } 1274 | 1275 | switch(mode) { 1276 | case HPDF_PAGE_MODE_USE_NONE: 1277 | case HPDF_PAGE_MODE_USE_OUTLINE: 1278 | case HPDF_PAGE_MODE_USE_THUMBS: 1279 | case HPDF_PAGE_MODE_FULL_SCREEN: 1280 | /* only these are valid */ 1281 | break; 1282 | default: 1283 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid page mode value"); 1284 | return; 1285 | } 1286 | 1287 | status = HPDF_SetPageMode(doc->h, (HPDF_PageMode)mode); 1288 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1289 | return; 1290 | } 1291 | RETURN_TRUE; 1292 | } 1293 | /* }}} */ 1294 | 1295 | /* {{{ proto int HaruDoc::getPageMode() 1296 | Return current page mode */ 1297 | static PHP_METHOD(HaruDoc, getPageMode) 1298 | { 1299 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1300 | HPDF_PageMode mode; 1301 | 1302 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1303 | return; 1304 | } 1305 | 1306 | mode = HPDF_GetPageMode(doc->h); 1307 | RETURN_LONG((long)mode); 1308 | } 1309 | /* }}} */ 1310 | 1311 | /* {{{ proto bool HaruDoc::setInfoAttr(int type, string info) 1312 | Set the info attributes of the document */ 1313 | static PHP_METHOD(HaruDoc, setInfoAttr) 1314 | { 1315 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1316 | HPDF_STATUS status; 1317 | long type; 1318 | char *info; 1319 | int info_len; 1320 | 1321 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &info, &info_len) == FAILURE) { 1322 | return; 1323 | } 1324 | 1325 | switch(type) { 1326 | case HPDF_INFO_AUTHOR: 1327 | case HPDF_INFO_CREATOR: 1328 | case HPDF_INFO_TITLE: 1329 | case HPDF_INFO_SUBJECT: 1330 | case HPDF_INFO_KEYWORDS: 1331 | /* only these are valid */ 1332 | break; 1333 | default: 1334 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid info attribute type value"); 1335 | return; 1336 | } 1337 | 1338 | status = HPDF_SetInfoAttr(doc->h, (HPDF_InfoType)type, (const char *)info); 1339 | 1340 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1341 | return; 1342 | } 1343 | 1344 | RETURN_TRUE; 1345 | } 1346 | /* }}} */ 1347 | 1348 | /* {{{ proto string HaruDoc::getInfoAttr(int type) 1349 | Get current value of the specified document attribute */ 1350 | static PHP_METHOD(HaruDoc, getInfoAttr) 1351 | { 1352 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1353 | long type; 1354 | const char *info; 1355 | 1356 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) { 1357 | return; 1358 | } 1359 | 1360 | switch(type) { 1361 | case HPDF_INFO_CREATION_DATE: 1362 | case HPDF_INFO_MOD_DATE: 1363 | case HPDF_INFO_AUTHOR: 1364 | case HPDF_INFO_CREATOR: 1365 | case HPDF_INFO_TITLE: 1366 | case HPDF_INFO_SUBJECT: 1367 | case HPDF_INFO_KEYWORDS: 1368 | /* only these are valid */ 1369 | break; 1370 | default: 1371 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid info attribute type value"); 1372 | return; 1373 | } 1374 | 1375 | info = HPDF_GetInfoAttr(doc->h, (HPDF_InfoType)type); 1376 | 1377 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1378 | return; 1379 | } 1380 | 1381 | if (!info) { /* no error, it's just not set */ 1382 | RETURN_EMPTY_STRING(); 1383 | } 1384 | RETURN_STRING((char *)info, 1); 1385 | } 1386 | /* }}} */ 1387 | 1388 | /* {{{ proto bool HaruDoc::setInfoDateAttr(int type, int year, int month, int day, int hour, int min, int sec, string ind, int off_hour, int off_min) 1389 | Set the datetime info attributes of the document */ 1390 | static PHP_METHOD(HaruDoc, setInfoDateAttr) 1391 | { 1392 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1393 | HPDF_STATUS status; 1394 | long type, year, month, day, hour, min, sec, off_hour, off_min; 1395 | char *ind; 1396 | int ind_len; 1397 | HPDF_Date value; 1398 | 1399 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllllllsll", &type, &year, &month, &day, &hour, &min, &sec, &ind, &ind_len, &off_hour, &off_min) == FAILURE) { 1400 | return; 1401 | } 1402 | 1403 | switch(type) { 1404 | case HPDF_INFO_CREATION_DATE: 1405 | case HPDF_INFO_MOD_DATE: 1406 | /* only these are valid */ 1407 | break; 1408 | default: 1409 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid datetime info attribute type value"); 1410 | return; 1411 | } 1412 | 1413 | value.year = (HPDF_INT) year; 1414 | value.month = (HPDF_INT) month; 1415 | value.day = (HPDF_INT) day; 1416 | value.hour = (HPDF_INT) hour; 1417 | value.minutes = (HPDF_INT) min; 1418 | value.seconds = (HPDF_INT) sec; 1419 | value.ind = (ind[0] == 0) ? 32 /* ' ' */ : ind[0]; /* make libharu happy with empty ind */ 1420 | value.off_hour = (HPDF_INT) off_hour; 1421 | value.off_minutes = (HPDF_INT) off_min; 1422 | 1423 | status = HPDF_SetInfoDateAttr(doc->h, (HPDF_InfoType)type, value); 1424 | 1425 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1426 | return; 1427 | } 1428 | 1429 | RETURN_TRUE; 1430 | } 1431 | /* }}} */ 1432 | 1433 | /* {{{ proto object HaruDoc::getFont(string fontname[, string encoding ]) 1434 | Create and return HaruFont instance */ 1435 | static PHP_METHOD(HaruDoc, getFont) 1436 | { 1437 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1438 | char *fontname, *encoding = NULL; 1439 | int fontname_len, encoding_len = 0; 1440 | HPDF_Font f; 1441 | php_harufont *font; 1442 | 1443 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &fontname, &fontname_len, &encoding, &encoding_len) == FAILURE) { 1444 | return; 1445 | } 1446 | 1447 | if (encoding_len == 0) { 1448 | encoding = NULL; 1449 | } 1450 | 1451 | f = HPDF_GetFont(doc->h, (const char *)fontname, (const char*)encoding); 1452 | 1453 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1454 | return; 1455 | } 1456 | PHP_HARU_NULL_CHECK(f, "Cannot create HaruFont handle"); 1457 | 1458 | object_init_ex(return_value, ce_harufont); 1459 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 1460 | 1461 | font = (php_harufont*)zend_object_store_get_object(return_value TSRMLS_CC); 1462 | 1463 | font->doc = *getThis(); 1464 | font->h = f; 1465 | 1466 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 1467 | } 1468 | /* }}} */ 1469 | 1470 | /* {{{ proto string HaruDoc::loadTTF(string fontfile[, bool embed]) 1471 | Load TTF font file */ 1472 | static PHP_METHOD(HaruDoc, loadTTF) 1473 | { 1474 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1475 | char *fontfile; 1476 | int fontfile_len; 1477 | zend_bool embed = 0; 1478 | const char *name; 1479 | 1480 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &fontfile, &fontfile_len, &embed) == FAILURE) { 1481 | return; 1482 | } 1483 | 1484 | HARU_CHECK_FILE(fontfile); 1485 | 1486 | name = HPDF_LoadTTFontFromFile(doc->h, (const char *)fontfile, (HPDF_BOOL)embed); 1487 | 1488 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1489 | return; 1490 | } 1491 | PHP_HARU_NULL_CHECK(name, "Failed to load TTF font"); 1492 | 1493 | RETURN_STRING((char *)name, 1); 1494 | } 1495 | /* }}} */ 1496 | 1497 | /* {{{ proto string HaruDoc::loadTTC(string fontfile, int index[, bool embed ]) 1498 | Load font with the speicifed index from TTC file */ 1499 | static PHP_METHOD(HaruDoc, loadTTC) 1500 | { 1501 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1502 | char *fontfile; 1503 | int fontfile_len; 1504 | zend_bool embed = 0; 1505 | const char *name; 1506 | long index; 1507 | 1508 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|b", &fontfile, &fontfile_len, &index, &embed) == FAILURE) { 1509 | return; 1510 | } 1511 | 1512 | HARU_CHECK_FILE(fontfile); 1513 | 1514 | name = HPDF_LoadTTFontFromFile2(doc->h, (const char *)fontfile, (HPDF_UINT)index, (HPDF_BOOL)embed); 1515 | 1516 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1517 | return; 1518 | } 1519 | PHP_HARU_NULL_CHECK(name, "Failed to load TTF font from the font collection"); 1520 | 1521 | RETURN_STRING((char *)name, 1); 1522 | } 1523 | /* }}} */ 1524 | 1525 | /* {{{ proto string HaruDoc::loadType1(string afmfile[, string pfmfile]) 1526 | Load Type1 font */ 1527 | static PHP_METHOD(HaruDoc, loadType1) 1528 | { 1529 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1530 | char *afmfile, *pfmfile = NULL; 1531 | int afmfile_len, pfmfile_len = 0; 1532 | const char *name; 1533 | 1534 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &afmfile, &afmfile_len, &pfmfile, &pfmfile_len) == FAILURE) { 1535 | return; 1536 | } 1537 | 1538 | HARU_CHECK_FILE(afmfile); 1539 | 1540 | if (pfmfile_len == 0) { 1541 | pfmfile = NULL; 1542 | } else { 1543 | HARU_CHECK_FILE(pfmfile); 1544 | } 1545 | 1546 | name = HPDF_LoadType1FontFromFile(doc->h, (const char *)afmfile, (const char *)pfmfile); 1547 | 1548 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1549 | return; 1550 | } 1551 | PHP_HARU_NULL_CHECK(name, "Failed to load Type1 font"); 1552 | 1553 | RETURN_STRING((char *)name, 1); 1554 | } 1555 | /* }}} */ 1556 | 1557 | /* {{{ proto object HaruDoc::loadPNG(string filename[, bool deferred]) 1558 | Load PNG image and return HaruImage instance */ 1559 | static PHP_METHOD(HaruDoc, loadPNG) 1560 | { 1561 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1562 | php_haruimage *image; 1563 | HPDF_Image i; 1564 | char *filename; 1565 | int filename_len; 1566 | zend_bool deferred = 0; 1567 | 1568 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &filename, &filename_len, &deferred) == FAILURE) { 1569 | return; 1570 | } 1571 | 1572 | HARU_CHECK_FILE(filename); 1573 | 1574 | if (deferred) { 1575 | i = HPDF_LoadPngImageFromFile2(doc->h, (const char*)filename); 1576 | } else { 1577 | /* default */ 1578 | i = HPDF_LoadPngImageFromFile(doc->h, (const char*)filename); 1579 | } 1580 | 1581 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1582 | return; 1583 | } 1584 | PHP_HARU_NULL_CHECK(i, "Failed to load PNG image"); 1585 | 1586 | object_init_ex(return_value, ce_haruimage); 1587 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 1588 | 1589 | image = (php_haruimage *)zend_object_store_get_object(return_value TSRMLS_CC); 1590 | 1591 | image->doc = *getThis(); 1592 | image->h = i; 1593 | image->filename = estrndup(filename, filename_len); 1594 | 1595 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 1596 | } 1597 | /* }}} */ 1598 | 1599 | /* {{{ proto object HaruDoc::loadJPEG(string filename) 1600 | Load JPEG image and return HaruImage instance */ 1601 | static PHP_METHOD(HaruDoc, loadJPEG) 1602 | { 1603 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1604 | php_haruimage *image; 1605 | HPDF_Image i; 1606 | char *filename; 1607 | int filename_len; 1608 | 1609 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { 1610 | return; 1611 | } 1612 | 1613 | HARU_CHECK_FILE(filename); 1614 | 1615 | i = HPDF_LoadJpegImageFromFile(doc->h, (const char*)filename); 1616 | 1617 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1618 | return; 1619 | } 1620 | PHP_HARU_NULL_CHECK(i, "Failed to load JPEG image"); 1621 | 1622 | object_init_ex(return_value, ce_haruimage); 1623 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 1624 | 1625 | image = (php_haruimage *)zend_object_store_get_object(return_value TSRMLS_CC); 1626 | 1627 | image->doc = *getThis(); 1628 | image->h = i; 1629 | image->filename = estrndup(filename, filename_len); 1630 | 1631 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 1632 | } 1633 | /* }}} */ 1634 | 1635 | /* {{{ proto object HaruDoc::loadRaw(string filename, int width, int height, int color_space) 1636 | Load RAW image and return HaruImage instance */ 1637 | static PHP_METHOD(HaruDoc, loadRaw) 1638 | { 1639 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1640 | php_haruimage *image; 1641 | HPDF_Image i; 1642 | char *filename; 1643 | int filename_len; 1644 | long width, height, color_space; 1645 | 1646 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slll", &filename, &filename_len, &width, &height, &color_space) == FAILURE) { 1647 | return; 1648 | } 1649 | 1650 | HARU_CHECK_FILE(filename); 1651 | 1652 | switch(color_space) { 1653 | case HPDF_CS_DEVICE_GRAY: 1654 | case HPDF_CS_DEVICE_RGB: 1655 | case HPDF_CS_DEVICE_CMYK: 1656 | /* only these are valid */ 1657 | break; 1658 | default: 1659 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid color_space parameter value"); 1660 | return; 1661 | } 1662 | 1663 | i = HPDF_LoadRawImageFromFile(doc->h, (const char *)filename, width, height, (HPDF_ColorSpace)color_space); 1664 | 1665 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1666 | return; 1667 | } 1668 | PHP_HARU_NULL_CHECK(i, "Failed to load RAW image"); 1669 | 1670 | object_init_ex(return_value, ce_haruimage); 1671 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 1672 | 1673 | image = (php_haruimage *)zend_object_store_get_object(return_value TSRMLS_CC); 1674 | 1675 | image->doc = *getThis(); 1676 | image->h = i; 1677 | image->filename = estrndup(filename, filename_len); 1678 | 1679 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 1680 | } 1681 | /* }}} */ 1682 | 1683 | /* {{{ proto bool HaruDoc::setPassword(string owner_password, string user_password) 1684 | Set owner and user passwords for the document */ 1685 | static PHP_METHOD(HaruDoc, setPassword) 1686 | { 1687 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1688 | char *owner_pswd, *user_pswd; 1689 | int owner_pswd_len, user_pswd_len; 1690 | HPDF_STATUS status; 1691 | 1692 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &owner_pswd, &owner_pswd_len, &user_pswd, &user_pswd_len) == FAILURE) { 1693 | return; 1694 | } 1695 | 1696 | status = HPDF_SetPassword(doc->h, (const char *)owner_pswd, (const char *)user_pswd); 1697 | 1698 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1699 | return; 1700 | } 1701 | RETURN_TRUE; 1702 | } 1703 | /* }}} */ 1704 | 1705 | /* {{{ proto bool HaruDoc::setPermission(int permission) 1706 | Set permissions for the document */ 1707 | static PHP_METHOD(HaruDoc, setPermission) 1708 | { 1709 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1710 | long permission; 1711 | HPDF_STATUS status; 1712 | 1713 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &permission) == FAILURE) { 1714 | return; 1715 | } 1716 | 1717 | status = HPDF_SetPermission(doc->h, (HPDF_UINT)permission); 1718 | 1719 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1720 | return; 1721 | } 1722 | RETURN_TRUE; 1723 | } 1724 | /* }}} */ 1725 | 1726 | /* {{{ proto bool HaruDoc::setEncryptionMode(int mode[, int key_len]) 1727 | Set encryption mode for the document */ 1728 | static PHP_METHOD(HaruDoc, setEncryptionMode) 1729 | { 1730 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1731 | long mode, key_len = 5; 1732 | HPDF_STATUS status; 1733 | 1734 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &mode, &key_len) == FAILURE) { 1735 | return; 1736 | } 1737 | 1738 | switch (mode) { 1739 | case HPDF_ENCRYPT_R2: 1740 | case HPDF_ENCRYPT_R3: 1741 | /* only these are valid */ 1742 | break; 1743 | default: 1744 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid encrypt mode value"); 1745 | return; 1746 | } 1747 | 1748 | status = HPDF_SetEncryptionMode(doc->h, (HPDF_EncryptMode)mode, (HPDF_UINT)key_len); 1749 | 1750 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1751 | return; 1752 | } 1753 | RETURN_TRUE; 1754 | } 1755 | /* }}} */ 1756 | 1757 | /* {{{ proto bool HaruDoc::setCompressionMode(int mode) 1758 | Set compression mode for the document */ 1759 | static PHP_METHOD(HaruDoc, setCompressionMode) 1760 | { 1761 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1762 | long mode; 1763 | HPDF_STATUS status; 1764 | 1765 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { 1766 | return; 1767 | } 1768 | 1769 | status = HPDF_SetCompressionMode(doc->h, (HPDF_UINT)mode); 1770 | 1771 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1772 | return; 1773 | } 1774 | RETURN_TRUE; 1775 | } 1776 | /* }}} */ 1777 | 1778 | /* {{{ proto bool HaruDoc::setPagesConfiguration(int page_per_pages) 1779 | Set the number of pages per set of pages object */ 1780 | static PHP_METHOD(HaruDoc, setPagesConfiguration) 1781 | { 1782 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1783 | long page_per_pages; 1784 | HPDF_STATUS status; 1785 | 1786 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &page_per_pages) == FAILURE) { 1787 | return; 1788 | } 1789 | 1790 | status = HPDF_SetPagesConfiguration(doc->h, (HPDF_UINT)page_per_pages); 1791 | 1792 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1793 | return; 1794 | } 1795 | RETURN_TRUE; 1796 | } 1797 | /* }}} */ 1798 | 1799 | /* {{{ proto object HaruDoc::setOpenAction(object destination) 1800 | Define which page is shown when the document is opened */ 1801 | static PHP_METHOD(HaruDoc, setOpenAction) 1802 | { 1803 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1804 | php_harudestination *dest; 1805 | zval *destination; 1806 | HPDF_STATUS status; 1807 | 1808 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &destination, ce_harudestination) == FAILURE) { 1809 | return; 1810 | } 1811 | 1812 | dest = (php_harudestination *)zend_object_store_get_object(destination TSRMLS_CC); 1813 | 1814 | status = HPDF_SetOpenAction(doc->h, dest->h); 1815 | 1816 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1817 | return; 1818 | } 1819 | RETURN_TRUE; 1820 | } 1821 | /* }}} */ 1822 | 1823 | /* {{{ proto object HaruDoc::createOutline(string title[, object parent_outline[, object encoder ] ]) 1824 | Create a HaruOutline instance */ 1825 | static PHP_METHOD(HaruDoc, createOutline) 1826 | { 1827 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1828 | php_haruoutline *o, *o_parent; 1829 | php_haruencoder *e; 1830 | HPDF_Outline outline, out_parent = NULL; 1831 | HPDF_Encoder enc = NULL; 1832 | zval *encoder = NULL, *parent = NULL; 1833 | char *title; 1834 | int title_len; 1835 | 1836 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|O!O!", &title, &title_len, &parent, ce_haruoutline, &encoder, ce_haruencoder) == FAILURE) { 1837 | return; 1838 | } 1839 | 1840 | if (parent) { 1841 | o_parent = (php_haruoutline *)zend_object_store_get_object(parent TSRMLS_CC); 1842 | out_parent = o_parent->h; 1843 | } 1844 | 1845 | if (encoder) { 1846 | e = (php_haruencoder *)zend_object_store_get_object(encoder TSRMLS_CC); 1847 | enc = e->h; 1848 | } 1849 | 1850 | outline = HPDF_CreateOutline(doc->h, out_parent, (const char *)title, enc); 1851 | 1852 | if (php_haru_check_doc_error(doc TSRMLS_CC)) { 1853 | return; 1854 | } 1855 | PHP_HARU_NULL_CHECK(outline, "Cannot create HaruOutline handle"); 1856 | 1857 | object_init_ex(return_value, ce_haruoutline); 1858 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 1859 | 1860 | o = (php_haruoutline *)zend_object_store_get_object(return_value TSRMLS_CC); 1861 | 1862 | o->doc = *getThis(); 1863 | o->h = outline; 1864 | 1865 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 1866 | } 1867 | /* }}} */ 1868 | 1869 | /* {{{ proto bool HaruDoc::addPageLabel(int first_page, int style, int first_num[, string prefix ]) 1870 | Set the numbering style for the specified range of the pages */ 1871 | static PHP_METHOD(HaruDoc, addPageLabel) 1872 | { 1873 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1874 | long first_page, style, first_num; 1875 | char *prefix = NULL; 1876 | int prefix_len = 0; 1877 | HPDF_STATUS status; 1878 | 1879 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|s", &first_page, &style, &first_num, &prefix, &prefix_len) == FAILURE) { 1880 | return; 1881 | } 1882 | 1883 | switch (style) { 1884 | case HPDF_PAGE_NUM_STYLE_DECIMAL: 1885 | case HPDF_PAGE_NUM_STYLE_UPPER_ROMAN: 1886 | case HPDF_PAGE_NUM_STYLE_LOWER_ROMAN: 1887 | case HPDF_PAGE_NUM_STYLE_UPPER_LETTERS: 1888 | case HPDF_PAGE_NUM_STYLE_LOWER_LETTERS: 1889 | /* only these are valid */ 1890 | break; 1891 | default: 1892 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid numbering mode"); 1893 | return; 1894 | } 1895 | 1896 | if (!prefix_len) { 1897 | prefix = NULL; 1898 | } 1899 | 1900 | status = HPDF_AddPageLabel(doc->h, (HPDF_UINT)first_page, (HPDF_PageNumStyle)style, (HPDF_UINT)first_num, (const char *)prefix); 1901 | 1902 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1903 | return; 1904 | } 1905 | RETURN_TRUE; 1906 | } 1907 | /* }}} */ 1908 | 1909 | /* {{{ proto bool HaruDoc::useJPFonts() 1910 | Enable builtin Japanese fonts */ 1911 | static PHP_METHOD(HaruDoc, useJPFonts) 1912 | { 1913 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1914 | HPDF_STATUS status; 1915 | 1916 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1917 | return; 1918 | } 1919 | 1920 | status = HPDF_UseJPFonts(doc->h); 1921 | 1922 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1923 | return; 1924 | } 1925 | RETURN_TRUE; 1926 | } 1927 | /* }}} */ 1928 | 1929 | /* {{{ proto bool HaruDoc::useJPEncodings() 1930 | Enable Japanese encodings */ 1931 | static PHP_METHOD(HaruDoc, useJPEncodings) 1932 | { 1933 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1934 | HPDF_STATUS status; 1935 | 1936 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1937 | return; 1938 | } 1939 | 1940 | status = HPDF_UseJPEncodings(doc->h); 1941 | 1942 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1943 | return; 1944 | } 1945 | RETURN_TRUE; 1946 | } 1947 | /* }}} */ 1948 | 1949 | /* {{{ proto bool HaruDoc::useKRFonts() 1950 | Enable builtin Korean fonts */ 1951 | static PHP_METHOD(HaruDoc, useKRFonts) 1952 | { 1953 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1954 | HPDF_STATUS status; 1955 | 1956 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1957 | return; 1958 | } 1959 | 1960 | status = HPDF_UseKRFonts(doc->h); 1961 | 1962 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1963 | return; 1964 | } 1965 | RETURN_TRUE; 1966 | } 1967 | /* }}} */ 1968 | 1969 | /* {{{ proto bool HaruDoc::useKREncodings() 1970 | Enable Korean encodings */ 1971 | static PHP_METHOD(HaruDoc, useKREncodings) 1972 | { 1973 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1974 | HPDF_STATUS status; 1975 | 1976 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1977 | return; 1978 | } 1979 | 1980 | status = HPDF_UseKREncodings(doc->h); 1981 | 1982 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 1983 | return; 1984 | } 1985 | RETURN_TRUE; 1986 | } 1987 | /* }}} */ 1988 | 1989 | /* {{{ proto bool HaruDoc::useCNSFonts() 1990 | Enable builtin Chinese simplified fonts */ 1991 | static PHP_METHOD(HaruDoc, useCNSFonts) 1992 | { 1993 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 1994 | HPDF_STATUS status; 1995 | 1996 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 1997 | return; 1998 | } 1999 | 2000 | status = HPDF_UseCNSFonts(doc->h); 2001 | 2002 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2003 | return; 2004 | } 2005 | RETURN_TRUE; 2006 | } 2007 | /* }}} */ 2008 | 2009 | /* {{{ proto bool HaruDoc::useCNSEncodings() 2010 | Enable Chinese simplified encodings */ 2011 | static PHP_METHOD(HaruDoc, useCNSEncodings) 2012 | { 2013 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 2014 | HPDF_STATUS status; 2015 | 2016 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2017 | return; 2018 | } 2019 | 2020 | status = HPDF_UseCNSEncodings(doc->h); 2021 | 2022 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2023 | return; 2024 | } 2025 | RETURN_TRUE; 2026 | } 2027 | /* }}} */ 2028 | 2029 | /* {{{ proto bool HaruDoc::useCNTFonts() 2030 | Enable builtin Chinese traditional fonts */ 2031 | static PHP_METHOD(HaruDoc, useCNTFonts) 2032 | { 2033 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 2034 | HPDF_STATUS status; 2035 | 2036 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2037 | return; 2038 | } 2039 | 2040 | status = HPDF_UseCNTFonts(doc->h); 2041 | 2042 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2043 | return; 2044 | } 2045 | RETURN_TRUE; 2046 | } 2047 | /* }}} */ 2048 | 2049 | /* {{{ proto bool HaruDoc::useCNTEncodings() 2050 | Enable Chinese traditional encodings */ 2051 | static PHP_METHOD(HaruDoc, useCNTEncodings) 2052 | { 2053 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 2054 | HPDF_STATUS status; 2055 | 2056 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2057 | return; 2058 | } 2059 | 2060 | status = HPDF_UseCNTEncodings(doc->h); 2061 | 2062 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2063 | return; 2064 | } 2065 | RETURN_TRUE; 2066 | } 2067 | /* }}} */ 2068 | 2069 | /* {{{ proto bool HaruDoc::useUTFEncodings() 2070 | Enable Unicode encodings */ 2071 | static PHP_METHOD(HaruDoc, useUTFEncodings) 2072 | { 2073 | php_harudoc *doc = (php_harudoc *)zend_object_store_get_object(getThis() TSRMLS_CC); 2074 | HPDF_STATUS status; 2075 | 2076 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2077 | return; 2078 | } 2079 | 2080 | status = HPDF_UseUTFEncodings(doc->h); 2081 | 2082 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2083 | return; 2084 | } 2085 | RETURN_TRUE; 2086 | } 2087 | 2088 | /* }}} */ 2089 | 2090 | /* HaruPage methods {{{ */ 2091 | 2092 | /* {{{ proto bool HaruPage::__construct() 2093 | Dummy constructor */ 2094 | static PHP_METHOD(HaruPage, __construct) 2095 | { 2096 | return; 2097 | } 2098 | /* }}} */ 2099 | 2100 | /* {{{ proto bool HaruPage::drawImage(object image, double x, double y, double width, double height) 2101 | Show image at the page */ 2102 | static PHP_METHOD(HaruPage, drawImage) 2103 | { 2104 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2105 | php_haruimage *image; 2106 | zval *z_image; 2107 | double x, y, width, height; 2108 | HPDF_STATUS status; 2109 | 2110 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Odddd", &z_image, ce_haruimage, &x, &y, &width, &height) == FAILURE) { 2111 | return; 2112 | } 2113 | 2114 | image = (php_haruimage *)zend_object_store_get_object(z_image TSRMLS_CC); 2115 | 2116 | status = HPDF_Page_DrawImage(page->h, image->h, (HPDF_REAL)x, (HPDF_REAL)y, (HPDF_REAL)width, (HPDF_REAL)height); 2117 | 2118 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2119 | return; 2120 | } 2121 | RETURN_TRUE; 2122 | } 2123 | /* }}} */ 2124 | 2125 | /* {{{ proto bool HaruPage::setLineWidth(double width) 2126 | Set line width for the page */ 2127 | static PHP_METHOD(HaruPage, setLineWidth) 2128 | { 2129 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2130 | HPDF_STATUS status; 2131 | double width; 2132 | 2133 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &width) == FAILURE) { 2134 | return; 2135 | } 2136 | 2137 | status = HPDF_Page_SetLineWidth(page->h, (HPDF_REAL)width); 2138 | 2139 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2140 | return; 2141 | } 2142 | RETURN_TRUE; 2143 | } 2144 | /* }}} */ 2145 | 2146 | /* {{{ proto bool HaruPage::setLineCap(int cap) 2147 | Set the shape to be used at the ends of line */ 2148 | static PHP_METHOD(HaruPage, setLineCap) 2149 | { 2150 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2151 | HPDF_STATUS status; 2152 | long cap; 2153 | 2154 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &cap) == FAILURE) { 2155 | return; 2156 | } 2157 | 2158 | switch (cap) { 2159 | case HPDF_BUTT_END: 2160 | case HPDF_ROUND_END: 2161 | case HPDF_PROJECTING_SCUARE_END: 2162 | /* only these are valid */ 2163 | break; 2164 | default: 2165 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid line cap value"); 2166 | return; 2167 | } 2168 | 2169 | status = HPDF_Page_SetLineCap(page->h, (HPDF_LineCap)cap); 2170 | 2171 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2172 | return; 2173 | } 2174 | RETURN_TRUE; 2175 | } 2176 | /* }}} */ 2177 | 2178 | /* {{{ proto bool HaruPage::setLineJoin(int join) 2179 | Set line join style for the page */ 2180 | static PHP_METHOD(HaruPage, setLineJoin) 2181 | { 2182 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2183 | HPDF_STATUS status; 2184 | long join; 2185 | 2186 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &join) == FAILURE) { 2187 | return; 2188 | } 2189 | 2190 | switch (join) { 2191 | case HPDF_MITER_JOIN: 2192 | case HPDF_ROUND_JOIN: 2193 | case HPDF_BEVEL_JOIN: 2194 | /* only these are valid */ 2195 | break; 2196 | default: 2197 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid line cap value"); 2198 | return; 2199 | } 2200 | 2201 | status = HPDF_Page_SetLineJoin(page->h, (HPDF_LineJoin)join); 2202 | 2203 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2204 | return; 2205 | } 2206 | RETURN_TRUE; 2207 | } 2208 | /* }}} */ 2209 | 2210 | /* {{{ proto bool HaruPage::setMiterLimit(double limit) 2211 | Set the current value of the miter limit of the page */ 2212 | static PHP_METHOD(HaruPage, setMiterLimit) 2213 | { 2214 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2215 | HPDF_STATUS status; 2216 | double limit; 2217 | 2218 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &limit) == FAILURE) { 2219 | return; 2220 | } 2221 | 2222 | status = HPDF_Page_SetMiterLimit(page->h, (HPDF_REAL)limit); 2223 | 2224 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2225 | return; 2226 | } 2227 | RETURN_TRUE; 2228 | } 2229 | /* }}} */ 2230 | 2231 | /* {{{ proto bool HaruPage::setDash(array pattern, int phase) 2232 | Set the dash pattern for the page */ 2233 | static PHP_METHOD(HaruPage, setDash) 2234 | { 2235 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2236 | HPDF_STATUS status; 2237 | HPDF_UINT16 *pat = NULL; 2238 | zval *pattern; 2239 | int pat_num = 0; 2240 | long phase; 2241 | 2242 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!l", &pattern, &phase) == FAILURE) { 2243 | return; 2244 | } 2245 | 2246 | if (pattern) { 2247 | pat_num = zend_hash_num_elements(Z_ARRVAL_P(pattern)); 2248 | if (pat_num > 8) { 2249 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "first parameter is expected to be array with at most 8 elements, %d given", pat_num); 2250 | return; 2251 | } 2252 | } 2253 | 2254 | if (phase > pat_num) { 2255 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "phase parameter cannot be greater than the number of elements in the pattern"); 2256 | return; 2257 | } 2258 | 2259 | if (pat_num > 0) { 2260 | zval **element, tmp, tmp_element; 2261 | int i = 0; 2262 | 2263 | pat = emalloc(pat_num * sizeof(HPDF_UINT16)); /* safe */ 2264 | 2265 | for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(pattern)); 2266 | zend_hash_get_current_data(Z_ARRVAL_P(pattern), (void **) &element) == SUCCESS; 2267 | zend_hash_move_forward(Z_ARRVAL_P(pattern))) { 2268 | if (Z_TYPE_PP(element) != IS_LONG) { 2269 | tmp = **element; 2270 | zval_copy_ctor(&tmp); 2271 | INIT_PZVAL(&tmp); 2272 | convert_to_long(&tmp); 2273 | tmp_element = tmp; 2274 | } else { 2275 | tmp_element = **element; 2276 | } 2277 | 2278 | pat[i++] = Z_LVAL(tmp_element); 2279 | 2280 | if (Z_TYPE_PP(element) != IS_LONG) { 2281 | zval_dtor(&tmp); 2282 | } 2283 | } 2284 | } 2285 | 2286 | status = HPDF_Page_SetDash(page->h, (const HPDF_UINT16 *)pat, (HPDF_UINT)pat_num, (HPDF_UINT)phase); 2287 | 2288 | if (pat) { 2289 | efree(pat); 2290 | } 2291 | 2292 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2293 | return; 2294 | } 2295 | RETURN_TRUE; 2296 | } 2297 | /* }}} */ 2298 | 2299 | /* {{{ proto bool HaruPage::setFlatness(double flatness) 2300 | Set flatness for the page */ 2301 | static PHP_METHOD(HaruPage, setFlatness) 2302 | { 2303 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2304 | HPDF_STATUS status; 2305 | double flatness; 2306 | 2307 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &flatness) == FAILURE) { 2308 | return; 2309 | } 2310 | 2311 | status = HPDF_Page_SetFlat(page->h, (HPDF_REAL)flatness); 2312 | 2313 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2314 | return; 2315 | } 2316 | RETURN_TRUE; 2317 | } 2318 | /* }}} */ 2319 | 2320 | /* {{{ proto bool HaruPage::setFontAndSize(object font, double size) 2321 | Set font and fontsize for the page */ 2322 | static PHP_METHOD(HaruPage, setFontAndSize) 2323 | { 2324 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2325 | php_harufont *font; 2326 | HPDF_STATUS status; 2327 | double size; 2328 | zval *z_font; 2329 | 2330 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Od", &z_font, ce_harufont, &size) == FAILURE) { 2331 | return; 2332 | } 2333 | 2334 | font = (php_harufont *)zend_object_store_get_object(z_font TSRMLS_CC); 2335 | 2336 | status = HPDF_Page_SetFontAndSize(page->h, font->h, (HPDF_REAL)size); 2337 | 2338 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2339 | return; 2340 | } 2341 | RETURN_TRUE; 2342 | } 2343 | /* }}} */ 2344 | 2345 | /* {{{ proto bool HaruPage::setCharSpace(double char_space) 2346 | Set character spacing for the page */ 2347 | static PHP_METHOD(HaruPage, setCharSpace) 2348 | { 2349 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2350 | HPDF_STATUS status; 2351 | double char_space; 2352 | 2353 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &char_space) == FAILURE) { 2354 | return; 2355 | } 2356 | 2357 | status = HPDF_Page_SetCharSpace(page->h, (HPDF_REAL)char_space); 2358 | 2359 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2360 | return; 2361 | } 2362 | RETURN_TRUE; 2363 | } 2364 | /* }}} */ 2365 | 2366 | /* {{{ proto bool HaruPage::setWordSpace(double word_space) 2367 | Set word spacing for the page */ 2368 | static PHP_METHOD(HaruPage, setWordSpace) 2369 | { 2370 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2371 | HPDF_STATUS status; 2372 | double word_space; 2373 | 2374 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &word_space) == FAILURE) { 2375 | return; 2376 | } 2377 | 2378 | status = HPDF_Page_SetWordSpace(page->h, (HPDF_REAL)word_space); 2379 | 2380 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2381 | return; 2382 | } 2383 | RETURN_TRUE; 2384 | } 2385 | /* }}} */ 2386 | 2387 | /* {{{ proto bool HaruPage::setHorizontalScaling(double scaling) 2388 | Set horizontal scaling for the page */ 2389 | static PHP_METHOD(HaruPage, setHorizontalScaling) 2390 | { 2391 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2392 | HPDF_STATUS status; 2393 | double scaling; 2394 | 2395 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &scaling) == FAILURE) { 2396 | return; 2397 | } 2398 | 2399 | status = HPDF_Page_SetHorizontalScalling(page->h, (HPDF_REAL)scaling); 2400 | 2401 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2402 | return; 2403 | } 2404 | RETURN_TRUE; 2405 | } 2406 | /* }}} */ 2407 | 2408 | /* {{{ proto bool HaruPage::setTextLeading(double text_leading) 2409 | Set text leading (line spacing) for the page */ 2410 | static PHP_METHOD(HaruPage, setTextLeading) 2411 | { 2412 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2413 | HPDF_STATUS status; 2414 | double text_leading; 2415 | 2416 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &text_leading) == FAILURE) { 2417 | return; 2418 | } 2419 | 2420 | status = HPDF_Page_SetTextLeading(page->h, (HPDF_REAL)text_leading); 2421 | 2422 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2423 | return; 2424 | } 2425 | RETURN_TRUE; 2426 | } 2427 | /* }}} */ 2428 | 2429 | /* {{{ proto bool HaruPage::setTextRenderingMode(int mode) 2430 | Set text rendering mode for the page */ 2431 | static PHP_METHOD(HaruPage, setTextRenderingMode) 2432 | { 2433 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2434 | HPDF_STATUS status; 2435 | long mode; 2436 | 2437 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { 2438 | return; 2439 | } 2440 | 2441 | switch (mode) { 2442 | case HPDF_FILL: 2443 | case HPDF_STROKE: 2444 | case HPDF_FILL_THEN_STROKE: 2445 | case HPDF_INVISIBLE: 2446 | case HPDF_FILL_CLIPPING: 2447 | case HPDF_STROKE_CLIPPING: 2448 | case HPDF_FILL_STROKE_CLIPPING: 2449 | case HPDF_CLIPPING: 2450 | /* only these are valid */ 2451 | break; 2452 | default: 2453 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid line cap value"); 2454 | return; 2455 | } 2456 | 2457 | status = HPDF_Page_SetTextRenderingMode(page->h, (HPDF_TextRenderingMode)mode); 2458 | 2459 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2460 | return; 2461 | } 2462 | RETURN_TRUE; 2463 | } 2464 | /* }}} */ 2465 | 2466 | /* {{{ proto bool HaruPage::setTextRise(double rise) 2467 | */ 2468 | static PHP_METHOD(HaruPage, setTextRise) 2469 | { 2470 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2471 | HPDF_STATUS status; 2472 | double rise; 2473 | 2474 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &rise) == FAILURE) { 2475 | return; 2476 | } 2477 | 2478 | status = HPDF_Page_SetTextRise(page->h, (HPDF_REAL)rise); 2479 | 2480 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2481 | return; 2482 | } 2483 | RETURN_TRUE; 2484 | } 2485 | /* }}} */ 2486 | 2487 | /* {{{ proto bool HaruPage::setGrayFill(double value) 2488 | Set filling color for the page */ 2489 | static PHP_METHOD(HaruPage, setGrayFill) 2490 | { 2491 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2492 | HPDF_STATUS status; 2493 | double val; 2494 | 2495 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &val) == FAILURE) { 2496 | return; 2497 | } 2498 | 2499 | status = HPDF_Page_SetGrayFill(page->h, (HPDF_REAL)val); 2500 | 2501 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2502 | return; 2503 | } 2504 | RETURN_TRUE; 2505 | } 2506 | /* }}} */ 2507 | 2508 | /* {{{ proto bool HaruPage::setGrayStroke(double value) 2509 | Sets stroking color for the page */ 2510 | static PHP_METHOD(HaruPage, setGrayStroke) 2511 | { 2512 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2513 | HPDF_STATUS status; 2514 | double val; 2515 | 2516 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &val) == FAILURE) { 2517 | return; 2518 | } 2519 | 2520 | status = HPDF_Page_SetGrayStroke(page->h, (HPDF_REAL)val); 2521 | 2522 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2523 | return; 2524 | } 2525 | RETURN_TRUE; 2526 | } 2527 | /* }}} */ 2528 | 2529 | /* {{{ proto bool HaruPage::setRGBFill(double r, double g, double b) 2530 | Set filling color for the page */ 2531 | static PHP_METHOD(HaruPage, setRGBFill) 2532 | { 2533 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2534 | HPDF_STATUS status; 2535 | double r, g, b; 2536 | 2537 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &r, &g, &b) == FAILURE) { 2538 | return; 2539 | } 2540 | 2541 | status = HPDF_Page_SetRGBFill(page->h, (HPDF_REAL)r, (HPDF_REAL)g, (HPDF_REAL)b); 2542 | 2543 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2544 | return; 2545 | } 2546 | RETURN_TRUE; 2547 | } 2548 | /* }}} */ 2549 | 2550 | /* {{{ proto bool HaruPage::setRGBStroke(double r, double g, double b) 2551 | Set stroking color for the page */ 2552 | static PHP_METHOD(HaruPage, setRGBStroke) 2553 | { 2554 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2555 | HPDF_STATUS status; 2556 | double r, g, b; 2557 | 2558 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &r, &g, &b) == FAILURE) { 2559 | return; 2560 | } 2561 | 2562 | status = HPDF_Page_SetRGBStroke(page->h, (HPDF_REAL)r, (HPDF_REAL)g, (HPDF_REAL)b); 2563 | 2564 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2565 | return; 2566 | } 2567 | RETURN_TRUE; 2568 | } 2569 | /* }}} */ 2570 | 2571 | /* {{{ proto bool HaruPage::setCMYKFill(double c, double m, double y, double k) 2572 | Set filling color for the page */ 2573 | static PHP_METHOD(HaruPage, setCMYKFill) 2574 | { 2575 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2576 | HPDF_STATUS status; 2577 | double c, m, y, k; 2578 | 2579 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &c, &m, &y, &k) == FAILURE) { 2580 | return; 2581 | } 2582 | 2583 | status = HPDF_Page_SetCMYKFill(page->h, (HPDF_REAL)c, (HPDF_REAL)m, (HPDF_REAL)y, (HPDF_REAL)k); 2584 | 2585 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2586 | return; 2587 | } 2588 | RETURN_TRUE; 2589 | } 2590 | /* }}} */ 2591 | 2592 | /* {{{ proto bool HaruPage::setCMYKStroke(double c, double m, double y, double k) 2593 | Set stroking color for the page */ 2594 | static PHP_METHOD(HaruPage, setCMYKStroke) 2595 | { 2596 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2597 | HPDF_STATUS status; 2598 | double c, m, y, k; 2599 | 2600 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &c, &m, &y, &k) == FAILURE) { 2601 | return; 2602 | } 2603 | 2604 | status = HPDF_Page_SetCMYKStroke(page->h, (HPDF_REAL)c, (HPDF_REAL)m, (HPDF_REAL)y, (HPDF_REAL)k); 2605 | 2606 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2607 | return; 2608 | } 2609 | RETURN_TRUE; 2610 | } 2611 | /* }}} */ 2612 | 2613 | /* {{{ proto bool HaruPage::Concat(double a, double b, double c, double d, double x, double y) 2614 | Concatenate current transformation matrix of the page and the specified matrix */ 2615 | static PHP_METHOD(HaruPage, Concat) 2616 | { 2617 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2618 | HPDF_STATUS status; 2619 | double a, b, c, d, x, y; 2620 | 2621 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) { 2622 | return; 2623 | } 2624 | 2625 | status = HPDF_Page_Concat(page->h, (HPDF_REAL)a, (HPDF_REAL)b, (HPDF_REAL)c, (HPDF_REAL)d, (HPDF_REAL)x, (HPDF_REAL)y); 2626 | 2627 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2628 | return; 2629 | } 2630 | RETURN_TRUE; 2631 | } 2632 | /* }}} */ 2633 | 2634 | /* {{{ proto array HaruPage::getTransMatrix() 2635 | Get the current transformation matrix of the page */ 2636 | static PHP_METHOD(HaruPage, getTransMatrix) 2637 | { 2638 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2639 | HPDF_TransMatrix matrix; 2640 | 2641 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2642 | return; 2643 | } 2644 | 2645 | matrix = HPDF_Page_GetTransMatrix(page->h); 2646 | 2647 | array_init(return_value); 2648 | add_assoc_double_ex(return_value, "a", sizeof("a"), matrix.a); 2649 | add_assoc_double_ex(return_value, "b", sizeof("b"), matrix.b); 2650 | add_assoc_double_ex(return_value, "c", sizeof("c"), matrix.c); 2651 | add_assoc_double_ex(return_value, "d", sizeof("d"), matrix.d); 2652 | add_assoc_double_ex(return_value, "x", sizeof("x"), matrix.x); 2653 | add_assoc_double_ex(return_value, "y", sizeof("y"), matrix.y); 2654 | } 2655 | /* }}} */ 2656 | 2657 | /* {{{ proto bool HaruPage::setTextMatrix(double a, double b, double c, double d, double x, double y) 2658 | Set the current text transformation matrix of the page */ 2659 | static PHP_METHOD(HaruPage, setTextMatrix) 2660 | { 2661 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2662 | HPDF_STATUS status; 2663 | double a, b, c, d, x, y; 2664 | 2665 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) { 2666 | return; 2667 | } 2668 | 2669 | status = HPDF_Page_SetTextMatrix(page->h, (HPDF_REAL)a, (HPDF_REAL)b, (HPDF_REAL)c, (HPDF_REAL)d, (HPDF_REAL)x, (HPDF_REAL)y); 2670 | 2671 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2672 | /* knock-knock, follow the white rabbit */ 2673 | return; 2674 | } 2675 | RETURN_TRUE; 2676 | } 2677 | /* }}} */ 2678 | 2679 | /* {{{ proto array HaruPage::getTextMatrix() 2680 | Get the current text transformation matrix of the page */ 2681 | static PHP_METHOD(HaruPage, getTextMatrix) 2682 | { 2683 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2684 | HPDF_TransMatrix matrix; 2685 | 2686 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2687 | return; 2688 | } 2689 | 2690 | matrix = HPDF_Page_GetTextMatrix(page->h); 2691 | 2692 | array_init(return_value); 2693 | add_assoc_double_ex(return_value, "a", sizeof("a"), matrix.a); 2694 | add_assoc_double_ex(return_value, "b", sizeof("b"), matrix.b); 2695 | add_assoc_double_ex(return_value, "c", sizeof("c"), matrix.c); 2696 | add_assoc_double_ex(return_value, "d", sizeof("d"), matrix.d); 2697 | add_assoc_double_ex(return_value, "x", sizeof("x"), matrix.x); 2698 | add_assoc_double_ex(return_value, "y", sizeof("y"), matrix.y); 2699 | } 2700 | /* }}} */ 2701 | 2702 | /* {{{ proto bool HaruPage::moveTo(double x, double y) 2703 | Set start point for new drawing path */ 2704 | static PHP_METHOD(HaruPage, moveTo) 2705 | { 2706 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2707 | HPDF_STATUS status; 2708 | double x, y; 2709 | 2710 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { 2711 | return; 2712 | } 2713 | 2714 | status = HPDF_Page_MoveTo(page->h, (HPDF_REAL)x, (HPDF_REAL)y); 2715 | 2716 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2717 | return; 2718 | } 2719 | RETURN_TRUE; 2720 | } 2721 | /* }}} */ 2722 | 2723 | /* {{{ proto bool HaruPage::stroke([bool close_path]) 2724 | Paint current path */ 2725 | static PHP_METHOD(HaruPage, stroke) 2726 | { 2727 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2728 | HPDF_STATUS status; 2729 | zend_bool close_path = 0; 2730 | 2731 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &close_path) == FAILURE) { 2732 | return; 2733 | } 2734 | 2735 | if (!close_path) { 2736 | status = HPDF_Page_Stroke(page->h); 2737 | } else { 2738 | status = HPDF_Page_ClosePathStroke(page->h); 2739 | } 2740 | 2741 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2742 | return; 2743 | } 2744 | RETURN_TRUE; 2745 | } 2746 | /* }}} */ 2747 | 2748 | /* {{{ proto bool HaruPage::fill() 2749 | Fill current path using nonzero winding number rule */ 2750 | static PHP_METHOD(HaruPage, fill) 2751 | { 2752 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2753 | HPDF_STATUS status; 2754 | 2755 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2756 | return; 2757 | } 2758 | 2759 | status = HPDF_Page_Fill(page->h); 2760 | 2761 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2762 | return; 2763 | } 2764 | RETURN_TRUE; 2765 | } 2766 | /* }}} */ 2767 | 2768 | /* {{{ proto bool HaruPage::eofill() 2769 | Fill current path using even-odd rule */ 2770 | static PHP_METHOD(HaruPage, eofill) 2771 | { 2772 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2773 | HPDF_STATUS status; 2774 | 2775 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2776 | return; 2777 | } 2778 | 2779 | status = HPDF_Page_Eofill(page->h); 2780 | 2781 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2782 | return; 2783 | } 2784 | RETURN_TRUE; 2785 | } 2786 | /* }}} */ 2787 | 2788 | /* {{{ proto bool HaruPage::fillStroke([bool close_path]) 2789 | Fill current path using nonzero winding number rule, then paint the path */ 2790 | static PHP_METHOD(HaruPage, fillStroke) 2791 | { 2792 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2793 | HPDF_STATUS status; 2794 | zend_bool close_path = 0; 2795 | 2796 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &close_path) == FAILURE) { 2797 | return; 2798 | } 2799 | 2800 | if (!close_path) { 2801 | status = HPDF_Page_FillStroke(page->h); 2802 | } else { 2803 | status = HPDF_Page_ClosePathFillStroke(page->h); 2804 | } 2805 | 2806 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2807 | return; 2808 | } 2809 | RETURN_TRUE; 2810 | } 2811 | /* }}} */ 2812 | 2813 | /* {{{ proto bool HaruPage::eoFillStroke([bool close_path]) 2814 | Fill current path using even-odd rule, then paint the path */ 2815 | static PHP_METHOD(HaruPage, eoFillStroke) 2816 | { 2817 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2818 | HPDF_STATUS status; 2819 | zend_bool close_path = 0; 2820 | 2821 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &close_path) == FAILURE) { 2822 | return; 2823 | } 2824 | 2825 | if (!close_path) { 2826 | status = HPDF_Page_EofillStroke(page->h); 2827 | } else { 2828 | status = HPDF_Page_ClosePathEofillStroke(page->h); 2829 | } 2830 | 2831 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2832 | return; 2833 | } 2834 | RETURN_TRUE; 2835 | } 2836 | /* }}} */ 2837 | 2838 | /* {{{ proto bool HaruPage::closePath() 2839 | Append a straight line from the current point to the start point of the path */ 2840 | static PHP_METHOD(HaruPage, closePath) 2841 | { 2842 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2843 | HPDF_STATUS status; 2844 | 2845 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2846 | return; 2847 | } 2848 | 2849 | status = HPDF_Page_ClosePath(page->h); 2850 | 2851 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2852 | return; 2853 | } 2854 | RETURN_TRUE; 2855 | } 2856 | /* }}} */ 2857 | 2858 | /* {{{ proto bool HaruPage::endPath() 2859 | End current path object without filling and painting operation */ 2860 | static PHP_METHOD(HaruPage, endPath) 2861 | { 2862 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2863 | HPDF_STATUS status; 2864 | 2865 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 2866 | return; 2867 | } 2868 | 2869 | status = HPDF_Page_EndPath(page->h); 2870 | 2871 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2872 | return; 2873 | } 2874 | RETURN_TRUE; 2875 | } 2876 | /* }}} */ 2877 | 2878 | /* {{{ proto bool HaruPage::lineTo(double x, double y) 2879 | Append a line from the current point to the specified point to the current path */ 2880 | static PHP_METHOD(HaruPage, lineTo) 2881 | { 2882 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2883 | HPDF_STATUS status; 2884 | double x, y; 2885 | 2886 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { 2887 | return; 2888 | } 2889 | 2890 | status = HPDF_Page_LineTo(page->h, (HPDF_REAL)x, (HPDF_REAL)y); 2891 | 2892 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2893 | return; 2894 | } 2895 | RETURN_TRUE; 2896 | } 2897 | /* }}} */ 2898 | 2899 | /* {{{ proto bool HaruPage::curveTo(double x1, double y1, double x2, double y2, double x3, double y3) 2900 | Append a Bezier curve to the current path */ 2901 | static PHP_METHOD(HaruPage, curveTo) 2902 | { 2903 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2904 | HPDF_STATUS status; 2905 | double x1, x2, x3, y1, y2, y3; 2906 | 2907 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &x1, &y1, &x2, &y2, &x3, &y3) == FAILURE) { 2908 | return; 2909 | } 2910 | 2911 | status = HPDF_Page_CurveTo(page->h, (HPDF_REAL)x1, (HPDF_REAL)y1, (HPDF_REAL)x2, (HPDF_REAL)y2, (HPDF_REAL)x3, (HPDF_REAL)y3); 2912 | 2913 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2914 | return; 2915 | } 2916 | RETURN_TRUE; 2917 | } 2918 | /* }}} */ 2919 | 2920 | /* {{{ proto bool HaruPage::curveTo2(double x2, double y2, double x3, double y3) 2921 | Append a Bezier curve to the current path */ 2922 | static PHP_METHOD(HaruPage, curveTo2) 2923 | { 2924 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2925 | HPDF_STATUS status; 2926 | double x2, x3, y2, y3; 2927 | 2928 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &x2, &y2, &x3, &y3) == FAILURE) { 2929 | return; 2930 | } 2931 | 2932 | status = HPDF_Page_CurveTo2(page->h, (HPDF_REAL)x2, (HPDF_REAL)y2, (HPDF_REAL)x3, (HPDF_REAL)y3); 2933 | 2934 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2935 | return; 2936 | } 2937 | RETURN_TRUE; 2938 | } 2939 | /* }}} */ 2940 | 2941 | /* {{{ proto bool HaruPage::curveTo3(double x1, double y1, double x3, double y3) 2942 | Append a Bezier curve to the current path */ 2943 | static PHP_METHOD(HaruPage, curveTo3) 2944 | { 2945 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2946 | HPDF_STATUS status; 2947 | double x1, x3, y1, y3; 2948 | 2949 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &x1, &y1, &x3, &y3) == FAILURE) { 2950 | return; 2951 | } 2952 | 2953 | status = HPDF_Page_CurveTo3(page->h, (HPDF_REAL)x1, (HPDF_REAL)y1, (HPDF_REAL)x3, (HPDF_REAL)y3); 2954 | 2955 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2956 | return; 2957 | } 2958 | RETURN_TRUE; 2959 | } 2960 | /* }}} */ 2961 | 2962 | /* {{{ proto bool HaruPage::rectangle(double x, double y, double width, double height) 2963 | Append a rectangle to the current path */ 2964 | static PHP_METHOD(HaruPage, rectangle) 2965 | { 2966 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2967 | HPDF_STATUS status; 2968 | double x, y, width, height; 2969 | 2970 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &x, &y, &width, &height) == FAILURE) { 2971 | return; 2972 | } 2973 | 2974 | status = HPDF_Page_Rectangle(page->h, (HPDF_REAL)x, (HPDF_REAL)y, (HPDF_REAL)width, (HPDF_REAL)height); 2975 | 2976 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2977 | return; 2978 | } 2979 | RETURN_TRUE; 2980 | } 2981 | /* }}} */ 2982 | 2983 | /* {{{ proto bool HaruPage::arc(double x, double y, double ray, double ang1, double ang2) 2984 | Append an arc to the current path */ 2985 | static PHP_METHOD(HaruPage, arc) 2986 | { 2987 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 2988 | HPDF_STATUS status; 2989 | double x, y, ray, ang1, ang2; 2990 | 2991 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddddd", &x, &y, &ray, &ang1, &ang2) == FAILURE) { 2992 | return; 2993 | } 2994 | 2995 | status = HPDF_Page_Arc(page->h, (HPDF_REAL)x, (HPDF_REAL)y, (HPDF_REAL)ray, (HPDF_REAL)ang1, (HPDF_REAL)ang2); 2996 | 2997 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 2998 | return; 2999 | } 3000 | RETURN_TRUE; 3001 | } 3002 | /* }}} */ 3003 | 3004 | /* {{{ proto bool HaruPage::circle(double x, double y, double ray) 3005 | Append a circle to the current path */ 3006 | static PHP_METHOD(HaruPage, circle) 3007 | { 3008 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3009 | HPDF_STATUS status; 3010 | double x, y, ray; 3011 | 3012 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &x, &y, &ray) == FAILURE) { 3013 | return; 3014 | } 3015 | 3016 | status = HPDF_Page_Circle(page->h, (HPDF_REAL)x, (HPDF_REAL)y, (HPDF_REAL)ray); 3017 | 3018 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3019 | return; 3020 | } 3021 | RETURN_TRUE; 3022 | } 3023 | /* }}} */ 3024 | 3025 | /* {{{ proto bool HaruPage::ellipse(double x, double y, double xray, double yray) 3026 | Append an ellipse to the current path */ 3027 | static PHP_METHOD(HaruPage, ellipse) 3028 | { 3029 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3030 | HPDF_STATUS status; 3031 | double x, y, xray, yray; 3032 | 3033 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &x, &y, &xray, &yray) == FAILURE) { 3034 | return; 3035 | } 3036 | 3037 | status = HPDF_Page_Ellipse(page->h, (HPDF_REAL) x, (HPDF_REAL)y, (HPDF_REAL)xray, (HPDF_REAL)yray); 3038 | 3039 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3040 | return; 3041 | } 3042 | RETURN_TRUE; 3043 | } 3044 | /* }}} */ 3045 | 3046 | /* {{{ proto bool HaruPage::showText(string text) 3047 | Print text at the current position of the page */ 3048 | static PHP_METHOD(HaruPage, showText) 3049 | { 3050 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3051 | HPDF_STATUS status; 3052 | char *text; 3053 | int text_len; 3054 | 3055 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &text, &text_len) == FAILURE) { 3056 | return; 3057 | } 3058 | 3059 | status = HPDF_Page_ShowText(page->h, (const char*)text); 3060 | 3061 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3062 | return; 3063 | } 3064 | RETURN_TRUE; 3065 | } 3066 | /* }}} */ 3067 | 3068 | /* {{{ proto bool HaruPage::showTextNextLine(string text) 3069 | Move current position to the start of the next line and print the text */ 3070 | static PHP_METHOD(HaruPage, showTextNextLine) 3071 | { 3072 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3073 | HPDF_STATUS status; 3074 | char *text; 3075 | int text_len; 3076 | double word_space = 0, char_space = 0; 3077 | 3078 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|dd", &text, &text_len, &word_space, &char_space) == FAILURE) { 3079 | return; 3080 | } 3081 | 3082 | if (ZEND_NUM_ARGS() == 1) { 3083 | status = HPDF_Page_ShowTextNextLine(page->h, (const char*)text); 3084 | } else { 3085 | status = HPDF_Page_ShowTextNextLineEx(page->h, (HPDF_REAL)word_space, (HPDF_REAL)char_space, (const char*)text); 3086 | } 3087 | 3088 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3089 | return; 3090 | } 3091 | RETURN_TRUE; 3092 | } 3093 | /* }}} */ 3094 | 3095 | /* {{{ proto bool HaruPage::textOut(double x, double y, string text) 3096 | Print the text on the specified position */ 3097 | static PHP_METHOD(HaruPage, textOut) 3098 | { 3099 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3100 | HPDF_STATUS status; 3101 | double x, y; 3102 | char *text; 3103 | int text_len; 3104 | 3105 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dds", &x, &y, &text, &text_len) == FAILURE) { 3106 | return; 3107 | } 3108 | 3109 | status = HPDF_Page_TextOut(page->h, (HPDF_REAL)x, (HPDF_REAL)y, (const char*)text); 3110 | 3111 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3112 | return; 3113 | } 3114 | RETURN_TRUE; 3115 | } 3116 | /* }}} */ 3117 | 3118 | /* {{{ proto bool HaruPage::beginText() 3119 | Begin a text object and set the current text position to (0,0) */ 3120 | static PHP_METHOD(HaruPage, beginText) 3121 | { 3122 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3123 | HPDF_STATUS status; 3124 | 3125 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3126 | return; 3127 | } 3128 | 3129 | status = HPDF_Page_BeginText(page->h); 3130 | 3131 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3132 | return; 3133 | } 3134 | RETURN_TRUE; 3135 | } 3136 | /* }}} */ 3137 | 3138 | /* {{{ proto bool HaruPage::endText() 3139 | End current text object */ 3140 | static PHP_METHOD(HaruPage, endText) 3141 | { 3142 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3143 | HPDF_STATUS status; 3144 | 3145 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3146 | return; 3147 | } 3148 | 3149 | status = HPDF_Page_EndText(page->h); 3150 | 3151 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3152 | return; 3153 | } 3154 | RETURN_TRUE; 3155 | } 3156 | /* }}} */ 3157 | 3158 | /* {{{ proto bool HaruPage::textRect(double left, double top, double right, double bottom, string text[, int align ]) 3159 | Print the text inside the specified region */ 3160 | static PHP_METHOD(HaruPage, textRect) 3161 | { 3162 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3163 | HPDF_STATUS status; 3164 | double left, top, right, bottom; 3165 | char *str; 3166 | int str_len; 3167 | long align = HPDF_TALIGN_LEFT; 3168 | 3169 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddds|l", &left, &top, &right, &bottom, &str, &str_len, &align) == FAILURE) { 3170 | return; 3171 | } 3172 | 3173 | switch(align) { 3174 | case HPDF_TALIGN_LEFT: 3175 | case HPDF_TALIGN_RIGHT: 3176 | case HPDF_TALIGN_CENTER: 3177 | case HPDF_TALIGN_JUSTIFY: 3178 | /* only these are valid */ 3179 | break; 3180 | default: 3181 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid align value"); 3182 | return; 3183 | } 3184 | 3185 | status = HPDF_Page_TextRect(page->h, (HPDF_REAL)left, (HPDF_REAL)top, (HPDF_REAL)right, (HPDF_REAL)bottom, (const char *)str, (HPDF_TextAlignment) align, NULL); 3186 | 3187 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3188 | return; 3189 | } 3190 | RETURN_TRUE; 3191 | } 3192 | /* }}} */ 3193 | 3194 | /* {{{ proto bool HaruPage::moveTextPos(double x, double y[, bool set_leading ]) 3195 | Move text position to the specified offset */ 3196 | static PHP_METHOD(HaruPage, moveTextPos) 3197 | { 3198 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3199 | HPDF_STATUS status; 3200 | double x, y; 3201 | zend_bool set_leading = 0; 3202 | 3203 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd|b", &x, &y, &set_leading) == FAILURE) { 3204 | return; 3205 | } 3206 | 3207 | if (!set_leading) { 3208 | /* default */ 3209 | status = HPDF_Page_MoveTextPos(page->h, (HPDF_REAL)x, (HPDF_REAL)y); 3210 | } else { 3211 | status = HPDF_Page_MoveTextPos2(page->h, (HPDF_REAL)x, (HPDF_REAL)y); 3212 | } 3213 | 3214 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3215 | return; 3216 | } 3217 | RETURN_TRUE; 3218 | } 3219 | /* }}} */ 3220 | 3221 | /* {{{ proto bool HaruPage::moveToNextLine() 3222 | Move text position to the start of the next line */ 3223 | static PHP_METHOD(HaruPage, moveToNextLine) 3224 | { 3225 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3226 | HPDF_STATUS status; 3227 | 3228 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3229 | return; 3230 | } 3231 | 3232 | status = HPDF_Page_MoveToNextLine(page->h); 3233 | 3234 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3235 | return; 3236 | } 3237 | RETURN_TRUE; 3238 | } 3239 | /* }}} */ 3240 | 3241 | /* {{{ proto bool HaruPage::setWidth(double width) 3242 | Set width of the page */ 3243 | static PHP_METHOD(HaruPage, setWidth) 3244 | { 3245 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3246 | HPDF_STATUS status; 3247 | double width; 3248 | 3249 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &width) == FAILURE) { 3250 | return; 3251 | } 3252 | 3253 | status = HPDF_Page_SetWidth(page->h, (HPDF_REAL)width); 3254 | 3255 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3256 | return; 3257 | } 3258 | RETURN_TRUE; 3259 | } 3260 | /* }}} */ 3261 | 3262 | /* {{{ proto bool HaruPage::setHeight(double height) 3263 | Set height of the page */ 3264 | static PHP_METHOD(HaruPage, setHeight) 3265 | { 3266 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3267 | HPDF_STATUS status; 3268 | double height; 3269 | 3270 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &height) == FAILURE) { 3271 | return; 3272 | } 3273 | 3274 | status = HPDF_Page_SetHeight(page->h, (HPDF_REAL)height); 3275 | 3276 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3277 | return; 3278 | } 3279 | RETURN_TRUE; 3280 | } 3281 | /* }}} */ 3282 | 3283 | /* {{{ proto bool HaruPage::setSize(int size, int direction) 3284 | Set size and direction of the page */ 3285 | static PHP_METHOD(HaruPage, setSize) 3286 | { 3287 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3288 | HPDF_STATUS status; 3289 | long size, direction; 3290 | 3291 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &size, &direction) == FAILURE) { 3292 | return; 3293 | } 3294 | 3295 | switch(size) { 3296 | case HPDF_PAGE_SIZE_LETTER: 3297 | case HPDF_PAGE_SIZE_LEGAL: 3298 | case HPDF_PAGE_SIZE_A3: 3299 | case HPDF_PAGE_SIZE_A4: 3300 | case HPDF_PAGE_SIZE_A5: 3301 | case HPDF_PAGE_SIZE_B4: 3302 | case HPDF_PAGE_SIZE_B5: 3303 | case HPDF_PAGE_SIZE_EXECUTIVE: 3304 | case HPDF_PAGE_SIZE_US4x6: 3305 | case HPDF_PAGE_SIZE_US4x8: 3306 | case HPDF_PAGE_SIZE_US5x7: 3307 | case HPDF_PAGE_SIZE_COMM10: 3308 | /* only these are valid */ 3309 | break; 3310 | default: 3311 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid page size value"); 3312 | return; 3313 | } 3314 | 3315 | switch(direction) { 3316 | case HPDF_PAGE_PORTRAIT: 3317 | case HPDF_PAGE_LANDSCAPE: 3318 | /* only these are valid */ 3319 | break; 3320 | default: 3321 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid page size value"); 3322 | return; 3323 | } 3324 | 3325 | status = HPDF_Page_SetSize(page->h, (HPDF_PageSizes)size, (HPDF_PageDirection)direction); 3326 | 3327 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3328 | return; 3329 | } 3330 | RETURN_TRUE; 3331 | } 3332 | /* }}} */ 3333 | 3334 | /* {{{ proto bool HaruPage::setRotate(int angle) 3335 | Set rotation angle of the page */ 3336 | static PHP_METHOD(HaruPage, setRotate) 3337 | { 3338 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3339 | HPDF_STATUS status; 3340 | long angle; 3341 | 3342 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &angle) == FAILURE) { 3343 | return; 3344 | } 3345 | 3346 | status = HPDF_Page_SetRotate(page->h, (HPDF_UINT16)angle); 3347 | 3348 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 3349 | return; 3350 | } 3351 | RETURN_TRUE; 3352 | } 3353 | /* }}} */ 3354 | 3355 | /* {{{ proto double HaruPage::getWidth() 3356 | Get width of the page */ 3357 | static PHP_METHOD(HaruPage, getWidth) 3358 | { 3359 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3360 | HPDF_REAL width; 3361 | 3362 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3363 | return; 3364 | } 3365 | 3366 | width = HPDF_Page_GetWidth(page->h); 3367 | 3368 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3369 | return; 3370 | } 3371 | RETURN_DOUBLE((double)width); 3372 | } 3373 | /* }}} */ 3374 | 3375 | /* {{{ proto double HaruPage::getHeight() 3376 | Get height of the page */ 3377 | static PHP_METHOD(HaruPage, getHeight) 3378 | { 3379 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3380 | HPDF_REAL height; 3381 | 3382 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3383 | return; 3384 | } 3385 | 3386 | height = HPDF_Page_GetHeight(page->h); 3387 | 3388 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3389 | return; 3390 | } 3391 | RETURN_DOUBLE((double)height); 3392 | } 3393 | /* }}} */ 3394 | 3395 | /* {{{ proto object HaruPage::createDestination() 3396 | Create and return new HaruDestination instance */ 3397 | static PHP_METHOD(HaruPage, createDestination) 3398 | { 3399 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3400 | php_harudestination *destination; 3401 | HPDF_Destination dest; 3402 | 3403 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3404 | return; 3405 | } 3406 | 3407 | dest = HPDF_Page_CreateDestination(page->h); 3408 | 3409 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3410 | return; 3411 | } 3412 | PHP_HARU_NULL_CHECK(dest, "Cannot create HaruDestination handle"); 3413 | 3414 | object_init_ex(return_value, ce_harudestination); 3415 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 3416 | 3417 | destination = (php_harudestination *)zend_object_store_get_object(return_value TSRMLS_CC); 3418 | 3419 | destination->page = *getThis(); 3420 | destination->h = dest; 3421 | 3422 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 3423 | } 3424 | /* }}} */ 3425 | 3426 | /* {{{ proto object HaruPage::createTextAnnotation(array rectangle, string text[, object encoder ]) 3427 | Create and return new HaruAnnotation instance */ 3428 | static PHP_METHOD(HaruPage, createTextAnnotation) 3429 | { 3430 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3431 | php_haruannotation *annotation; 3432 | php_haruencoder *enc; 3433 | HPDF_Annotation ann; 3434 | HPDF_Rect r; 3435 | HPDF_Encoder e = NULL; 3436 | zval *rect, *encoder = NULL; 3437 | char *text; 3438 | int text_len; 3439 | 3440 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "as|O", &rect, &text, &text_len, &encoder, ce_haruencoder) == FAILURE) { 3441 | return; 3442 | } 3443 | 3444 | if (zend_hash_num_elements(Z_ARRVAL_P(rect)) != 4) { 3445 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Rectangle parameter is expected to be an array with exactly 4 elements"); 3446 | return; 3447 | } 3448 | 3449 | r = php_haru_array_to_rect(rect); 3450 | 3451 | if (encoder) { 3452 | enc = (php_haruencoder *)zend_object_store_get_object(encoder TSRMLS_CC); 3453 | e = enc->h; 3454 | } 3455 | 3456 | ann = HPDF_Page_CreateTextAnnot(page->h, r, (const char *)text, e); 3457 | 3458 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3459 | return; 3460 | } 3461 | PHP_HARU_NULL_CHECK(ann, "Cannot create HaruAnnotation handle"); 3462 | 3463 | object_init_ex(return_value, ce_haruannotation); 3464 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 3465 | 3466 | annotation = (php_haruannotation *)zend_object_store_get_object(return_value TSRMLS_CC); 3467 | 3468 | annotation->page = *getThis(); 3469 | annotation->h = ann; 3470 | 3471 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 3472 | } 3473 | /* }}} */ 3474 | 3475 | /* {{{ proto object HaruPage::createLinkAnnotation(array rectangle, object destination) 3476 | Create and return new HaruAnnotation instance */ 3477 | static PHP_METHOD(HaruPage, createLinkAnnotation) 3478 | { 3479 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3480 | php_haruannotation *annotation; 3481 | php_harudestination *dest; 3482 | HPDF_Annotation ann; 3483 | HPDF_Rect r; 3484 | zval *rect, *destination; 3485 | 3486 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "aO", &rect, &destination, ce_harudestination) == FAILURE) { 3487 | return; 3488 | } 3489 | 3490 | if (zend_hash_num_elements(Z_ARRVAL_P(rect)) != 4) { 3491 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Rectangle parameter is expected to be an array with exactly 4 elements"); 3492 | return; 3493 | } 3494 | 3495 | r = php_haru_array_to_rect(rect); 3496 | 3497 | dest = (php_harudestination *)zend_object_store_get_object(destination TSRMLS_CC); 3498 | 3499 | ann = HPDF_Page_CreateLinkAnnot(page->h, r, dest->h); 3500 | 3501 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3502 | return; 3503 | } 3504 | PHP_HARU_NULL_CHECK(ann, "Cannot create HaruAnnotation handle"); 3505 | 3506 | object_init_ex(return_value, ce_haruannotation); 3507 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 3508 | 3509 | annotation = (php_haruannotation *)zend_object_store_get_object(return_value TSRMLS_CC); 3510 | 3511 | annotation->page = *getThis(); 3512 | annotation->h = ann; 3513 | 3514 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 3515 | } 3516 | /* }}} */ 3517 | 3518 | /* {{{ proto object HaruPage::createURLAnnotation(array rectangle, string url) 3519 | Create and return new HaruAnnotation instance */ 3520 | static PHP_METHOD(HaruPage, createURLAnnotation) 3521 | { 3522 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3523 | php_haruannotation *annotation; 3524 | HPDF_Annotation ann; 3525 | HPDF_Rect r; 3526 | zval *rect; 3527 | int url_len; 3528 | char *url; 3529 | 3530 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "as", &rect, &url, &url_len) == FAILURE) { 3531 | return; 3532 | } 3533 | 3534 | if (zend_hash_num_elements(Z_ARRVAL_P(rect)) != 4) { 3535 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Rectangle parameter is expected to be an array with exactly 4 elements"); 3536 | return; 3537 | } 3538 | 3539 | r = php_haru_array_to_rect(rect); 3540 | 3541 | ann = HPDF_Page_CreateURILinkAnnot(page->h, r, (const char *)url); 3542 | 3543 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3544 | return; 3545 | } 3546 | PHP_HARU_NULL_CHECK(ann, "Cannot create HaruAnnotation handle"); 3547 | 3548 | object_init_ex(return_value, ce_haruannotation); 3549 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 3550 | 3551 | annotation = (php_haruannotation *)zend_object_store_get_object(return_value TSRMLS_CC); 3552 | 3553 | annotation->page = *getThis(); 3554 | annotation->h = ann; 3555 | 3556 | zend_objects_store_add_ref(getThis() TSRMLS_CC); 3557 | } 3558 | /* }}} */ 3559 | 3560 | /* {{{ proto double HaruPage::getTextWidth(string text) 3561 | Get the width of the text using current fontsize, character spacing and word spacing */ 3562 | static PHP_METHOD(HaruPage, getTextWidth) 3563 | { 3564 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3565 | HPDF_REAL width; 3566 | char *str; 3567 | int str_len; 3568 | 3569 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { 3570 | return; 3571 | } 3572 | 3573 | width = HPDF_Page_TextWidth(page->h, (const char *)str); 3574 | 3575 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3576 | return; 3577 | } 3578 | RETURN_DOUBLE((double)width); 3579 | } 3580 | /* }}} */ 3581 | 3582 | /* {{{ proto int HaruPage::MeasureText(string text, double width[, bool wordwrap]) 3583 | Calculate the number of characters which can be included within the specified width */ 3584 | static PHP_METHOD(HaruPage, MeasureText) 3585 | { 3586 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3587 | HPDF_UINT result; 3588 | char *str; 3589 | int str_len; 3590 | double width; 3591 | zend_bool wordwrap = 0; 3592 | 3593 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sd|b", &str, &str_len, &width, &wordwrap) == FAILURE) { 3594 | return; 3595 | } 3596 | 3597 | result = HPDF_Page_MeasureText(page->h, (const char *)str, (HPDF_REAL)width, (HPDF_BOOL)wordwrap, NULL); 3598 | 3599 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3600 | return; 3601 | } 3602 | RETURN_LONG(result); 3603 | } 3604 | /* }}} */ 3605 | 3606 | /* {{{ proto int HaruPage::getGMode() 3607 | Get the current graphics mode */ 3608 | static PHP_METHOD(HaruPage, getGMode) 3609 | { 3610 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3611 | HPDF_UINT16 result; 3612 | 3613 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3614 | return; 3615 | } 3616 | 3617 | result = HPDF_Page_GetGMode(page->h); 3618 | 3619 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3620 | return; 3621 | } 3622 | RETURN_LONG((long)result); 3623 | } 3624 | /* }}} */ 3625 | 3626 | /* {{{ proto array HaruPage::getCurrentPos() 3627 | Get the current position for path painting */ 3628 | static PHP_METHOD(HaruPage, getCurrentPos) 3629 | { 3630 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3631 | HPDF_Point point; 3632 | 3633 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3634 | return; 3635 | } 3636 | 3637 | point = HPDF_Page_GetCurrentPos(page->h); 3638 | 3639 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3640 | return; 3641 | } 3642 | 3643 | array_init(return_value); 3644 | add_assoc_double_ex(return_value, "x", sizeof("x"), point.x); 3645 | add_assoc_double_ex(return_value, "y", sizeof("y"), point.y); 3646 | } 3647 | /* }}} */ 3648 | 3649 | /* {{{ proto array HaruPage::getCurrentTextPos() 3650 | Get the current position for text printing */ 3651 | static PHP_METHOD(HaruPage, getCurrentTextPos) 3652 | { 3653 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3654 | HPDF_Point point; 3655 | 3656 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3657 | return; 3658 | } 3659 | 3660 | point = HPDF_Page_GetCurrentTextPos(page->h); 3661 | 3662 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3663 | return; 3664 | } 3665 | 3666 | array_init(return_value); 3667 | add_assoc_double_ex(return_value, "x", sizeof("x"), point.x); 3668 | add_assoc_double_ex(return_value, "y", sizeof("y"), point.y); 3669 | } 3670 | /* }}} */ 3671 | 3672 | /* {{{ proto object HaruPage::getCurrentFont() 3673 | Get the currently used font */ 3674 | static PHP_METHOD(HaruPage, getCurrentFont) 3675 | { 3676 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3677 | php_harufont *font; 3678 | HPDF_Font f; 3679 | 3680 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3681 | return; 3682 | } 3683 | 3684 | f = HPDF_Page_GetCurrentFont(page->h); 3685 | 3686 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3687 | return; 3688 | } 3689 | 3690 | if (!f) { /* no error */ 3691 | RETURN_FALSE; 3692 | } 3693 | 3694 | object_init_ex(return_value, ce_harufont); 3695 | HARU_SET_REFCOUNT_AND_IS_REF(return_value); 3696 | 3697 | font = (php_harufont *)zend_object_store_get_object(return_value TSRMLS_CC); 3698 | 3699 | font->doc = page->doc; 3700 | font->h = f; 3701 | 3702 | zend_objects_store_add_ref(&page->doc TSRMLS_CC); 3703 | } 3704 | /* }}} */ 3705 | 3706 | /* {{{ proto double HaruPage::getCurrentFontSize() 3707 | Get the current font size */ 3708 | static PHP_METHOD(HaruPage, getCurrentFontSize) 3709 | { 3710 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3711 | HPDF_REAL size; 3712 | 3713 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3714 | return; 3715 | } 3716 | 3717 | size = HPDF_Page_GetCurrentFontSize(page->h); 3718 | 3719 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3720 | return; 3721 | } 3722 | 3723 | RETURN_DOUBLE((double)size); 3724 | } 3725 | /* }}} */ 3726 | 3727 | /* {{{ proto double HaruPage::getLineWidth() 3728 | Get the current line width */ 3729 | static PHP_METHOD(HaruPage, getLineWidth) 3730 | { 3731 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3732 | HPDF_REAL width; 3733 | 3734 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3735 | return; 3736 | } 3737 | 3738 | width = HPDF_Page_GetLineWidth(page->h); 3739 | 3740 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3741 | return; 3742 | } 3743 | 3744 | RETURN_DOUBLE((double)width); 3745 | } 3746 | /* }}} */ 3747 | 3748 | /* {{{ proto int HaruPage::getLineCap() 3749 | Get the current line cap style */ 3750 | static PHP_METHOD(HaruPage, getLineCap) 3751 | { 3752 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3753 | HPDF_LineCap cap; 3754 | 3755 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3756 | return; 3757 | } 3758 | 3759 | cap = HPDF_Page_GetLineCap(page->h); 3760 | 3761 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3762 | return; 3763 | } 3764 | 3765 | RETURN_LONG((long)cap); 3766 | } 3767 | /* }}} */ 3768 | 3769 | /* {{{ proto int HaruPage::getLineJoin() 3770 | Get the current line join style */ 3771 | static PHP_METHOD(HaruPage, getLineJoin) 3772 | { 3773 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3774 | HPDF_LineJoin join; 3775 | 3776 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3777 | return; 3778 | } 3779 | 3780 | join = HPDF_Page_GetLineJoin(page->h); 3781 | 3782 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3783 | return; 3784 | } 3785 | 3786 | RETURN_LONG((long)join); 3787 | } 3788 | /* }}} */ 3789 | 3790 | /* {{{ proto double HaruPage::getMiterLimit() 3791 | Get the value of miter limit */ 3792 | static PHP_METHOD(HaruPage, getMiterLimit) 3793 | { 3794 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3795 | HPDF_REAL limit; 3796 | 3797 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3798 | return; 3799 | } 3800 | 3801 | limit = HPDF_Page_GetMiterLimit(page->h); 3802 | 3803 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3804 | return; 3805 | } 3806 | 3807 | RETURN_DOUBLE((double)limit); 3808 | } 3809 | /* }}} */ 3810 | 3811 | /* {{{ proto array HaruPage::getDash() 3812 | Get the current dash pattern */ 3813 | static PHP_METHOD(HaruPage, getDash) 3814 | { 3815 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3816 | HPDF_DashMode mode; 3817 | unsigned int i; 3818 | zval *element; 3819 | 3820 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3821 | return; 3822 | } 3823 | 3824 | mode = HPDF_Page_GetDash(page->h); 3825 | 3826 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3827 | return; 3828 | } 3829 | 3830 | if (!mode.num_ptn) { 3831 | RETURN_FALSE; 3832 | } 3833 | 3834 | array_init(return_value); 3835 | MAKE_STD_ZVAL(element); 3836 | array_init(element); 3837 | 3838 | for (i = 0; i < mode.num_ptn; i++) { 3839 | add_next_index_long(element, mode.ptn[i]); 3840 | } 3841 | add_assoc_zval_ex(return_value, "pattern", sizeof("pattern"), element); 3842 | 3843 | MAKE_STD_ZVAL(element); 3844 | ZVAL_LONG(element, mode.phase); 3845 | 3846 | add_assoc_zval_ex(return_value, "phase", sizeof("phase"), element); 3847 | } 3848 | /* }}} */ 3849 | 3850 | /* {{{ proto double HaruPage::getFlatness() 3851 | Get the flatness of the page */ 3852 | static PHP_METHOD(HaruPage, getFlatness) 3853 | { 3854 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3855 | HPDF_REAL flatness; 3856 | 3857 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3858 | return; 3859 | } 3860 | 3861 | flatness = HPDF_Page_GetFlat(page->h); 3862 | 3863 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3864 | return; 3865 | } 3866 | 3867 | RETURN_DOUBLE((double)flatness); 3868 | } 3869 | /* }}} */ 3870 | 3871 | /* {{{ proto double HaruPage::getCharSpace() 3872 | Get the current value of character spacing */ 3873 | static PHP_METHOD(HaruPage, getCharSpace) 3874 | { 3875 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3876 | HPDF_REAL space; 3877 | 3878 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3879 | return; 3880 | } 3881 | 3882 | space = HPDF_Page_GetCharSpace(page->h); 3883 | 3884 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3885 | return; 3886 | } 3887 | 3888 | RETURN_DOUBLE((double)space); 3889 | } 3890 | /* }}} */ 3891 | 3892 | /* {{{ proto double HaruPage::getWordSpace() 3893 | Get the current value of word spacing */ 3894 | static PHP_METHOD(HaruPage, getWordSpace) 3895 | { 3896 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3897 | HPDF_REAL space; 3898 | 3899 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3900 | return; 3901 | } 3902 | 3903 | space = HPDF_Page_GetWordSpace(page->h); 3904 | 3905 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3906 | return; 3907 | } 3908 | 3909 | RETURN_DOUBLE((double)space); 3910 | } 3911 | /* }}} */ 3912 | 3913 | /* {{{ proto double HaruPage::getHorizontalScaling() 3914 | Get the current value of horizontal scaling */ 3915 | static PHP_METHOD(HaruPage, getHorizontalScaling) 3916 | { 3917 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3918 | HPDF_REAL scaling; 3919 | 3920 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3921 | return; 3922 | } 3923 | 3924 | scaling = HPDF_Page_GetHorizontalScalling(page->h); 3925 | 3926 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3927 | return; 3928 | } 3929 | 3930 | RETURN_DOUBLE((double)scaling); 3931 | } 3932 | /* }}} */ 3933 | 3934 | /* {{{ proto double HaruPage::getTextLeading() 3935 | Get the current value of line spacing */ 3936 | static PHP_METHOD(HaruPage, getTextLeading) 3937 | { 3938 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3939 | HPDF_REAL leading; 3940 | 3941 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3942 | return; 3943 | } 3944 | 3945 | leading = HPDF_Page_GetTextLeading(page->h); 3946 | 3947 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3948 | return; 3949 | } 3950 | 3951 | RETURN_DOUBLE((double)leading); 3952 | } 3953 | /* }}} */ 3954 | 3955 | /* {{{ proto int HaruPage::getTextRenderingMode() 3956 | Get the current text rendering mode */ 3957 | static PHP_METHOD(HaruPage, getTextRenderingMode) 3958 | { 3959 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3960 | HPDF_TextRenderingMode mode; 3961 | 3962 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3963 | return; 3964 | } 3965 | 3966 | mode = HPDF_Page_GetTextRenderingMode(page->h); 3967 | 3968 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3969 | return; 3970 | } 3971 | 3972 | RETURN_LONG((long)mode); 3973 | } 3974 | /* }}} */ 3975 | 3976 | /* {{{ proto double HaruPage::getTextRise() 3977 | Get the current value of text rising */ 3978 | static PHP_METHOD(HaruPage, getTextRise) 3979 | { 3980 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 3981 | HPDF_REAL rise; 3982 | 3983 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 3984 | return; 3985 | } 3986 | 3987 | rise = HPDF_Page_GetTextRise(page->h); 3988 | 3989 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 3990 | return; 3991 | } 3992 | 3993 | RETURN_DOUBLE((double)rise); 3994 | } 3995 | /* }}} */ 3996 | 3997 | /* {{{ proto array HaruPage::getRGBFill() 3998 | Get the current filling color */ 3999 | static PHP_METHOD(HaruPage, getRGBFill) 4000 | { 4001 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4002 | HPDF_RGBColor fill; 4003 | 4004 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4005 | return; 4006 | } 4007 | 4008 | fill = HPDF_Page_GetRGBFill(page->h); 4009 | 4010 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4011 | return; 4012 | } 4013 | 4014 | array_init(return_value); 4015 | add_assoc_double_ex(return_value, "r", sizeof("r"), fill.r); 4016 | add_assoc_double_ex(return_value, "g", sizeof("g"), fill.g); 4017 | add_assoc_double_ex(return_value, "b", sizeof("b"), fill.b); 4018 | } 4019 | /* }}} */ 4020 | 4021 | /* {{{ proto array HaruPage::getRGBStroke() 4022 | Get the current stroking color */ 4023 | static PHP_METHOD(HaruPage, getRGBStroke) 4024 | { 4025 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4026 | HPDF_RGBColor stroke; 4027 | 4028 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4029 | return; 4030 | } 4031 | 4032 | stroke = HPDF_Page_GetRGBStroke(page->h); 4033 | 4034 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4035 | return; 4036 | } 4037 | 4038 | array_init(return_value); 4039 | add_assoc_double_ex(return_value, "r", sizeof("r"), stroke.r); 4040 | add_assoc_double_ex(return_value, "g", sizeof("g"), stroke.g); 4041 | add_assoc_double_ex(return_value, "b", sizeof("b"), stroke.b); 4042 | } 4043 | /* }}} */ 4044 | 4045 | /* {{{ proto array HaruPage::getCMYKFill() 4046 | Get the current filling color */ 4047 | static PHP_METHOD(HaruPage, getCMYKFill) 4048 | { 4049 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4050 | HPDF_CMYKColor fill; 4051 | 4052 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4053 | return; 4054 | } 4055 | 4056 | fill = HPDF_Page_GetCMYKFill(page->h); 4057 | 4058 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4059 | return; 4060 | } 4061 | 4062 | array_init(return_value); 4063 | add_assoc_double_ex(return_value, "c", sizeof("c"), fill.c); 4064 | add_assoc_double_ex(return_value, "m", sizeof("m"), fill.m); 4065 | add_assoc_double_ex(return_value, "y", sizeof("y"), fill.y); 4066 | add_assoc_double_ex(return_value, "k", sizeof("k"), fill.k); 4067 | } 4068 | /* }}} */ 4069 | 4070 | /* {{{ proto array HaruPage::getCMYKStroke() 4071 | Get the current stroking color */ 4072 | static PHP_METHOD(HaruPage, getCMYKStroke) 4073 | { 4074 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4075 | HPDF_CMYKColor stroke; 4076 | 4077 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4078 | return; 4079 | } 4080 | 4081 | stroke = HPDF_Page_GetCMYKStroke(page->h); 4082 | 4083 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4084 | return; 4085 | } 4086 | 4087 | array_init(return_value); 4088 | add_assoc_double_ex(return_value, "c", sizeof("c"), stroke.c); 4089 | add_assoc_double_ex(return_value, "m", sizeof("m"), stroke.m); 4090 | add_assoc_double_ex(return_value, "y", sizeof("y"), stroke.y); 4091 | add_assoc_double_ex(return_value, "k", sizeof("k"), stroke.k); 4092 | } 4093 | /* }}} */ 4094 | 4095 | /* {{{ proto double HaruPage::getGrayFill() 4096 | Get the current filling color */ 4097 | static PHP_METHOD(HaruPage, getGrayFill) 4098 | { 4099 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4100 | HPDF_REAL fill; 4101 | 4102 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4103 | return; 4104 | } 4105 | 4106 | fill = HPDF_Page_GetGrayFill(page->h); 4107 | 4108 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4109 | return; 4110 | } 4111 | 4112 | RETURN_DOUBLE((double)fill); 4113 | } 4114 | /* }}} */ 4115 | 4116 | /* {{{ proto double HaruPage::getGrayStroke() 4117 | Get the current stroking color */ 4118 | static PHP_METHOD(HaruPage, getGrayStroke) 4119 | { 4120 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4121 | HPDF_REAL stroke; 4122 | 4123 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4124 | return; 4125 | } 4126 | 4127 | stroke = HPDF_Page_GetGrayStroke(page->h); 4128 | 4129 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4130 | return; 4131 | } 4132 | 4133 | RETURN_DOUBLE((double)stroke); 4134 | } 4135 | /* }}} */ 4136 | 4137 | /* {{{ proto int HaruPage::getFillingColorSpace() 4138 | Get the current filling color space */ 4139 | static PHP_METHOD(HaruPage, getFillingColorSpace) 4140 | { 4141 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4142 | HPDF_ColorSpace space; 4143 | 4144 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4145 | return; 4146 | } 4147 | 4148 | space = HPDF_Page_GetFillingColorSpace(page->h); 4149 | 4150 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4151 | return; 4152 | } 4153 | 4154 | RETURN_LONG((long)space); 4155 | } 4156 | /* }}} */ 4157 | 4158 | /* {{{ proto int HaruPage::getStrokingColorSpace() 4159 | Get the current stroking color space */ 4160 | static PHP_METHOD(HaruPage, getStrokingColorSpace) 4161 | { 4162 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4163 | HPDF_ColorSpace space; 4164 | 4165 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4166 | return; 4167 | } 4168 | 4169 | space = HPDF_Page_GetStrokingColorSpace(page->h); 4170 | 4171 | if (php_haru_check_error(page->h->error TSRMLS_CC)) { 4172 | return; 4173 | } 4174 | 4175 | RETURN_LONG((long)space); 4176 | } 4177 | /* }}} */ 4178 | 4179 | /* {{{ proto bool HaruPage::setSlideShow(int type, double disp_time, double trans_time) 4180 | Set transition style for the page */ 4181 | static PHP_METHOD(HaruPage, setSlideShow) 4182 | { 4183 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4184 | HPDF_STATUS status; 4185 | long type; 4186 | double disp_time, trans_time; 4187 | 4188 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ldd", &type, &disp_time, &trans_time) == FAILURE) { 4189 | return; 4190 | } 4191 | 4192 | switch(type) { 4193 | case HPDF_TS_WIPE_RIGHT: 4194 | case HPDF_TS_WIPE_UP: 4195 | case HPDF_TS_WIPE_LEFT: 4196 | case HPDF_TS_WIPE_DOWN: 4197 | case HPDF_TS_BARN_DOORS_HORIZONTAL_OUT: 4198 | case HPDF_TS_BARN_DOORS_HORIZONTAL_IN: 4199 | case HPDF_TS_BARN_DOORS_VERTICAL_OUT: 4200 | case HPDF_TS_BARN_DOORS_VERTICAL_IN: 4201 | case HPDF_TS_BOX_OUT: 4202 | case HPDF_TS_BOX_IN: 4203 | case HPDF_TS_BLINDS_HORIZONTAL: 4204 | case HPDF_TS_BLINDS_VERTICAL: 4205 | case HPDF_TS_DISSOLVE: 4206 | case HPDF_TS_GLITTER_RIGHT: 4207 | case HPDF_TS_GLITTER_DOWN: 4208 | case HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT: 4209 | case HPDF_TS_REPLACE: 4210 | /* only these are valid */ 4211 | break; 4212 | default: 4213 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid transition style value"); 4214 | return; 4215 | } 4216 | 4217 | status = HPDF_Page_SetSlideShow(page->h, (HPDF_TransitionStyle)type, (HPDF_REAL)disp_time, (HPDF_REAL)trans_time); 4218 | 4219 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4220 | return; 4221 | } 4222 | RETURN_TRUE; 4223 | } 4224 | /* }}} */ 4225 | 4226 | /* {{{ proto bool HaruPage::clip() 4227 | Modifies the current clipping path by intersecting it with the current path using the nonzero winding number rule. 4228 | The clipping path is only modified after the succeeding painting operator. 4229 | The following painting operations will only affect the regions of the page contained by the clipping path. 4230 | Initially, the clipping path includes the entire page. 4231 | There is no way to enlarge the current clipping path, or to replace the clipping path with a new one. */ 4232 | static PHP_METHOD(HaruPage, clip) 4233 | { 4234 | php_harupage *page = (php_harupage *) zend_object_store_get_object(getThis() TSRMLS_CC); 4235 | HPDF_STATUS status; 4236 | 4237 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4238 | return; 4239 | } 4240 | 4241 | status = HPDF_Page_Clip(page->h); 4242 | 4243 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4244 | return; 4245 | } 4246 | RETURN_TRUE; 4247 | } 4248 | /* }}} */ 4249 | 4250 | /* {{{ proto bool HaruPage::saveGS() 4251 | Saves the page's current graphics state to the stack. 4252 | The parameters that are saved are: 4253 | Character Spacing 4254 | Clipping Path 4255 | Dash Mode 4256 | Filling Color 4257 | Flatness 4258 | Font 4259 | Font Size 4260 | Horizontal Scalling 4261 | Line Width 4262 | Line Cap Style 4263 | Line Join Style 4264 | Miter Limit 4265 | Rendering Mode 4266 | Stroking Color 4267 | Text Leading 4268 | Text Rise 4269 | Transformation Matrix 4270 | Word Spacing */ 4271 | static PHP_METHOD(HaruPage, saveGS) 4272 | { 4273 | php_harupage *page = (php_harupage *) zend_object_store_get_object(getThis() TSRMLS_CC); 4274 | HPDF_STATUS status; 4275 | 4276 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4277 | return; 4278 | } 4279 | 4280 | status = HPDF_Page_GSave(page->h); 4281 | 4282 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4283 | return; 4284 | } 4285 | RETURN_TRUE; 4286 | } 4287 | /* }}} */ 4288 | 4289 | /* {{{ proto bool HaruPage::restoreGS() 4290 | Restores the graphics state saved by saveGS() */ 4291 | static PHP_METHOD(HaruPage, restoreGS) 4292 | { 4293 | HPDF_STATUS status; 4294 | php_harupage *page = (php_harupage *) zend_object_store_get_object(getThis() TSRMLS_CC); 4295 | 4296 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4297 | return; 4298 | } 4299 | 4300 | status = HPDF_Page_GRestore(page->h); 4301 | 4302 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4303 | return; 4304 | } 4305 | RETURN_TRUE; 4306 | } 4307 | /* }}} */ 4308 | 4309 | #if defined(HPDF_VERSION_ID) && HPDF_VERSION_ID >= 20200 4310 | /* {{{ proto bool HaruPage::setZoom(double zoom) 4311 | Set size and direction of the page */ 4312 | static PHP_METHOD(HaruPage, setZoom) 4313 | { 4314 | php_harupage *page = (php_harupage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4315 | HPDF_STATUS status; 4316 | double zoom; 4317 | 4318 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &zoom) == FAILURE) { 4319 | return; 4320 | } 4321 | 4322 | status = HPDF_Page_SetZoom(page->h, (HPDF_REAL) zoom); 4323 | 4324 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4325 | return; 4326 | } 4327 | RETURN_TRUE; 4328 | } 4329 | /* }}} */ 4330 | #endif 4331 | 4332 | /* }}} */ 4333 | 4334 | /* HaruImage methods {{{ */ 4335 | 4336 | /* {{{ proto bool HaruImage::__construct() 4337 | Dummy constructor */ 4338 | static PHP_METHOD(HaruImage, __construct) 4339 | { 4340 | return; 4341 | } 4342 | /* }}} */ 4343 | 4344 | /* {{{ proto array HaruImage::getSize() 4345 | Get size of the image */ 4346 | static PHP_METHOD(HaruImage, getSize) 4347 | { 4348 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4349 | HPDF_Point ret; 4350 | 4351 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4352 | return; 4353 | } 4354 | 4355 | ret = HPDF_Image_GetSize(image->h); 4356 | 4357 | if (php_haru_check_error(image->h->error TSRMLS_CC)) { 4358 | return; 4359 | } 4360 | 4361 | array_init(return_value); 4362 | add_assoc_double_ex(return_value, "width", sizeof("width"), ret.x); 4363 | add_assoc_double_ex(return_value, "height", sizeof("height"), ret.y); 4364 | } 4365 | /* }}} */ 4366 | 4367 | /* {{{ proto int HaruImage::getWidth() 4368 | Get width of the image */ 4369 | static PHP_METHOD(HaruImage, getWidth) 4370 | { 4371 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4372 | HPDF_UINT width; 4373 | 4374 | 4375 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4376 | return; 4377 | } 4378 | 4379 | width = HPDF_Image_GetWidth(image->h); 4380 | 4381 | if (php_haru_check_error(image->h->error TSRMLS_CC)) { 4382 | return; 4383 | } 4384 | RETURN_LONG(width); 4385 | } 4386 | /* }}} */ 4387 | 4388 | /* {{{ proto int HaruImage::getHeight() 4389 | Get height of the image */ 4390 | static PHP_METHOD(HaruImage, getHeight) 4391 | { 4392 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4393 | HPDF_UINT height; 4394 | 4395 | 4396 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4397 | return; 4398 | } 4399 | 4400 | height = HPDF_Image_GetHeight(image->h); 4401 | 4402 | if (php_haru_check_error(image->h->error TSRMLS_CC)) { 4403 | return; 4404 | } 4405 | RETURN_LONG(height); 4406 | } 4407 | /* }}} */ 4408 | 4409 | /* {{{ proto int HaruImage::getBitsPerComponent() 4410 | Get the number of bits used to describe each color component of the image */ 4411 | static PHP_METHOD(HaruImage, getBitsPerComponent) 4412 | { 4413 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4414 | HPDF_UINT bits; 4415 | 4416 | 4417 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4418 | return; 4419 | } 4420 | 4421 | bits = HPDF_Image_GetBitsPerComponent(image->h); 4422 | 4423 | if (php_haru_check_error(image->h->error TSRMLS_CC)) { 4424 | return; 4425 | } 4426 | RETURN_LONG(bits); 4427 | } 4428 | /* }}} */ 4429 | 4430 | /* {{{ proto string HaruImage::getColorSpace() 4431 | Get the name of the color space */ 4432 | static PHP_METHOD(HaruImage, getColorSpace) 4433 | { 4434 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4435 | const char *space; 4436 | 4437 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4438 | return; 4439 | } 4440 | 4441 | space = HPDF_Image_GetColorSpace(image->h); 4442 | 4443 | if (php_haru_check_error(image->h->error TSRMLS_CC)) { 4444 | return; 4445 | } 4446 | PHP_HARU_NULL_CHECK(space, "Failed to get the color space of the image"); 4447 | 4448 | RETURN_STRING((char *)space, 1); 4449 | } 4450 | /* }}} */ 4451 | 4452 | /* {{{ proto bool HaruImage::setColorMask(int rmin, int rmax, int gmin, int gmax, int bmin, int bmax) 4453 | Set the color mask of the image */ 4454 | static PHP_METHOD(HaruImage, setColorMask) 4455 | { 4456 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4457 | HPDF_STATUS status; 4458 | long rmin, rmax, gmin, gmax, bmin, bmax; 4459 | 4460 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llllll", &rmin, &rmax, &gmin, &gmax, &bmin, &bmax) == FAILURE) { 4461 | return; 4462 | } 4463 | 4464 | status = HPDF_Image_SetColorMask(image->h, (HPDF_UINT)rmin, (HPDF_UINT)rmax, (HPDF_UINT)gmin, (HPDF_UINT)gmax, (HPDF_UINT)bmin, (HPDF_UINT)bmax); 4465 | 4466 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4467 | return; 4468 | } 4469 | RETURN_TRUE; 4470 | } 4471 | /* }}} */ 4472 | 4473 | /* {{{ proto bool HaruImage::setMaskImage(object mask_image) 4474 | Set the image mask */ 4475 | static PHP_METHOD(HaruImage, setMaskImage) 4476 | { 4477 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4478 | php_haruimage *mask_image; 4479 | HPDF_STATUS status; 4480 | zval *z_mask_image; 4481 | 4482 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_mask_image, ce_haruimage) == FAILURE) { 4483 | return; 4484 | } 4485 | 4486 | mask_image = (php_haruimage *)zend_object_store_get_object(z_mask_image TSRMLS_CC); 4487 | 4488 | status = HPDF_Image_SetMaskImage(image->h, mask_image->h); 4489 | 4490 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4491 | return; 4492 | } 4493 | RETURN_TRUE; 4494 | } 4495 | /* }}} */ 4496 | 4497 | #if defined(HPDF_VERSION_ID) && HPDF_VERSION_ID >= 20200 4498 | 4499 | /* {{{ proto bool HaruImage::addSMask(object smask_image) 4500 | Set image transparency mask */ 4501 | static PHP_METHOD(HaruImage, addSMask) 4502 | { 4503 | php_haruimage *image = (php_haruimage *)zend_object_store_get_object(getThis() TSRMLS_CC); 4504 | php_haruimage *smask_image; 4505 | HPDF_STATUS status; 4506 | zval *z_smask_image; 4507 | 4508 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_smask_image, ce_haruimage) == FAILURE) { 4509 | return; 4510 | } 4511 | 4512 | smask_image = (php_haruimage *)zend_object_store_get_object(z_smask_image TSRMLS_CC); 4513 | 4514 | status = HPDF_Image_AddSMask(image->h, smask_image->h); 4515 | 4516 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4517 | return; 4518 | } 4519 | RETURN_TRUE; 4520 | } 4521 | /* }}} */ 4522 | #endif 4523 | 4524 | /* }}} */ 4525 | 4526 | /* HaruFont methods {{{ */ 4527 | 4528 | /* {{{ proto bool HaruFont::__construct() 4529 | Dummy constructor */ 4530 | static PHP_METHOD(HaruFont, __construct) 4531 | { 4532 | return; 4533 | } 4534 | /* }}} */ 4535 | 4536 | /* {{{ proto string HaruFont::getFontName() 4537 | Get the name of the font */ 4538 | static PHP_METHOD(HaruFont, getFontName) 4539 | { 4540 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4541 | const char *name; 4542 | 4543 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4544 | return; 4545 | } 4546 | 4547 | name = HPDF_Font_GetFontName(font->h); 4548 | 4549 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4550 | return; 4551 | } 4552 | PHP_HARU_NULL_CHECK(name, "Failed to get the name of the font"); 4553 | 4554 | RETURN_STRING((char *)name, 1); 4555 | } 4556 | /* }}} */ 4557 | 4558 | /* {{{ proto string HaruFont::getEncodingName() 4559 | Get the name of the encoding */ 4560 | static PHP_METHOD(HaruFont, getEncodingName) 4561 | { 4562 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4563 | const char *name; 4564 | 4565 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4566 | return; 4567 | } 4568 | 4569 | name = HPDF_Font_GetEncodingName(font->h); 4570 | 4571 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4572 | return; 4573 | } 4574 | PHP_HARU_NULL_CHECK(name, "Failed to get the encoding name of the font"); 4575 | 4576 | RETURN_STRING((char *)name, 1); 4577 | } 4578 | /* }}} */ 4579 | 4580 | /* {{{ proto int HaruFont::getUnicodeWidth(int character) 4581 | Get the width of the character in the font */ 4582 | static PHP_METHOD(HaruFont, getUnicodeWidth) 4583 | { 4584 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4585 | HPDF_INT width; 4586 | long character; 4587 | 4588 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &character) == FAILURE) { 4589 | return; 4590 | } 4591 | 4592 | width = HPDF_Font_GetUnicodeWidth(font->h, (HPDF_UINT16)character); 4593 | 4594 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4595 | return; 4596 | } 4597 | RETURN_LONG((long)width); 4598 | } 4599 | /* }}} */ 4600 | 4601 | /* {{{ proto int HaruFont::getAscent() 4602 | Get the vertical ascent of the font */ 4603 | static PHP_METHOD(HaruFont, getAscent) 4604 | { 4605 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4606 | HPDF_INT ascent; 4607 | 4608 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4609 | return; 4610 | } 4611 | 4612 | ascent = HPDF_Font_GetAscent(font->h); 4613 | 4614 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4615 | return; 4616 | } 4617 | RETURN_LONG((long)ascent); 4618 | } 4619 | /* }}} */ 4620 | 4621 | /* {{{ proto int HaruFont::getDescent() 4622 | Get the vertical descent of the font */ 4623 | static PHP_METHOD(HaruFont, getDescent) 4624 | { 4625 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4626 | HPDF_INT descent; 4627 | 4628 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4629 | return; 4630 | } 4631 | 4632 | descent = HPDF_Font_GetDescent(font->h); 4633 | 4634 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4635 | return; 4636 | } 4637 | RETURN_LONG(descent); 4638 | } 4639 | /* }}} */ 4640 | 4641 | /* {{{ proto int HaruFont::getXHeight() 4642 | Get the distance from the baseline of lowercase letter */ 4643 | static PHP_METHOD(HaruFont, getXHeight) 4644 | { 4645 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4646 | HPDF_UINT xheight; 4647 | 4648 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4649 | return; 4650 | } 4651 | 4652 | xheight = HPDF_Font_GetXHeight(font->h); 4653 | 4654 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4655 | return; 4656 | } 4657 | RETURN_LONG((long)xheight); 4658 | } 4659 | /* }}} */ 4660 | 4661 | /* {{{ proto int HaruFont::getCapHeight() 4662 | Get the distance from the baseline of uppercase letter */ 4663 | static PHP_METHOD(HaruFont, getCapHeight) 4664 | { 4665 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4666 | HPDF_UINT cap_height; 4667 | 4668 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4669 | return; 4670 | } 4671 | 4672 | cap_height = HPDF_Font_GetCapHeight(font->h); 4673 | 4674 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4675 | return; 4676 | } 4677 | RETURN_LONG((long)cap_height); 4678 | } 4679 | /* }}} */ 4680 | 4681 | /* {{{ proto array HaruFont::getTextWidth(string text) 4682 | Get the total width of the text, number of characters, number of words and number of spaces */ 4683 | static PHP_METHOD(HaruFont, getTextWidth) 4684 | { 4685 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4686 | char *str; 4687 | int str_len; 4688 | HPDF_TextWidth width; 4689 | 4690 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { 4691 | return; 4692 | } 4693 | 4694 | width = HPDF_Font_TextWidth(font->h, (const HPDF_BYTE *)str, (HPDF_UINT)str_len); 4695 | 4696 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4697 | return; 4698 | } 4699 | 4700 | array_init(return_value); 4701 | add_assoc_long_ex(return_value, "numchars", sizeof("numchars"), width.numchars); 4702 | add_assoc_long_ex(return_value, "numwords", sizeof("numwords"), width.numwords); 4703 | add_assoc_long_ex(return_value, "width", sizeof("width"), width.width); 4704 | add_assoc_long_ex(return_value, "numspace", sizeof("numspace"), width.numspace); 4705 | } 4706 | /* }}} */ 4707 | 4708 | /* {{{ proto int HaruFont::MeasureText(string text, double width, double font_size, double char_space, double word_space[, bool word_wrap]) 4709 | Calculate the number of characters which can be included within the specified width */ 4710 | static PHP_METHOD(HaruFont, MeasureText) 4711 | { 4712 | php_harufont *font = (php_harufont *)zend_object_store_get_object(getThis() TSRMLS_CC); 4713 | char *str; 4714 | int str_len, result; 4715 | double width, font_size, char_space, word_space; 4716 | zend_bool wordwrap = 0; 4717 | 4718 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sdddd|b", &str, &str_len, &width, &font_size, &char_space, &word_space, &wordwrap) == FAILURE) { 4719 | return; 4720 | } 4721 | 4722 | result = HPDF_Font_MeasureText(font->h, (const HPDF_BYTE *)str, (HPDF_UINT)str_len, (HPDF_REAL)width, (HPDF_REAL)font_size, (HPDF_REAL)char_space, (HPDF_REAL)word_space, (HPDF_BOOL)wordwrap, NULL); 4723 | 4724 | if (php_haru_check_error(font->h->error TSRMLS_CC)) { 4725 | return; 4726 | } 4727 | RETURN_LONG(result); 4728 | } 4729 | /* }}} */ 4730 | 4731 | /* }}} */ 4732 | 4733 | /* HaruEncoder methods {{{ */ 4734 | 4735 | /* {{{ proto bool HaruEncoder::__construct() 4736 | Dummy constructor */ 4737 | static PHP_METHOD(HaruEncoder, __construct) 4738 | { 4739 | return; 4740 | } 4741 | /* }}} */ 4742 | 4743 | /* {{{ proto int HaruEncoder::getType() 4744 | Get the type of the encoder */ 4745 | static PHP_METHOD(HaruEncoder, getType) 4746 | { 4747 | php_haruencoder *encoder = (php_haruencoder *)zend_object_store_get_object(getThis() TSRMLS_CC); 4748 | HPDF_EncoderType type; 4749 | 4750 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4751 | return; 4752 | } 4753 | 4754 | type = HPDF_Encoder_GetType(encoder->h); 4755 | 4756 | RETURN_LONG((long)type); 4757 | } 4758 | /* }}} */ 4759 | 4760 | /* {{{ proto int HaruEncoder::getByteType(string text, int index) 4761 | Get the type of the byte in the text on the current position */ 4762 | static PHP_METHOD(HaruEncoder, getByteType) 4763 | { 4764 | php_haruencoder *encoder = (php_haruencoder *)zend_object_store_get_object(getThis() TSRMLS_CC); 4765 | HPDF_ByteType type; 4766 | char *str; 4767 | int str_len; 4768 | long index; 4769 | 4770 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &str, &str_len, &index) == FAILURE) { 4771 | return; 4772 | } 4773 | 4774 | type = HPDF_Encoder_GetByteType(encoder->h, (const char*) str, (HPDF_UINT)index); 4775 | 4776 | RETURN_LONG((long)type); 4777 | } 4778 | /* }}} */ 4779 | 4780 | /* {{{ proto int HaruEncoder::getUnicode(int character) 4781 | Convert the specified character to unicode */ 4782 | static PHP_METHOD(HaruEncoder, getUnicode) 4783 | { 4784 | php_haruencoder *encoder = (php_haruencoder *)zend_object_store_get_object(getThis() TSRMLS_CC); 4785 | HPDF_UNICODE unicode; 4786 | long character; 4787 | 4788 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &character) == FAILURE) { 4789 | return; 4790 | } 4791 | 4792 | unicode = HPDF_Encoder_GetUnicode(encoder->h, (HPDF_UINT16)character); 4793 | 4794 | RETURN_LONG((long)unicode); 4795 | } 4796 | /* }}} */ 4797 | 4798 | /* {{{ proto int HaruEncoder::getWritingMode() 4799 | Get the writing mode of the encoder */ 4800 | static PHP_METHOD(HaruEncoder, getWritingMode) 4801 | { 4802 | php_haruencoder *encoder = (php_haruencoder *)zend_object_store_get_object(getThis() TSRMLS_CC); 4803 | HPDF_WritingMode mode; 4804 | 4805 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4806 | return; 4807 | } 4808 | 4809 | mode = HPDF_Encoder_GetWritingMode(encoder->h); 4810 | 4811 | RETURN_LONG((long)mode); 4812 | } 4813 | /* }}} */ 4814 | 4815 | /* }}} */ 4816 | 4817 | /* HaruAnnotation methods {{{ */ 4818 | 4819 | /* {{{ proto bool HaruAnnotation::__construct() 4820 | Dummy constructor */ 4821 | static PHP_METHOD(HaruAnnotation, __construct) 4822 | { 4823 | return; 4824 | } 4825 | /* }}} */ 4826 | 4827 | /* {{{ proto bool HaruAnnotation::setHighlightMode(int mode) 4828 | Set the highlighting mode of the annotation */ 4829 | static PHP_METHOD(HaruAnnotation, setHighlightMode) 4830 | { 4831 | php_haruannotation *a = (php_haruannotation *)zend_object_store_get_object(getThis() TSRMLS_CC); 4832 | HPDF_STATUS status; 4833 | long mode; 4834 | 4835 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { 4836 | return; 4837 | } 4838 | 4839 | switch(mode) { 4840 | case HPDF_ANNOT_NO_HIGHTLIGHT: 4841 | case HPDF_ANNOT_INVERT_BOX: 4842 | case HPDF_ANNOT_INVERT_BORDER: 4843 | case HPDF_ANNOT_DOWN_APPEARANCE: 4844 | /* only these are valid */ 4845 | break; 4846 | default: 4847 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid highlight mode value"); 4848 | return; 4849 | } 4850 | 4851 | status = HPDF_LinkAnnot_SetHighlightMode(a->h, (HPDF_AnnotHighlightMode)mode); 4852 | 4853 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4854 | return; 4855 | } 4856 | RETURN_TRUE; 4857 | } 4858 | /* }}} */ 4859 | 4860 | /* {{{ proto bool HaruAnnotation::setBorderStyle(double width, int dash_on, int dash_off) 4861 | Set the border style of the annotation */ 4862 | static PHP_METHOD(HaruAnnotation, setBorderStyle) 4863 | { 4864 | php_haruannotation *a = (php_haruannotation *)zend_object_store_get_object(getThis() TSRMLS_CC); 4865 | HPDF_STATUS status; 4866 | double width; 4867 | long dash_on, dash_off; 4868 | 4869 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dll", &width, &dash_on, &dash_off) == FAILURE) { 4870 | return; 4871 | } 4872 | 4873 | status = HPDF_LinkAnnot_SetBorderStyle(a->h, (HPDF_REAL)width, (HPDF_UINT16)dash_on, (HPDF_UINT16)dash_off); 4874 | 4875 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4876 | return; 4877 | } 4878 | RETURN_TRUE; 4879 | } 4880 | /* }}} */ 4881 | 4882 | /* {{{ proto bool HaruAnnotation::setIcon(int icon) 4883 | Set the icon style of the annotation */ 4884 | static PHP_METHOD(HaruAnnotation, setIcon) 4885 | { 4886 | php_haruannotation *a = (php_haruannotation *)zend_object_store_get_object(getThis() TSRMLS_CC); 4887 | HPDF_STATUS status; 4888 | long icon; 4889 | 4890 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &icon) == FAILURE) { 4891 | return; 4892 | } 4893 | 4894 | switch(icon) { 4895 | case HPDF_ANNOT_ICON_COMMENT: 4896 | case HPDF_ANNOT_ICON_KEY: 4897 | case HPDF_ANNOT_ICON_NOTE: 4898 | case HPDF_ANNOT_ICON_HELP: 4899 | case HPDF_ANNOT_ICON_NEW_PARAGRAPH: 4900 | case HPDF_ANNOT_ICON_PARAGRAPH: 4901 | case HPDF_ANNOT_ICON_INSERT: 4902 | /* only these are valid */ 4903 | break; 4904 | default: 4905 | zend_throw_exception_ex(ce_haruexception, 0 TSRMLS_CC, "Invalid icon value"); 4906 | return; 4907 | } 4908 | 4909 | status = HPDF_TextAnnot_SetIcon(a->h, (HPDF_AnnotIcon)icon); 4910 | 4911 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4912 | return; 4913 | } 4914 | RETURN_TRUE; 4915 | } 4916 | /* }}} */ 4917 | 4918 | /* {{{ proto bool HaruAnnotation::setOpened(bool opened) 4919 | Set the initial state of the annotation */ 4920 | static PHP_METHOD(HaruAnnotation, setOpened) 4921 | { 4922 | php_haruannotation *a = (php_haruannotation *)zend_object_store_get_object(getThis() TSRMLS_CC); 4923 | HPDF_STATUS status; 4924 | zend_bool opened; 4925 | 4926 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &opened) == FAILURE) { 4927 | return; 4928 | } 4929 | 4930 | status = HPDF_TextAnnot_SetOpened(a->h, (HPDF_BOOL)opened); 4931 | 4932 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4933 | return; 4934 | } 4935 | RETURN_TRUE; 4936 | } 4937 | /* }}} */ 4938 | 4939 | /* }}} */ 4940 | 4941 | /* HaruDestination methods {{{ */ 4942 | 4943 | /* {{{ proto bool HaruDestination::__construct() 4944 | Dummy constructor */ 4945 | static PHP_METHOD(HaruDestination, __construct) 4946 | { 4947 | return; 4948 | } 4949 | /* }}} */ 4950 | 4951 | /* {{{ proto bool HaruDestination::setXYZ(double left, double top, double zoom) 4952 | Set the appearance of the page */ 4953 | static PHP_METHOD(HaruDestination, setXYZ) 4954 | { 4955 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 4956 | HPDF_STATUS status; 4957 | double left, top, zoom; 4958 | 4959 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &left, &top, &zoom) == FAILURE) { 4960 | return; 4961 | } 4962 | 4963 | status = HPDF_Destination_SetXYZ(dest->h, (HPDF_REAL)left, (HPDF_REAL)top, (HPDF_REAL)zoom); 4964 | 4965 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4966 | return; 4967 | } 4968 | RETURN_TRUE; 4969 | } 4970 | /* }}} */ 4971 | 4972 | /* {{{ proto bool HaruDestination::setFit() 4973 | Set the appearance of the page to fit the window */ 4974 | static PHP_METHOD(HaruDestination, setFit) 4975 | { 4976 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 4977 | HPDF_STATUS status; 4978 | 4979 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 4980 | return; 4981 | } 4982 | 4983 | status = HPDF_Destination_SetFit(dest->h); 4984 | 4985 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 4986 | return; 4987 | } 4988 | RETURN_TRUE; 4989 | } 4990 | /* }}} */ 4991 | 4992 | /* {{{ proto bool HaruDestination::setFitH(double top) 4993 | Set the appearance of the page to fit the window width */ 4994 | static PHP_METHOD(HaruDestination, setFitH) 4995 | { 4996 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 4997 | HPDF_STATUS status; 4998 | double top; 4999 | 5000 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &top) == FAILURE) { 5001 | return; 5002 | } 5003 | 5004 | status = HPDF_Destination_SetFitH(dest->h, (HPDF_REAL)top); 5005 | 5006 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5007 | return; 5008 | } 5009 | RETURN_TRUE; 5010 | } 5011 | /* }}} */ 5012 | 5013 | /* {{{ proto bool HaruDestination::setFitV(double left) 5014 | Set the appearance of the page to fit the window height */ 5015 | static PHP_METHOD(HaruDestination, setFitV) 5016 | { 5017 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 5018 | HPDF_STATUS status; 5019 | double left; 5020 | 5021 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &left) == FAILURE) { 5022 | return; 5023 | } 5024 | 5025 | status = HPDF_Destination_SetFitV(dest->h, (HPDF_REAL)left); 5026 | 5027 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5028 | return; 5029 | } 5030 | RETURN_TRUE; 5031 | } 5032 | /* }}} */ 5033 | 5034 | /* {{{ proto bool HaruDestination::setFitR(double left, double bottom, double right, double top) 5035 | Set the appearance of the page to fit the specified rectangle */ 5036 | static PHP_METHOD(HaruDestination, setFitR) 5037 | { 5038 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 5039 | HPDF_STATUS status; 5040 | double left, bottom, right, top; 5041 | 5042 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &left, &bottom, &right, &top) == FAILURE) { 5043 | return; 5044 | } 5045 | 5046 | status = HPDF_Destination_SetFitR(dest->h, (HPDF_REAL) left, (HPDF_REAL) bottom, (HPDF_REAL) right, (HPDF_REAL) top); 5047 | 5048 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5049 | return; 5050 | } 5051 | RETURN_TRUE; 5052 | } 5053 | /* }}} */ 5054 | 5055 | /* {{{ proto bool HaruDestination::setFitB() 5056 | Set the appearance of the page to fit the bounding box of the page within the window */ 5057 | static PHP_METHOD(HaruDestination, setFitB) 5058 | { 5059 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 5060 | HPDF_STATUS status; 5061 | 5062 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { 5063 | return; 5064 | } 5065 | 5066 | status = HPDF_Destination_SetFitB(dest->h); 5067 | 5068 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5069 | return; 5070 | } 5071 | RETURN_TRUE; 5072 | } 5073 | /* }}} */ 5074 | 5075 | /* {{{ proto bool HaruDestination::setFitBH(double top) 5076 | Set the appearance of the page to fit the width of the bounding box */ 5077 | static PHP_METHOD(HaruDestination, setFitBH) 5078 | { 5079 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 5080 | HPDF_STATUS status; 5081 | double top; 5082 | 5083 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &top) == FAILURE) { 5084 | return; 5085 | } 5086 | 5087 | status = HPDF_Destination_SetFitBH(dest->h, (HPDF_REAL)top); 5088 | 5089 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5090 | return; 5091 | } 5092 | RETURN_TRUE; 5093 | } 5094 | /* }}} */ 5095 | 5096 | /* {{{ proto bool HaruDestination::setFitBV(double left) 5097 | Set the appearance of the page to fit the height of the boudning box */ 5098 | static PHP_METHOD(HaruDestination, setFitBV) 5099 | { 5100 | php_harudestination *dest = (php_harudestination *)zend_object_store_get_object(getThis() TSRMLS_CC); 5101 | HPDF_STATUS status; 5102 | double left; 5103 | 5104 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &left) == FAILURE) { 5105 | return; 5106 | } 5107 | 5108 | status = HPDF_Destination_SetFitBV(dest->h, (HPDF_REAL)left); 5109 | 5110 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5111 | return; 5112 | } 5113 | RETURN_TRUE; 5114 | } 5115 | /* }}} */ 5116 | 5117 | /* }}} */ 5118 | 5119 | /* HaruOutline methods {{{ */ 5120 | 5121 | /* {{{ proto bool HaruOutline::__construct() 5122 | Dummy constructor */ 5123 | static PHP_METHOD(HaruOutline, __construct) 5124 | { 5125 | return; 5126 | } 5127 | /* }}} */ 5128 | 5129 | /* {{{ proto bool HaruOutline::setOpened(bool opened) 5130 | Set the initial state of the outline */ 5131 | static PHP_METHOD(HaruOutline, setOpened) 5132 | { 5133 | php_haruoutline *outline = (php_haruoutline *)zend_object_store_get_object(getThis() TSRMLS_CC); 5134 | HPDF_STATUS status; 5135 | zend_bool opened; 5136 | 5137 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &opened) == FAILURE) { 5138 | return; 5139 | } 5140 | 5141 | status = HPDF_Outline_SetOpened(outline->h, (HPDF_BOOL)opened); 5142 | 5143 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5144 | return; 5145 | } 5146 | RETURN_TRUE; 5147 | } 5148 | /* }}} */ 5149 | 5150 | /* {{{ proto bool HaruOutline::setDestination(object destination) 5151 | Set the destination for the outline */ 5152 | static PHP_METHOD(HaruOutline, setDestination) 5153 | { 5154 | php_haruoutline *outline = (php_haruoutline *)zend_object_store_get_object(getThis() TSRMLS_CC); 5155 | php_harudestination *d; 5156 | HPDF_STATUS status; 5157 | zval *destination; 5158 | 5159 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &destination, ce_harudestination) == FAILURE) { 5160 | return; 5161 | } 5162 | 5163 | d = (php_harudestination *)zend_object_store_get_object(destination TSRMLS_CC); 5164 | 5165 | status = HPDF_Outline_SetDestination(outline->h, d->h); 5166 | 5167 | if (php_haru_status_to_exception(status TSRMLS_CC)) { 5168 | return; 5169 | } 5170 | RETURN_TRUE; 5171 | } 5172 | /* }}} */ 5173 | 5174 | /* }}} */ 5175 | 5176 | /* {{{ arginfo */ 5177 | ZEND_BEGIN_ARG_INFO(arginfo_harudoc___void, 0) 5178 | ZEND_END_ARG_INFO() 5179 | 5180 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_insertpage, 0, 0, 1) 5181 | ZEND_ARG_INFO(0, page) 5182 | ZEND_END_ARG_INFO() 5183 | 5184 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setcurrentencoder, 0, 0, 1) 5185 | ZEND_ARG_INFO(0, encoding) 5186 | ZEND_END_ARG_INFO() 5187 | 5188 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_save, 0, 0, 1) 5189 | ZEND_ARG_INFO(0, file) 5190 | ZEND_END_ARG_INFO() 5191 | 5192 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_readfromstream, 0, 0, 1) 5193 | ZEND_ARG_INFO(0, bytes) 5194 | ZEND_END_ARG_INFO() 5195 | 5196 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setpagelayout, 0, 0, 1) 5197 | ZEND_ARG_INFO(0, layout) 5198 | ZEND_END_ARG_INFO() 5199 | 5200 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setpagemode, 0, 0, 1) 5201 | ZEND_ARG_INFO(0, mode) 5202 | ZEND_END_ARG_INFO() 5203 | 5204 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setinfoattr, 0, 0, 2) 5205 | ZEND_ARG_INFO(0, type) 5206 | ZEND_ARG_INFO(0, info) 5207 | ZEND_END_ARG_INFO() 5208 | 5209 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_getinfoattr, 0, 0, 1) 5210 | ZEND_ARG_INFO(0, type) 5211 | ZEND_END_ARG_INFO() 5212 | 5213 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setinfodateattr, 0, 0, 10) 5214 | ZEND_ARG_INFO(0, type) 5215 | ZEND_ARG_INFO(0, year) 5216 | ZEND_ARG_INFO(0, month) 5217 | ZEND_ARG_INFO(0, day) 5218 | ZEND_ARG_INFO(0, hour) 5219 | ZEND_ARG_INFO(0, min) 5220 | ZEND_ARG_INFO(0, sec) 5221 | ZEND_ARG_INFO(0, ind) 5222 | ZEND_ARG_INFO(0, off_hour) 5223 | ZEND_ARG_INFO(0, off_min) 5224 | ZEND_END_ARG_INFO() 5225 | 5226 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_getfont, 0, 0, 1) 5227 | ZEND_ARG_INFO(0, fontname) 5228 | ZEND_ARG_INFO(0, encoding) 5229 | ZEND_END_ARG_INFO() 5230 | 5231 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_loadttf, 0, 0, 1) 5232 | ZEND_ARG_INFO(0, fontfile) 5233 | ZEND_ARG_INFO(0, embed) 5234 | ZEND_END_ARG_INFO() 5235 | 5236 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_loadttc, 0, 0, 2) 5237 | ZEND_ARG_INFO(0, fontfile) 5238 | ZEND_ARG_INFO(0, index) 5239 | ZEND_ARG_INFO(0, embed) 5240 | ZEND_END_ARG_INFO() 5241 | 5242 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_loadtype1, 0, 0, 1) 5243 | ZEND_ARG_INFO(0, afmfile) 5244 | ZEND_ARG_INFO(0, pfmfile) 5245 | ZEND_END_ARG_INFO() 5246 | 5247 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_loadpng, 0, 0, 1) 5248 | ZEND_ARG_INFO(0, filename) 5249 | ZEND_ARG_INFO(0, deferred) 5250 | ZEND_END_ARG_INFO() 5251 | 5252 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_loadjpeg, 0, 0, 1) 5253 | ZEND_ARG_INFO(0, filename) 5254 | ZEND_END_ARG_INFO() 5255 | 5256 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_loadraw, 0, 0, 4) 5257 | ZEND_ARG_INFO(0, filename) 5258 | ZEND_ARG_INFO(0, width) 5259 | ZEND_ARG_INFO(0, height) 5260 | ZEND_ARG_INFO(0, color_space) 5261 | ZEND_END_ARG_INFO() 5262 | 5263 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setpassword, 0, 0, 2) 5264 | ZEND_ARG_INFO(0, owner_password) 5265 | ZEND_ARG_INFO(0, user_password) 5266 | ZEND_END_ARG_INFO() 5267 | 5268 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setpermission, 0, 0, 1) 5269 | ZEND_ARG_INFO(0, permission) 5270 | ZEND_END_ARG_INFO() 5271 | 5272 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setencryptionmode, 0, 0, 1) 5273 | ZEND_ARG_INFO(0, mode) 5274 | ZEND_ARG_INFO(0, key_len) 5275 | ZEND_END_ARG_INFO() 5276 | 5277 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setcompressionmode, 0, 0, 1) 5278 | ZEND_ARG_INFO(0, mode) 5279 | ZEND_END_ARG_INFO() 5280 | 5281 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setpagesconfiguration, 0, 0, 1) 5282 | ZEND_ARG_INFO(0, page_per_pages) 5283 | ZEND_END_ARG_INFO() 5284 | 5285 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_setopenaction, 0, 0, 1) 5286 | ZEND_ARG_INFO(0, destination) 5287 | ZEND_END_ARG_INFO() 5288 | 5289 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_createoutline, 0, 0, 1) 5290 | ZEND_ARG_INFO(0, title) 5291 | ZEND_ARG_INFO(0, parent_outline) 5292 | ZEND_ARG_INFO(0, encoder) 5293 | ZEND_END_ARG_INFO() 5294 | 5295 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudoc_addpagelabel, 0, 0, 3) 5296 | ZEND_ARG_INFO(0, first_page) 5297 | ZEND_ARG_INFO(0, style) 5298 | ZEND_ARG_INFO(0, first_num) 5299 | ZEND_ARG_INFO(0, prefix) 5300 | ZEND_END_ARG_INFO() 5301 | 5302 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_drawimage, 0, 0, 5) 5303 | ZEND_ARG_INFO(0, image) 5304 | ZEND_ARG_INFO(0, x) 5305 | ZEND_ARG_INFO(0, y) 5306 | ZEND_ARG_INFO(0, width) 5307 | ZEND_ARG_INFO(0, height) 5308 | ZEND_END_ARG_INFO() 5309 | 5310 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setlinewidth, 0, 0, 1) 5311 | ZEND_ARG_INFO(0, width) 5312 | ZEND_END_ARG_INFO() 5313 | 5314 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setlinecap, 0, 0, 1) 5315 | ZEND_ARG_INFO(0, cap) 5316 | ZEND_END_ARG_INFO() 5317 | 5318 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setlinejoin, 0, 0, 1) 5319 | ZEND_ARG_INFO(0, join) 5320 | ZEND_END_ARG_INFO() 5321 | 5322 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setmiterlimit, 0, 0, 1) 5323 | ZEND_ARG_INFO(0, limit) 5324 | ZEND_END_ARG_INFO() 5325 | 5326 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setdash, 0, 0, 2) 5327 | ZEND_ARG_INFO(0, pattern) 5328 | ZEND_ARG_INFO(0, phase) 5329 | ZEND_END_ARG_INFO() 5330 | 5331 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setflatness, 0, 0, 1) 5332 | ZEND_ARG_INFO(0, flatness) 5333 | ZEND_END_ARG_INFO() 5334 | 5335 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setfontandsize, 0, 0, 2) 5336 | ZEND_ARG_INFO(0, font) 5337 | ZEND_ARG_INFO(0, size) 5338 | ZEND_END_ARG_INFO() 5339 | 5340 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setcharspace, 0, 0, 1) 5341 | ZEND_ARG_INFO(0, char_space) 5342 | ZEND_END_ARG_INFO() 5343 | 5344 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setwordspace, 0, 0, 1) 5345 | ZEND_ARG_INFO(0, word_space) 5346 | ZEND_END_ARG_INFO() 5347 | 5348 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_sethorizontalscaling, 0, 0, 1) 5349 | ZEND_ARG_INFO(0, scaling) 5350 | ZEND_END_ARG_INFO() 5351 | 5352 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_settextleading, 0, 0, 1) 5353 | ZEND_ARG_INFO(0, text_leading) 5354 | ZEND_END_ARG_INFO() 5355 | 5356 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_settextrenderingmode, 0, 0, 1) 5357 | ZEND_ARG_INFO(0, mode) 5358 | ZEND_END_ARG_INFO() 5359 | 5360 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_settextrise, 0, 0, 1) 5361 | ZEND_ARG_INFO(0, rise) 5362 | ZEND_END_ARG_INFO() 5363 | 5364 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setgraystroke, 0, 0, 1) 5365 | ZEND_ARG_INFO(0, value) 5366 | ZEND_END_ARG_INFO() 5367 | 5368 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setrgbstroke, 0, 0, 3) 5369 | ZEND_ARG_INFO(0, r) 5370 | ZEND_ARG_INFO(0, g) 5371 | ZEND_ARG_INFO(0, b) 5372 | ZEND_END_ARG_INFO() 5373 | 5374 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setcmykstroke, 0, 0, 4) 5375 | ZEND_ARG_INFO(0, c) 5376 | ZEND_ARG_INFO(0, m) 5377 | ZEND_ARG_INFO(0, y) 5378 | ZEND_ARG_INFO(0, k) 5379 | ZEND_END_ARG_INFO() 5380 | 5381 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_concat, 0, 0, 6) 5382 | ZEND_ARG_INFO(0, a) 5383 | ZEND_ARG_INFO(0, b) 5384 | ZEND_ARG_INFO(0, c) 5385 | ZEND_ARG_INFO(0, d) 5386 | ZEND_ARG_INFO(0, x) 5387 | ZEND_ARG_INFO(0, y) 5388 | ZEND_END_ARG_INFO() 5389 | 5390 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_settextmatrix, 0, 0, 6) 5391 | ZEND_ARG_INFO(0, a) 5392 | ZEND_ARG_INFO(0, b) 5393 | ZEND_ARG_INFO(0, c) 5394 | ZEND_ARG_INFO(0, d) 5395 | ZEND_ARG_INFO(0, x) 5396 | ZEND_ARG_INFO(0, y) 5397 | ZEND_END_ARG_INFO() 5398 | 5399 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_moveto, 0, 0, 2) 5400 | ZEND_ARG_INFO(0, x) 5401 | ZEND_ARG_INFO(0, y) 5402 | ZEND_END_ARG_INFO() 5403 | 5404 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_stroke, 0, 0, 0) 5405 | ZEND_ARG_INFO(0, close_path) 5406 | ZEND_END_ARG_INFO() 5407 | 5408 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_fillstroke, 0, 0, 0) 5409 | ZEND_ARG_INFO(0, close_path) 5410 | ZEND_END_ARG_INFO() 5411 | 5412 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_eofillstroke, 0, 0, 0) 5413 | ZEND_ARG_INFO(0, close_path) 5414 | ZEND_END_ARG_INFO() 5415 | 5416 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_lineto, 0, 0, 2) 5417 | ZEND_ARG_INFO(0, x) 5418 | ZEND_ARG_INFO(0, y) 5419 | ZEND_END_ARG_INFO() 5420 | 5421 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_curveto, 0, 0, 6) 5422 | ZEND_ARG_INFO(0, x1) 5423 | ZEND_ARG_INFO(0, y1) 5424 | ZEND_ARG_INFO(0, x2) 5425 | ZEND_ARG_INFO(0, y2) 5426 | ZEND_ARG_INFO(0, x3) 5427 | ZEND_ARG_INFO(0, y3) 5428 | ZEND_END_ARG_INFO() 5429 | 5430 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_curveto2, 0, 0, 4) 5431 | ZEND_ARG_INFO(0, x2) 5432 | ZEND_ARG_INFO(0, y2) 5433 | ZEND_ARG_INFO(0, x3) 5434 | ZEND_ARG_INFO(0, y3) 5435 | ZEND_END_ARG_INFO() 5436 | 5437 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_curveto3, 0, 0, 4) 5438 | ZEND_ARG_INFO(0, x1) 5439 | ZEND_ARG_INFO(0, y1) 5440 | ZEND_ARG_INFO(0, x3) 5441 | ZEND_ARG_INFO(0, y3) 5442 | ZEND_END_ARG_INFO() 5443 | 5444 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_rectangle, 0, 0, 4) 5445 | ZEND_ARG_INFO(0, x) 5446 | ZEND_ARG_INFO(0, y) 5447 | ZEND_ARG_INFO(0, width) 5448 | ZEND_ARG_INFO(0, height) 5449 | ZEND_END_ARG_INFO() 5450 | 5451 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_arc, 0, 0, 5) 5452 | ZEND_ARG_INFO(0, x) 5453 | ZEND_ARG_INFO(0, y) 5454 | ZEND_ARG_INFO(0, ray) 5455 | ZEND_ARG_INFO(0, ang1) 5456 | ZEND_ARG_INFO(0, ang2) 5457 | ZEND_END_ARG_INFO() 5458 | 5459 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_circle, 0, 0, 3) 5460 | ZEND_ARG_INFO(0, x) 5461 | ZEND_ARG_INFO(0, y) 5462 | ZEND_ARG_INFO(0, ray) 5463 | ZEND_END_ARG_INFO() 5464 | 5465 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_ellipse, 0, 0, 4) 5466 | ZEND_ARG_INFO(0, x) 5467 | ZEND_ARG_INFO(0, y) 5468 | ZEND_ARG_INFO(0, xray) 5469 | ZEND_ARG_INFO(0, yray) 5470 | ZEND_END_ARG_INFO() 5471 | 5472 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_showtext, 0, 0, 1) 5473 | ZEND_ARG_INFO(0, text) 5474 | ZEND_END_ARG_INFO() 5475 | 5476 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_showtextnextline, 0, 0, 1) 5477 | ZEND_ARG_INFO(0, text) 5478 | ZEND_END_ARG_INFO() 5479 | 5480 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_textout, 0, 0, 3) 5481 | ZEND_ARG_INFO(0, x) 5482 | ZEND_ARG_INFO(0, y) 5483 | ZEND_ARG_INFO(0, text) 5484 | ZEND_END_ARG_INFO() 5485 | 5486 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_textrect, 0, 0, 5) 5487 | ZEND_ARG_INFO(0, left) 5488 | ZEND_ARG_INFO(0, top) 5489 | ZEND_ARG_INFO(0, right) 5490 | ZEND_ARG_INFO(0, bottom) 5491 | ZEND_ARG_INFO(0, text) 5492 | ZEND_ARG_INFO(0, align) 5493 | ZEND_END_ARG_INFO() 5494 | 5495 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_movetextpos, 0, 0, 2) 5496 | ZEND_ARG_INFO(0, x) 5497 | ZEND_ARG_INFO(0, y) 5498 | ZEND_ARG_INFO(0, set_leading) 5499 | ZEND_END_ARG_INFO() 5500 | 5501 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setwidth, 0, 0, 1) 5502 | ZEND_ARG_INFO(0, width) 5503 | ZEND_END_ARG_INFO() 5504 | 5505 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setheight, 0, 0, 1) 5506 | ZEND_ARG_INFO(0, height) 5507 | ZEND_END_ARG_INFO() 5508 | 5509 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setsize, 0, 0, 2) 5510 | ZEND_ARG_INFO(0, size) 5511 | ZEND_ARG_INFO(0, direction) 5512 | ZEND_END_ARG_INFO() 5513 | 5514 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setrotate, 0, 0, 1) 5515 | ZEND_ARG_INFO(0, angle) 5516 | ZEND_END_ARG_INFO() 5517 | 5518 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_createtextannotation, 0, 0, 2) 5519 | ZEND_ARG_INFO(0, rectangle) 5520 | ZEND_ARG_INFO(0, text) 5521 | ZEND_ARG_INFO(0, encoder) 5522 | ZEND_END_ARG_INFO() 5523 | 5524 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_createlinkannotation, 0, 0, 2) 5525 | ZEND_ARG_INFO(0, rectangle) 5526 | ZEND_ARG_INFO(0, destination) 5527 | ZEND_END_ARG_INFO() 5528 | 5529 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_createurlannotation, 0, 0, 2) 5530 | ZEND_ARG_INFO(0, rectangle) 5531 | ZEND_ARG_INFO(0, url) 5532 | ZEND_END_ARG_INFO() 5533 | 5534 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_gettextwidth, 0, 0, 1) 5535 | ZEND_ARG_INFO(0, text) 5536 | ZEND_END_ARG_INFO() 5537 | 5538 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_measuretext, 0, 0, 2) 5539 | ZEND_ARG_INFO(0, text) 5540 | ZEND_ARG_INFO(0, width) 5541 | ZEND_ARG_INFO(0, wordwrap) 5542 | ZEND_END_ARG_INFO() 5543 | 5544 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setslideshow, 0, 0, 3) 5545 | ZEND_ARG_INFO(0, type) 5546 | ZEND_ARG_INFO(0, disp_time) 5547 | ZEND_ARG_INFO(0, trans_time) 5548 | ZEND_END_ARG_INFO() 5549 | 5550 | #if defined(HPDF_VERSION_ID) && HPDF_VERSION_ID >= 20200 5551 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harupage_setzoom, 0, 0, 1) 5552 | ZEND_ARG_INFO(0, zoom) 5553 | ZEND_END_ARG_INFO() 5554 | #endif 5555 | 5556 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruimage_setcolormask, 0, 0, 6) 5557 | ZEND_ARG_INFO(0, rmin) 5558 | ZEND_ARG_INFO(0, rmax) 5559 | ZEND_ARG_INFO(0, gmin) 5560 | ZEND_ARG_INFO(0, gmax) 5561 | ZEND_ARG_INFO(0, bmin) 5562 | ZEND_ARG_INFO(0, bmax) 5563 | ZEND_END_ARG_INFO() 5564 | 5565 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruimage_setmaskimage, 0, 0, 1) 5566 | ZEND_ARG_INFO(0, mask_image) 5567 | ZEND_END_ARG_INFO() 5568 | 5569 | #if defined(HPDF_VERSION_ID) && HPDF_VERSION_ID >= 20200 5570 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruimage_addsmask, 0, 0, 1) 5571 | ZEND_ARG_INFO(0, smask_image) 5572 | ZEND_END_ARG_INFO() 5573 | #endif 5574 | 5575 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harufont_getunicodewidth, 0, 0, 1) 5576 | ZEND_ARG_INFO(0, character) 5577 | ZEND_END_ARG_INFO() 5578 | 5579 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harufont_gettextwidth, 0, 0, 1) 5580 | ZEND_ARG_INFO(0, text) 5581 | ZEND_END_ARG_INFO() 5582 | 5583 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harufont_measuretext, 0, 0, 5) 5584 | ZEND_ARG_INFO(0, text) 5585 | ZEND_ARG_INFO(0, width) 5586 | ZEND_ARG_INFO(0, font_size) 5587 | ZEND_ARG_INFO(0, char_space) 5588 | ZEND_ARG_INFO(0, word_space) 5589 | ZEND_ARG_INFO(0, word_wrap) 5590 | ZEND_END_ARG_INFO() 5591 | 5592 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruencoder_getbytetype, 0, 0, 2) 5593 | ZEND_ARG_INFO(0, text) 5594 | ZEND_ARG_INFO(0, index) 5595 | ZEND_END_ARG_INFO() 5596 | 5597 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruencoder_getunicode, 0, 0, 1) 5598 | ZEND_ARG_INFO(0, character) 5599 | ZEND_END_ARG_INFO() 5600 | 5601 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruannotation_sethighlightmode, 0, 0, 1) 5602 | ZEND_ARG_INFO(0, mode) 5603 | ZEND_END_ARG_INFO() 5604 | 5605 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruannotation_setborderstyle, 0, 0, 3) 5606 | ZEND_ARG_INFO(0, width) 5607 | ZEND_ARG_INFO(0, dash_on) 5608 | ZEND_ARG_INFO(0, dash_off) 5609 | ZEND_END_ARG_INFO() 5610 | 5611 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruannotation_seticon, 0, 0, 1) 5612 | ZEND_ARG_INFO(0, icon) 5613 | ZEND_END_ARG_INFO() 5614 | 5615 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruannotation_setopened, 0, 0, 1) 5616 | ZEND_ARG_INFO(0, opened) 5617 | ZEND_END_ARG_INFO() 5618 | 5619 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudestination_setxyz, 0, 0, 3) 5620 | ZEND_ARG_INFO(0, left) 5621 | ZEND_ARG_INFO(0, top) 5622 | ZEND_ARG_INFO(0, zoom) 5623 | ZEND_END_ARG_INFO() 5624 | 5625 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudestination_setfith, 0, 0, 1) 5626 | ZEND_ARG_INFO(0, top) 5627 | ZEND_END_ARG_INFO() 5628 | 5629 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudestination_setfitv, 0, 0, 1) 5630 | ZEND_ARG_INFO(0, left) 5631 | ZEND_END_ARG_INFO() 5632 | 5633 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudestination_setfitr, 0, 0, 4) 5634 | ZEND_ARG_INFO(0, left) 5635 | ZEND_ARG_INFO(0, bottom) 5636 | ZEND_ARG_INFO(0, right) 5637 | ZEND_ARG_INFO(0, top) 5638 | ZEND_END_ARG_INFO() 5639 | 5640 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudestination_setfitbh, 0, 0, 1) 5641 | ZEND_ARG_INFO(0, top) 5642 | ZEND_END_ARG_INFO() 5643 | 5644 | ZEND_BEGIN_ARG_INFO_EX(arginfo_harudestination_setfitbv, 0, 0, 1) 5645 | ZEND_ARG_INFO(0, left) 5646 | ZEND_END_ARG_INFO() 5647 | 5648 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruoutline_setopened, 0, 0, 1) 5649 | ZEND_ARG_INFO(0, opened) 5650 | ZEND_END_ARG_INFO() 5651 | 5652 | ZEND_BEGIN_ARG_INFO_EX(arginfo_haruoutline_setdestination, 0, 0, 1) 5653 | ZEND_ARG_INFO(0, destination) 5654 | ZEND_END_ARG_INFO() 5655 | /* }}} */ 5656 | 5657 | 5658 | /* class method tables {{{ */ 5659 | 5660 | static zend_function_entry harudoc_methods[] = { /* {{{ */ 5661 | PHP_ME(HaruDoc, __construct, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5662 | PHP_ME(HaruDoc, resetError, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5663 | PHP_ME(HaruDoc, save, arginfo_harudoc_save, ZEND_ACC_PUBLIC) 5664 | PHP_ME(HaruDoc, output, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5665 | PHP_ME(HaruDoc, saveToStream, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5666 | PHP_ME(HaruDoc, resetStream, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5667 | PHP_ME(HaruDoc, getStreamSize, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5668 | PHP_ME(HaruDoc, readFromStream, arginfo_harudoc_readfromstream, ZEND_ACC_PUBLIC) 5669 | PHP_ME(HaruDoc, addPage, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5670 | PHP_ME(HaruDoc, insertPage, arginfo_harudoc_insertpage, ZEND_ACC_PUBLIC) 5671 | PHP_ME(HaruDoc, getCurrentPage, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5672 | PHP_ME(HaruDoc, getEncoder, arginfo_harudoc_setcurrentencoder, ZEND_ACC_PUBLIC) 5673 | PHP_ME(HaruDoc, getCurrentEncoder, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5674 | PHP_ME(HaruDoc, setCurrentEncoder, arginfo_harudoc_setcurrentencoder, ZEND_ACC_PUBLIC) 5675 | PHP_ME(HaruDoc, setPageLayout, arginfo_harudoc_setpagelayout, ZEND_ACC_PUBLIC) 5676 | PHP_ME(HaruDoc, getPageLayout, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5677 | PHP_ME(HaruDoc, setPageMode, arginfo_harudoc_setpagemode, ZEND_ACC_PUBLIC) 5678 | PHP_ME(HaruDoc, getPageMode, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5679 | PHP_ME(HaruDoc, setInfoAttr, arginfo_harudoc_setinfoattr, ZEND_ACC_PUBLIC) 5680 | PHP_ME(HaruDoc, setInfoDateAttr, arginfo_harudoc_setinfodateattr, ZEND_ACC_PUBLIC) 5681 | PHP_ME(HaruDoc, getInfoAttr, arginfo_harudoc_getinfoattr, ZEND_ACC_PUBLIC) 5682 | PHP_ME(HaruDoc, getFont, arginfo_harudoc_getfont, ZEND_ACC_PUBLIC) 5683 | PHP_ME(HaruDoc, loadTTF, arginfo_harudoc_loadttf, ZEND_ACC_PUBLIC) 5684 | PHP_ME(HaruDoc, loadTTC, arginfo_harudoc_loadttc, ZEND_ACC_PUBLIC) 5685 | PHP_ME(HaruDoc, loadType1, arginfo_harudoc_loadtype1, ZEND_ACC_PUBLIC) 5686 | PHP_ME(HaruDoc, loadPNG, arginfo_harudoc_loadpng, ZEND_ACC_PUBLIC) 5687 | PHP_ME(HaruDoc, loadJPEG, arginfo_harudoc_loadjpeg, ZEND_ACC_PUBLIC) 5688 | PHP_ME(HaruDoc, loadRaw, arginfo_harudoc_loadraw, ZEND_ACC_PUBLIC) 5689 | PHP_ME(HaruDoc, setPassword, arginfo_harudoc_setpassword, ZEND_ACC_PUBLIC) 5690 | PHP_ME(HaruDoc, setPermission, arginfo_harudoc_setpermission, ZEND_ACC_PUBLIC) 5691 | PHP_ME(HaruDoc, setEncryptionMode, arginfo_harudoc_setencryptionmode, ZEND_ACC_PUBLIC) 5692 | PHP_ME(HaruDoc, setCompressionMode, arginfo_harudoc_setcompressionmode, ZEND_ACC_PUBLIC) 5693 | PHP_ME(HaruDoc, setPagesConfiguration, arginfo_harudoc_setpagesconfiguration, ZEND_ACC_PUBLIC) 5694 | PHP_ME(HaruDoc, setOpenAction, arginfo_harudoc_setopenaction, ZEND_ACC_PUBLIC) 5695 | PHP_ME(HaruDoc, createOutline, arginfo_harudoc_createoutline, ZEND_ACC_PUBLIC) 5696 | PHP_ME(HaruDoc, addPageLabel, arginfo_harudoc_addpagelabel, ZEND_ACC_PUBLIC) 5697 | PHP_ME(HaruDoc, useJPFonts, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5698 | PHP_ME(HaruDoc, useJPEncodings, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5699 | PHP_ME(HaruDoc, useKRFonts, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5700 | PHP_ME(HaruDoc, useKREncodings, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5701 | PHP_ME(HaruDoc, useCNSFonts, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5702 | PHP_ME(HaruDoc, useCNSEncodings, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5703 | PHP_ME(HaruDoc, useCNTFonts, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5704 | PHP_ME(HaruDoc, useCNTEncodings, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5705 | PHP_ME(HaruDoc, useUTFEncodings, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5706 | {NULL, NULL, NULL} 5707 | }; 5708 | 5709 | /* }}} */ 5710 | 5711 | static zend_function_entry harupage_methods[] = { /* {{{ */ 5712 | PHP_ME(HaruPage, __construct, arginfo_harudoc___void, ZEND_ACC_PRIVATE) 5713 | PHP_ME(HaruPage, drawImage, arginfo_harupage_drawimage, ZEND_ACC_PUBLIC) 5714 | PHP_ME(HaruPage, setLineWidth, arginfo_harupage_setlinewidth, ZEND_ACC_PUBLIC) 5715 | PHP_ME(HaruPage, setLineCap, arginfo_harupage_setlinecap, ZEND_ACC_PUBLIC) 5716 | PHP_ME(HaruPage, setLineJoin, arginfo_harupage_setlinejoin, ZEND_ACC_PUBLIC) 5717 | PHP_ME(HaruPage, setMiterLimit, arginfo_harupage_setmiterlimit, ZEND_ACC_PUBLIC) 5718 | PHP_ME(HaruPage, setFlatness, arginfo_harupage_setflatness, ZEND_ACC_PUBLIC) 5719 | PHP_ME(HaruPage, setDash, arginfo_harupage_setdash, ZEND_ACC_PUBLIC) 5720 | PHP_ME(HaruPage, Concat, arginfo_harupage_concat, ZEND_ACC_PUBLIC) 5721 | PHP_ME(HaruPage, getTransMatrix, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5722 | PHP_ME(HaruPage, setTextMatrix, arginfo_harupage_settextmatrix, ZEND_ACC_PUBLIC) 5723 | PHP_ME(HaruPage, getTextMatrix, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5724 | PHP_ME(HaruPage, moveTo, arginfo_harupage_moveto, ZEND_ACC_PUBLIC) 5725 | PHP_ME(HaruPage, stroke, arginfo_harupage_stroke, ZEND_ACC_PUBLIC) 5726 | PHP_ME(HaruPage, fill, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5727 | PHP_ME(HaruPage, eofill, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5728 | PHP_ME(HaruPage, lineTo, arginfo_harupage_lineto, ZEND_ACC_PUBLIC) 5729 | PHP_ME(HaruPage, curveTo, arginfo_harupage_curveto, ZEND_ACC_PUBLIC) 5730 | PHP_ME(HaruPage, curveTo2, arginfo_harupage_curveto2, ZEND_ACC_PUBLIC) 5731 | PHP_ME(HaruPage, curveTo3, arginfo_harupage_curveto3, ZEND_ACC_PUBLIC) 5732 | PHP_ME(HaruPage, rectangle, arginfo_harupage_rectangle, ZEND_ACC_PUBLIC) 5733 | PHP_ME(HaruPage, arc, arginfo_harupage_arc, ZEND_ACC_PUBLIC) 5734 | PHP_ME(HaruPage, circle, arginfo_harupage_circle, ZEND_ACC_PUBLIC) 5735 | PHP_ME(HaruPage, showText, arginfo_harupage_showtext, ZEND_ACC_PUBLIC) 5736 | PHP_ME(HaruPage, showTextNextLine, arginfo_harupage_showtextnextline, ZEND_ACC_PUBLIC) 5737 | PHP_ME(HaruPage, textOut, arginfo_harupage_textout, ZEND_ACC_PUBLIC) 5738 | PHP_ME(HaruPage, beginText, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5739 | PHP_ME(HaruPage, endText, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5740 | PHP_ME(HaruPage, setFontAndSize, arginfo_harupage_setfontandsize, ZEND_ACC_PUBLIC) 5741 | PHP_ME(HaruPage, setCharSpace, arginfo_harupage_setcharspace, ZEND_ACC_PUBLIC) 5742 | PHP_ME(HaruPage, setWordSpace, arginfo_harupage_setwordspace, ZEND_ACC_PUBLIC) 5743 | PHP_ME(HaruPage, setHorizontalScaling, arginfo_harupage_sethorizontalscaling, ZEND_ACC_PUBLIC) 5744 | PHP_ME(HaruPage, setTextLeading, arginfo_harupage_settextleading, ZEND_ACC_PUBLIC) 5745 | PHP_ME(HaruPage, setTextRenderingMode, arginfo_harupage_settextrenderingmode, ZEND_ACC_PUBLIC) 5746 | PHP_ME(HaruPage, setTextRise, arginfo_harupage_settextrise, ZEND_ACC_PUBLIC) 5747 | PHP_ME(HaruPage, moveTextPos, arginfo_harupage_movetextpos, ZEND_ACC_PUBLIC) 5748 | PHP_ME(HaruPage, fillStroke, arginfo_harupage_fillstroke, ZEND_ACC_PUBLIC) 5749 | PHP_ME(HaruPage, eoFillStroke, arginfo_harupage_eofillstroke, ZEND_ACC_PUBLIC) 5750 | PHP_ME(HaruPage, closePath, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5751 | PHP_ME(HaruPage, endPath, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5752 | PHP_ME(HaruPage, ellipse, arginfo_harupage_ellipse, ZEND_ACC_PUBLIC) 5753 | PHP_ME(HaruPage, textRect, arginfo_harupage_textrect, ZEND_ACC_PUBLIC) 5754 | PHP_ME(HaruPage, moveToNextLine, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5755 | PHP_ME(HaruPage, setGrayFill, arginfo_harupage_setgraystroke, ZEND_ACC_PUBLIC) 5756 | PHP_ME(HaruPage, setGrayStroke, arginfo_harupage_setgraystroke, ZEND_ACC_PUBLIC) 5757 | PHP_ME(HaruPage, setRGBFill, arginfo_harupage_setrgbstroke, ZEND_ACC_PUBLIC) 5758 | PHP_ME(HaruPage, setRGBStroke, arginfo_harupage_setrgbstroke, ZEND_ACC_PUBLIC) 5759 | PHP_ME(HaruPage, setCMYKFill, arginfo_harupage_setcmykstroke, ZEND_ACC_PUBLIC) 5760 | PHP_ME(HaruPage, setCMYKStroke, arginfo_harupage_setcmykstroke, ZEND_ACC_PUBLIC) 5761 | PHP_ME(HaruPage, setWidth, arginfo_harupage_setwidth, ZEND_ACC_PUBLIC) 5762 | PHP_ME(HaruPage, setHeight, arginfo_harupage_setheight, ZEND_ACC_PUBLIC) 5763 | PHP_ME(HaruPage, setSize, arginfo_harupage_setsize, ZEND_ACC_PUBLIC) 5764 | PHP_ME(HaruPage, setRotate, arginfo_harupage_setrotate, ZEND_ACC_PUBLIC) 5765 | PHP_ME(HaruPage, getWidth, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5766 | PHP_ME(HaruPage, getHeight, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5767 | PHP_ME(HaruPage, createDestination, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5768 | PHP_ME(HaruPage, createTextAnnotation, arginfo_harupage_createtextannotation, ZEND_ACC_PUBLIC) 5769 | PHP_ME(HaruPage, createLinkAnnotation, arginfo_harupage_createlinkannotation, ZEND_ACC_PUBLIC) 5770 | PHP_ME(HaruPage, createURLAnnotation, arginfo_harupage_createurlannotation, ZEND_ACC_PUBLIC) 5771 | PHP_ME(HaruPage, getTextWidth, arginfo_harupage_gettextwidth, ZEND_ACC_PUBLIC) 5772 | PHP_ME(HaruPage, MeasureText, arginfo_harupage_measuretext, ZEND_ACC_PUBLIC) 5773 | PHP_ME(HaruPage, getGMode, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5774 | PHP_ME(HaruPage, getCurrentPos, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5775 | PHP_ME(HaruPage, getCurrentTextPos, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5776 | PHP_ME(HaruPage, getCurrentFont, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5777 | PHP_ME(HaruPage, getCurrentFontSize, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5778 | PHP_ME(HaruPage, getLineWidth, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5779 | PHP_ME(HaruPage, getLineCap, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5780 | PHP_ME(HaruPage, getLineJoin, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5781 | PHP_ME(HaruPage, getMiterLimit, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5782 | PHP_ME(HaruPage, getDash, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5783 | PHP_ME(HaruPage, getFlatness, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5784 | PHP_ME(HaruPage, getCharSpace, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5785 | PHP_ME(HaruPage, getWordSpace, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5786 | PHP_ME(HaruPage, getHorizontalScaling, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5787 | PHP_ME(HaruPage, getTextLeading, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5788 | PHP_ME(HaruPage, getTextRenderingMode, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5789 | PHP_ME(HaruPage, getTextRise, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5790 | PHP_ME(HaruPage, getRGBFill, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5791 | PHP_ME(HaruPage, getRGBStroke, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5792 | PHP_ME(HaruPage, getCMYKFill, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5793 | PHP_ME(HaruPage, getCMYKStroke, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5794 | PHP_ME(HaruPage, getGrayFill, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5795 | PHP_ME(HaruPage, getGrayStroke, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5796 | PHP_ME(HaruPage, getFillingColorSpace, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5797 | PHP_ME(HaruPage, getStrokingColorSpace, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5798 | PHP_ME(HaruPage, setSlideShow, arginfo_harupage_setslideshow, ZEND_ACC_PUBLIC) 5799 | PHP_ME(HaruPage, clip, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5800 | PHP_ME(HaruPage, saveGS, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5801 | PHP_ME(HaruPage, restoreGS, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5802 | #if defined(HPDF_VERSION_ID) && HPDF_VERSION_ID >= 20200 5803 | PHP_ME(HaruPage, setZoom, arginfo_harupage_setzoom, ZEND_ACC_PUBLIC) 5804 | #endif 5805 | {NULL, NULL, NULL} 5806 | }; 5807 | 5808 | /* }}} */ 5809 | 5810 | static zend_function_entry harufont_methods[] = { /* {{{ */ 5811 | PHP_ME(HaruFont, __construct, arginfo_harudoc___void, ZEND_ACC_PRIVATE) 5812 | PHP_ME(HaruFont, getFontName, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5813 | PHP_ME(HaruFont, getEncodingName, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5814 | PHP_ME(HaruFont, getUnicodeWidth, arginfo_harufont_getunicodewidth, ZEND_ACC_PUBLIC) 5815 | PHP_ME(HaruFont, getAscent, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5816 | PHP_ME(HaruFont, getDescent, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5817 | PHP_ME(HaruFont, getXHeight, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5818 | PHP_ME(HaruFont, getCapHeight, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5819 | PHP_ME(HaruFont, getTextWidth, arginfo_harufont_gettextwidth, ZEND_ACC_PUBLIC) 5820 | PHP_ME(HaruFont, MeasureText, arginfo_harufont_measuretext, ZEND_ACC_PUBLIC) 5821 | {NULL, NULL, NULL} 5822 | }; 5823 | 5824 | /* }}} */ 5825 | 5826 | static zend_function_entry haruimage_methods[] = { /* {{{ */ 5827 | PHP_ME(HaruImage, __construct, arginfo_harudoc___void, ZEND_ACC_PRIVATE) 5828 | PHP_ME(HaruImage, getSize, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5829 | PHP_ME(HaruImage, getWidth, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5830 | PHP_ME(HaruImage, getHeight, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5831 | PHP_ME(HaruImage, getBitsPerComponent, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5832 | PHP_ME(HaruImage, getColorSpace, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5833 | PHP_ME(HaruImage, setColorMask, arginfo_haruimage_setcolormask, ZEND_ACC_PUBLIC) 5834 | PHP_ME(HaruImage, setMaskImage, arginfo_haruimage_setmaskimage, ZEND_ACC_PUBLIC) 5835 | #if defined(HPDF_VERSION_ID) && HPDF_VERSION_ID >= 20200 5836 | PHP_ME(HaruImage, addSMask, arginfo_haruimage_addsmask, ZEND_ACC_PUBLIC) 5837 | #endif 5838 | {NULL, NULL, NULL} 5839 | }; 5840 | 5841 | /* }}} */ 5842 | 5843 | static zend_function_entry harudestination_methods[] = { /* {{{ */ 5844 | PHP_ME(HaruDestination, __construct, arginfo_harudoc___void, ZEND_ACC_PRIVATE) 5845 | PHP_ME(HaruDestination, setXYZ, arginfo_harudestination_setxyz, ZEND_ACC_PUBLIC) 5846 | PHP_ME(HaruDestination, setFit, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5847 | PHP_ME(HaruDestination, setFitH, arginfo_harudestination_setfith, ZEND_ACC_PUBLIC) 5848 | PHP_ME(HaruDestination, setFitV, arginfo_harudestination_setfitv, ZEND_ACC_PUBLIC) 5849 | PHP_ME(HaruDestination, setFitR, arginfo_harudestination_setfitr, ZEND_ACC_PUBLIC) 5850 | PHP_ME(HaruDestination, setFitB, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5851 | PHP_ME(HaruDestination, setFitBH, arginfo_harudestination_setfitbh, ZEND_ACC_PUBLIC) 5852 | PHP_ME(HaruDestination, setFitBV, arginfo_harudestination_setfitbv, ZEND_ACC_PUBLIC) 5853 | {NULL, NULL, NULL} 5854 | }; 5855 | 5856 | /* }}} */ 5857 | 5858 | static zend_function_entry haruannotation_methods[] = { /* {{{ */ 5859 | PHP_ME(HaruAnnotation, __construct, arginfo_harudoc___void, ZEND_ACC_PRIVATE) 5860 | PHP_ME(HaruAnnotation, setHighlightMode, arginfo_haruannotation_sethighlightmode, ZEND_ACC_PUBLIC) 5861 | PHP_ME(HaruAnnotation, setBorderStyle, arginfo_haruannotation_setborderstyle, ZEND_ACC_PUBLIC) 5862 | PHP_ME(HaruAnnotation, setIcon, arginfo_haruannotation_seticon, ZEND_ACC_PUBLIC) 5863 | PHP_ME(HaruAnnotation, setOpened, arginfo_haruannotation_setopened, ZEND_ACC_PUBLIC) 5864 | {NULL, NULL, NULL} 5865 | }; 5866 | 5867 | /* }}} */ 5868 | 5869 | static zend_function_entry haruencoder_methods[] = { /* {{{ */ 5870 | PHP_ME(HaruEncoder, __construct, arginfo_harudoc___void, ZEND_ACC_PRIVATE) 5871 | PHP_ME(HaruEncoder, getType, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5872 | PHP_ME(HaruEncoder, getByteType, arginfo_haruencoder_getbytetype, ZEND_ACC_PUBLIC) 5873 | PHP_ME(HaruEncoder, getUnicode, arginfo_haruencoder_getunicode, ZEND_ACC_PUBLIC) 5874 | PHP_ME(HaruEncoder, getWritingMode, arginfo_harudoc___void, ZEND_ACC_PUBLIC) 5875 | {NULL, NULL, NULL} 5876 | }; 5877 | 5878 | /* }}} */ 5879 | 5880 | static zend_function_entry haruoutline_methods[] = { /* {{{ */ 5881 | PHP_ME(HaruOutline, __construct, arginfo_harudoc___void, ZEND_ACC_PRIVATE) 5882 | PHP_ME(HaruOutline, setOpened, arginfo_haruoutline_setopened, ZEND_ACC_PUBLIC) 5883 | PHP_ME(HaruOutline, setDestination, arginfo_haruoutline_setdestination, ZEND_ACC_PUBLIC) 5884 | {NULL, NULL, NULL} 5885 | }; 5886 | /* }}} */ 5887 | 5888 | static zend_function_entry haruexception_methods[] = { /* {{{ */ 5889 | {NULL, NULL, NULL} 5890 | }; 5891 | /* }}} */ 5892 | 5893 | /* }}} */ 5894 | 5895 | static zend_function_entry haru_functions[] = { /* {{{ */ 5896 | {NULL, NULL, NULL} 5897 | }; 5898 | /* }}} */ 5899 | 5900 | #ifdef COMPILE_DL_HARU 5901 | 5902 | ZEND_GET_MODULE(haru) 5903 | #endif 5904 | 5905 | #define HARU_CLASS_CONST(ce, name, value) \ 5906 | zend_declare_class_constant_long(ce, name, sizeof(name)-1, (long)value TSRMLS_CC); 5907 | 5908 | #define HARU_INIT_CLASS(uc_class_name, lc_class_name) \ 5909 | memcpy(&php_##lc_class_name##_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \ 5910 | php_##lc_class_name##_handlers.clone_obj = NULL; \ 5911 | INIT_CLASS_ENTRY(ce, uc_class_name, lc_class_name##_methods); \ 5912 | ce.create_object = php_##lc_class_name##_new; \ 5913 | ce_##lc_class_name = zend_register_internal_class(&ce TSRMLS_CC); 5914 | 5915 | /* {{{ PHP_MINIT_FUNCTION 5916 | */ 5917 | static PHP_MINIT_FUNCTION(haru) 5918 | { 5919 | zend_class_entry ce; 5920 | 5921 | INIT_CLASS_ENTRY(ce, "HaruException", haruexception_methods); 5922 | ce_haruexception = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC); 5923 | 5924 | HARU_INIT_CLASS("HaruDoc", harudoc); 5925 | HARU_INIT_CLASS("HaruPage", harupage); 5926 | HARU_INIT_CLASS("HaruFont", harufont); 5927 | HARU_INIT_CLASS("HaruImage", haruimage); 5928 | HARU_INIT_CLASS("HaruDestination", harudestination); 5929 | HARU_INIT_CLASS("HaruAnnotation", haruannotation); 5930 | HARU_INIT_CLASS("HaruEncoder", haruencoder); 5931 | HARU_INIT_CLASS("HaruOutline", haruoutline); 5932 | 5933 | HARU_CLASS_CONST(ce_harudoc, "CS_DEVICE_GRAY", HPDF_CS_DEVICE_GRAY); 5934 | HARU_CLASS_CONST(ce_harudoc, "CS_DEVICE_RGB", HPDF_CS_DEVICE_RGB); 5935 | HARU_CLASS_CONST(ce_harudoc, "CS_DEVICE_CMYK", HPDF_CS_DEVICE_CMYK); 5936 | HARU_CLASS_CONST(ce_harudoc, "CS_CAL_GRAY", HPDF_CS_CAL_GRAY); 5937 | HARU_CLASS_CONST(ce_harudoc, "CS_CAL_RGB", HPDF_CS_CAL_RGB); 5938 | HARU_CLASS_CONST(ce_harudoc, "CS_LAB", HPDF_CS_LAB); 5939 | HARU_CLASS_CONST(ce_harudoc, "CS_ICC_BASED", HPDF_CS_ICC_BASED); 5940 | HARU_CLASS_CONST(ce_harudoc, "CS_SEPARATION", HPDF_CS_SEPARATION); 5941 | HARU_CLASS_CONST(ce_harudoc, "CS_DEVICE_N", HPDF_CS_DEVICE_N); 5942 | HARU_CLASS_CONST(ce_harudoc, "CS_INDEXED", HPDF_CS_INDEXED); 5943 | HARU_CLASS_CONST(ce_harudoc, "CS_PATTERN", HPDF_CS_PATTERN); 5944 | 5945 | HARU_CLASS_CONST(ce_harudoc, "ENABLE_READ", HPDF_ENABLE_READ); 5946 | HARU_CLASS_CONST(ce_harudoc, "ENABLE_PRINT", HPDF_ENABLE_PRINT); 5947 | HARU_CLASS_CONST(ce_harudoc, "ENABLE_EDIT_ALL", HPDF_ENABLE_EDIT_ALL); 5948 | HARU_CLASS_CONST(ce_harudoc, "ENABLE_COPY", HPDF_ENABLE_COPY); 5949 | HARU_CLASS_CONST(ce_harudoc, "ENABLE_EDIT", HPDF_ENABLE_EDIT); 5950 | 5951 | HARU_CLASS_CONST(ce_harudoc, "ENCRYPT_R2", HPDF_ENCRYPT_R2); 5952 | HARU_CLASS_CONST(ce_harudoc, "ENCRYPT_R3", HPDF_ENCRYPT_R3); 5953 | 5954 | HARU_CLASS_CONST(ce_harudoc, "INFO_AUTHOR", HPDF_INFO_AUTHOR); 5955 | HARU_CLASS_CONST(ce_harudoc, "INFO_CREATOR", HPDF_INFO_CREATOR); 5956 | HARU_CLASS_CONST(ce_harudoc, "INFO_TITLE", HPDF_INFO_TITLE); 5957 | HARU_CLASS_CONST(ce_harudoc, "INFO_SUBJECT", HPDF_INFO_SUBJECT); 5958 | HARU_CLASS_CONST(ce_harudoc, "INFO_KEYWORDS", HPDF_INFO_KEYWORDS); 5959 | HARU_CLASS_CONST(ce_harudoc, "INFO_CREATION_DATE", HPDF_INFO_CREATION_DATE); 5960 | HARU_CLASS_CONST(ce_harudoc, "INFO_MOD_DATE", HPDF_INFO_MOD_DATE); 5961 | 5962 | HARU_CLASS_CONST(ce_harudoc, "COMP_NONE", HPDF_COMP_NONE); 5963 | HARU_CLASS_CONST(ce_harudoc, "COMP_TEXT", HPDF_COMP_TEXT); 5964 | HARU_CLASS_CONST(ce_harudoc, "COMP_IMAGE", HPDF_COMP_IMAGE); 5965 | HARU_CLASS_CONST(ce_harudoc, "COMP_METADATA", HPDF_COMP_METADATA); 5966 | HARU_CLASS_CONST(ce_harudoc, "COMP_ALL", HPDF_COMP_ALL); 5967 | 5968 | HARU_CLASS_CONST(ce_harudoc, "PAGE_LAYOUT_SINGLE", HPDF_PAGE_LAYOUT_SINGLE); 5969 | HARU_CLASS_CONST(ce_harudoc, "PAGE_LAYOUT_ONE_COLUMN", HPDF_PAGE_LAYOUT_ONE_COLUMN); 5970 | HARU_CLASS_CONST(ce_harudoc, "PAGE_LAYOUT_TWO_COLUMN_LEFT", HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT); 5971 | HARU_CLASS_CONST(ce_harudoc, "PAGE_LAYOUT_TWO_COLUMN_RIGHT", HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT); 5972 | 5973 | HARU_CLASS_CONST(ce_harudoc, "PAGE_MODE_USE_NONE", HPDF_PAGE_MODE_USE_NONE); 5974 | HARU_CLASS_CONST(ce_harudoc, "PAGE_MODE_USE_OUTLINE", HPDF_PAGE_MODE_USE_OUTLINE); 5975 | HARU_CLASS_CONST(ce_harudoc, "PAGE_MODE_USE_THUMBS", HPDF_PAGE_MODE_USE_THUMBS); 5976 | HARU_CLASS_CONST(ce_harudoc, "PAGE_MODE_FULL_SCREEN", HPDF_PAGE_MODE_FULL_SCREEN); 5977 | 5978 | HARU_CLASS_CONST(ce_harupage, "GMODE_PAGE_DESCRIPTION", HPDF_GMODE_PAGE_DESCRIPTION); 5979 | HARU_CLASS_CONST(ce_harupage, "GMODE_TEXT_OBJECT", HPDF_GMODE_TEXT_OBJECT); 5980 | HARU_CLASS_CONST(ce_harupage, "GMODE_PATH_OBJECT", HPDF_GMODE_PATH_OBJECT); 5981 | HARU_CLASS_CONST(ce_harupage, "GMODE_CLIPPING_PATH", HPDF_GMODE_CLIPPING_PATH); 5982 | HARU_CLASS_CONST(ce_harupage, "GMODE_SHADING", HPDF_GMODE_SHADING); 5983 | HARU_CLASS_CONST(ce_harupage, "GMODE_INLINE_IMAGE", HPDF_GMODE_INLINE_IMAGE); 5984 | HARU_CLASS_CONST(ce_harupage, "GMODE_EXTERNAL_OBJECT", HPDF_GMODE_EXTERNAL_OBJECT); 5985 | 5986 | HARU_CLASS_CONST(ce_harupage, "BUTT_END", HPDF_BUTT_END); 5987 | HARU_CLASS_CONST(ce_harupage, "ROUND_END", HPDF_ROUND_END); 5988 | HARU_CLASS_CONST(ce_harupage, "PROJECTING_SCUARE_END", HPDF_PROJECTING_SCUARE_END); 5989 | 5990 | HARU_CLASS_CONST(ce_harupage, "MITER_JOIN", HPDF_MITER_JOIN); 5991 | HARU_CLASS_CONST(ce_harupage, "ROUND_JOIN", HPDF_ROUND_JOIN); 5992 | HARU_CLASS_CONST(ce_harupage, "BEVEL_JOIN", HPDF_BEVEL_JOIN); 5993 | 5994 | HARU_CLASS_CONST(ce_harupage, "FILL", HPDF_FILL); 5995 | HARU_CLASS_CONST(ce_harupage, "STROKE", HPDF_STROKE); 5996 | HARU_CLASS_CONST(ce_harupage, "FILL_THEN_STROKE", HPDF_FILL_THEN_STROKE); 5997 | HARU_CLASS_CONST(ce_harupage, "INVISIBLE", HPDF_INVISIBLE); 5998 | HARU_CLASS_CONST(ce_harupage, "FILL_CLIPPING", HPDF_FILL_CLIPPING); 5999 | HARU_CLASS_CONST(ce_harupage, "STROKE_CLIPPING", HPDF_STROKE_CLIPPING); 6000 | HARU_CLASS_CONST(ce_harupage, "FILL_STROKE_CLIPPING", HPDF_FILL_STROKE_CLIPPING); 6001 | HARU_CLASS_CONST(ce_harupage, "CLIPPING", HPDF_CLIPPING); 6002 | 6003 | HARU_CLASS_CONST(ce_harupage, "TALIGN_LEFT", HPDF_TALIGN_LEFT); 6004 | HARU_CLASS_CONST(ce_harupage, "TALIGN_RIGHT", HPDF_TALIGN_RIGHT); 6005 | HARU_CLASS_CONST(ce_harupage, "TALIGN_CENTER", HPDF_TALIGN_CENTER); 6006 | HARU_CLASS_CONST(ce_harupage, "TALIGN_JUSTIFY", HPDF_TALIGN_JUSTIFY); 6007 | 6008 | HARU_CLASS_CONST(ce_harupage, "SIZE_LETTER", HPDF_PAGE_SIZE_LETTER); 6009 | HARU_CLASS_CONST(ce_harupage, "SIZE_LEGAL", HPDF_PAGE_SIZE_LEGAL); 6010 | HARU_CLASS_CONST(ce_harupage, "SIZE_A3", HPDF_PAGE_SIZE_A3); 6011 | HARU_CLASS_CONST(ce_harupage, "SIZE_A4", HPDF_PAGE_SIZE_A4); 6012 | HARU_CLASS_CONST(ce_harupage, "SIZE_A5", HPDF_PAGE_SIZE_A5); 6013 | HARU_CLASS_CONST(ce_harupage, "SIZE_B4", HPDF_PAGE_SIZE_B4); 6014 | HARU_CLASS_CONST(ce_harupage, "SIZE_B5", HPDF_PAGE_SIZE_B5); 6015 | HARU_CLASS_CONST(ce_harupage, "SIZE_EXECUTIVE", HPDF_PAGE_SIZE_EXECUTIVE); 6016 | HARU_CLASS_CONST(ce_harupage, "SIZE_US4x6", HPDF_PAGE_SIZE_US4x6); 6017 | HARU_CLASS_CONST(ce_harupage, "SIZE_US4x8", HPDF_PAGE_SIZE_US4x8); 6018 | HARU_CLASS_CONST(ce_harupage, "SIZE_US5x7", HPDF_PAGE_SIZE_US5x7); 6019 | HARU_CLASS_CONST(ce_harupage, "SIZE_COMM10", HPDF_PAGE_SIZE_COMM10); 6020 | 6021 | HARU_CLASS_CONST(ce_harupage, "PORTRAIT", HPDF_PAGE_PORTRAIT); 6022 | HARU_CLASS_CONST(ce_harupage, "LANDSCAPE", HPDF_PAGE_LANDSCAPE); 6023 | 6024 | HARU_CLASS_CONST(ce_harupage, "TS_WIPE_LIGHT", HPDF_TS_WIPE_RIGHT); 6025 | HARU_CLASS_CONST(ce_harupage, "TS_WIPE_UP", HPDF_TS_WIPE_UP); 6026 | HARU_CLASS_CONST(ce_harupage, "TS_WIPE_LEFT", HPDF_TS_WIPE_LEFT); 6027 | HARU_CLASS_CONST(ce_harupage, "TS_WIPE_DOWN", HPDF_TS_WIPE_DOWN); 6028 | HARU_CLASS_CONST(ce_harupage, "TS_BARN_DOORS_HORIZONTAL_OUT", HPDF_TS_BARN_DOORS_HORIZONTAL_OUT); 6029 | HARU_CLASS_CONST(ce_harupage, "TS_BARN_DOORS_HORIZONTAL_IN", HPDF_TS_BARN_DOORS_HORIZONTAL_IN); 6030 | HARU_CLASS_CONST(ce_harupage, "TS_BARN_DOORS_VERTICAL_OUT", HPDF_TS_BARN_DOORS_VERTICAL_OUT); 6031 | HARU_CLASS_CONST(ce_harupage, "TS_BARN_DOORS_VERTICAL_IN", HPDF_TS_BARN_DOORS_VERTICAL_IN); 6032 | HARU_CLASS_CONST(ce_harupage, "TS_BOX_OUT", HPDF_TS_BOX_OUT); 6033 | HARU_CLASS_CONST(ce_harupage, "TS_BOX_IN", HPDF_TS_BOX_IN); 6034 | HARU_CLASS_CONST(ce_harupage, "TS_BLINDS_HORIZONTAL", HPDF_TS_BLINDS_HORIZONTAL); 6035 | HARU_CLASS_CONST(ce_harupage, "TS_BLINDS_VERTICAL", HPDF_TS_BLINDS_VERTICAL); 6036 | HARU_CLASS_CONST(ce_harupage, "TS_DISSOLVE", HPDF_TS_DISSOLVE); 6037 | HARU_CLASS_CONST(ce_harupage, "TS_GLITTER_RIGHT", HPDF_TS_GLITTER_RIGHT); 6038 | HARU_CLASS_CONST(ce_harupage, "TS_GLITTER_DOWN", HPDF_TS_GLITTER_DOWN); 6039 | HARU_CLASS_CONST(ce_harupage, "TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT", HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT); 6040 | HARU_CLASS_CONST(ce_harupage, "TS_REPLACE", HPDF_TS_REPLACE); 6041 | 6042 | HARU_CLASS_CONST(ce_harupage, "NUM_STYLE_DECIMAL", HPDF_PAGE_NUM_STYLE_DECIMAL); 6043 | HARU_CLASS_CONST(ce_harupage, "NUM_STYLE_UPPER_ROMAN", HPDF_PAGE_NUM_STYLE_UPPER_ROMAN); 6044 | HARU_CLASS_CONST(ce_harupage, "NUM_STYLE_LOWER_ROMAN", HPDF_PAGE_NUM_STYLE_LOWER_ROMAN); 6045 | HARU_CLASS_CONST(ce_harupage, "NUM_STYLE_UPPER_LETTERS", HPDF_PAGE_NUM_STYLE_UPPER_LETTERS); 6046 | HARU_CLASS_CONST(ce_harupage, "NUM_STYLE_LOWER_LETTERS", HPDF_PAGE_NUM_STYLE_LOWER_LETTERS); 6047 | 6048 | HARU_CLASS_CONST(ce_haruencoder, "TYPE_SINGLE_BYTE", HPDF_ENCODER_TYPE_SINGLE_BYTE); 6049 | HARU_CLASS_CONST(ce_haruencoder, "TYPE_DOUBLE_BYTE", HPDF_ENCODER_TYPE_DOUBLE_BYTE); 6050 | HARU_CLASS_CONST(ce_haruencoder, "TYPE_UNINITIALIZED", HPDF_ENCODER_TYPE_UNINITIALIZED); 6051 | HARU_CLASS_CONST(ce_haruencoder, "UNKNOWN", HPDF_ENCODER_UNKNOWN); 6052 | 6053 | HARU_CLASS_CONST(ce_haruencoder, "BYTE_TYPE_SINGLE", HPDF_BYTE_TYPE_SINGLE); 6054 | HARU_CLASS_CONST(ce_haruencoder, "BYTE_TYPE_LEAD", HPDF_BYTE_TYPE_LEAD); 6055 | HARU_CLASS_CONST(ce_haruencoder, "BYTE_TYPE_TRAIL", HPDF_BYTE_TYPE_TRIAL); /* note the typo in the original name.. */ 6056 | HARU_CLASS_CONST(ce_haruencoder, "BYTE_TYPE_UNKNOWN", HPDF_BYTE_TYPE_UNKNOWN); 6057 | 6058 | HARU_CLASS_CONST(ce_haruencoder, "WMODE_HORIZONTAL", HPDF_WMODE_HORIZONTAL); 6059 | HARU_CLASS_CONST(ce_haruencoder, "WMODE_VERTICAL", HPDF_WMODE_VERTICAL); 6060 | 6061 | HARU_CLASS_CONST(ce_haruannotation, "NO_HIGHLIGHT", HPDF_ANNOT_NO_HIGHTLIGHT); 6062 | HARU_CLASS_CONST(ce_haruannotation, "INVERT_BOX", HPDF_ANNOT_INVERT_BOX); 6063 | HARU_CLASS_CONST(ce_haruannotation, "INVERT_BORDER", HPDF_ANNOT_INVERT_BORDER); 6064 | HARU_CLASS_CONST(ce_haruannotation, "DOWN_APPEARANCE", HPDF_ANNOT_DOWN_APPEARANCE); 6065 | 6066 | HARU_CLASS_CONST(ce_haruannotation, "ICON_COMMENT", HPDF_ANNOT_ICON_COMMENT); 6067 | HARU_CLASS_CONST(ce_haruannotation, "ICON_KEY", HPDF_ANNOT_ICON_KEY); 6068 | HARU_CLASS_CONST(ce_haruannotation, "ICON_NOTE", HPDF_ANNOT_ICON_NOTE); 6069 | HARU_CLASS_CONST(ce_haruannotation, "ICON_HELP", HPDF_ANNOT_ICON_HELP); 6070 | HARU_CLASS_CONST(ce_haruannotation, "ICON_NEW_PARAGRAPH", HPDF_ANNOT_ICON_NEW_PARAGRAPH); 6071 | HARU_CLASS_CONST(ce_haruannotation, "ICON_PARAGRAPH", HPDF_ANNOT_ICON_PARAGRAPH); 6072 | HARU_CLASS_CONST(ce_haruannotation, "ICON_INSERT", HPDF_ANNOT_ICON_INSERT); 6073 | 6074 | return SUCCESS; 6075 | } 6076 | /* }}} */ 6077 | 6078 | /* {{{ PHP_MINFO_FUNCTION 6079 | */ 6080 | static PHP_MINFO_FUNCTION(haru) 6081 | { 6082 | php_info_print_table_start(); 6083 | php_info_print_table_header(2, "Haru PDF support", "enabled"); 6084 | php_info_print_table_row(2, "Version", PHP_HARU_VERSION); 6085 | php_info_print_table_row(2, "libharu version", HPDF_VERSION_TEXT); 6086 | php_info_print_table_end(); 6087 | 6088 | } 6089 | /* }}} */ 6090 | 6091 | /* {{{ haru_module_entry 6092 | */ 6093 | zend_module_entry haru_module_entry = { 6094 | #if ZEND_MODULE_API_NO >= 20010901 6095 | STANDARD_MODULE_HEADER, 6096 | #endif 6097 | "haru", 6098 | haru_functions, 6099 | PHP_MINIT(haru), 6100 | NULL, 6101 | NULL, 6102 | NULL, 6103 | PHP_MINFO(haru), 6104 | #if ZEND_MODULE_API_NO >= 20010901 6105 | PHP_HARU_VERSION, 6106 | #endif 6107 | STANDARD_MODULE_PROPERTIES 6108 | }; 6109 | /* }}} */ 6110 | 6111 | /* 6112 | * Local variables: 6113 | * tab-width: 4 6114 | * c-basic-offset: 4 6115 | * End: 6116 | * vim600: noet sw=4 ts=4 fdm=marker 6117 | * vim<600: noet sw=4 ts=4 6118 | */ 6119 | --------------------------------------------------------------------------------