📄 cpdf.c
字号:
#define BUFFERLEN 20/* {{{ proto bool cpdf_setdash(int pdfdoc, long white, long black) Sets dash pattern */PHP_FUNCTION(cpdf_setdash){ pval *arg1, *arg2, *arg3; int id, type; char buffer[BUFFERLEN]; CPDFdoc *pdf; if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); convert_to_long(arg2); convert_to_long(arg3); id=Z_LVAL_P(arg1); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if (!pdf->currentMemStream) { RETURN_FALSE; } snprintf(buffer, BUFFERLEN, "[%d %d] 0", (int) Z_LVAL_P(arg2), (int) Z_LVAL_P(arg3)); cpdf_setdash(pdf, buffer); RETURN_TRUE;}/* }}} */#undef BUFFERLEN/* {{{ proto bool cpdf_moveto(int pdfdoc, float x, float y [, int mode]) Sets current point */PHP_FUNCTION(cpdf_moveto){ pval *argv[4]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 3) || (argc > 4)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 3) { convert_to_long(argv[3]); mode = Z_LVAL_P(argv[3]); } if(mode == 1) cpdf_rawMoveto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); else cpdf_moveto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_rmoveto(int pdfdoc, float x, float y [, int mode]) Sets current point */PHP_FUNCTION(cpdf_rmoveto){ pval *argv[4]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 3) || (argc > 4)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 3) { convert_to_long(argv[3]); mode = Z_LVAL_P(argv[3]); } if(mode == 1) cpdf_rawRmoveto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); else cpdf_rmoveto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_curveto(int pdfdoc, float x1, float y1, float x2, float y2, float x3, float y3 [, int mode]) Draws a curve */PHP_FUNCTION(cpdf_curveto){ pval *argv[8]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 7) || (argc > 8)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); convert_to_double(argv[3]); convert_to_double(argv[4]); convert_to_double(argv[5]); convert_to_double(argv[6]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 7) { convert_to_long(argv[7]); mode = Z_LVAL_P(argv[7]); } if(mode == 1) cpdf_rawCurveto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), (float) Z_DVAL_P(argv[4]), (float) Z_DVAL_P(argv[5]), (float) Z_DVAL_P(argv[6])); else cpdf_curveto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), (float) Z_DVAL_P(argv[4]), (float) Z_DVAL_P(argv[5]), (float) Z_DVAL_P(argv[6])); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_lineto(int pdfdoc, float x, float y [, int mode]) Draws a line */PHP_FUNCTION(cpdf_lineto){ pval *argv[4]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 3) || (argc > 4)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 3) { convert_to_long(argv[3]); mode = Z_LVAL_P(argv[3]); } if(mode == 1) cpdf_rawLineto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); else cpdf_lineto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_rlineto(int pdfdoc, float x, float y [, int mode]) Draws a line relative to current point */PHP_FUNCTION(cpdf_rlineto){ pval *argv[4]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 3) || (argc > 4)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 3) { convert_to_long(argv[3]); mode = Z_LVAL_P(argv[3]); } if(mode == 1) cpdf_rawRlineto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); else cpdf_rlineto(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2])); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_circle(int pdfdoc, float x, float y, float radius [, int mode]) Draws a circle */PHP_FUNCTION(cpdf_circle){ pval *argv[5]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 4) || (argc > 5)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); convert_to_double(argv[3]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 4) { convert_to_long(argv[4]); mode = Z_LVAL_P(argv[4]); } if(mode == 1) cpdf_rawCircle(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3])); else cpdf_circle(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3])); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_arc(int pdfdoc, float x, float y, float radius, float start, float end [, int mode]) Draws an arc */PHP_FUNCTION(cpdf_arc){ pval *argv[7]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 6) || (argc > 7)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); convert_to_double(argv[3]); convert_to_double(argv[4]); convert_to_double(argv[5]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 6) { convert_to_long(argv[6]); mode = Z_LVAL_P(argv[6]); } if(mode == 1) cpdf_rawArc(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), (float) Z_DVAL_P(argv[4]), (float) Z_DVAL_P(argv[5]), 1); else cpdf_arc(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), (float) Z_DVAL_P(argv[4]), (float) Z_DVAL_P(argv[5]), 1); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_rect(int pdfdoc, float x, float y, float width, float height [, int mode]) Draws a rectangle */PHP_FUNCTION(cpdf_rect){ pval *argv[6]; int id, type, argc, mode=0; CPDFdoc *pdf; argc = ZEND_NUM_ARGS(); if((argc < 5) || (argc > 6)) WRONG_PARAM_COUNT; if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(argv[0]); convert_to_double(argv[1]); convert_to_double(argv[2]); convert_to_double(argv[3]); convert_to_double(argv[4]); id=Z_LVAL_P(argv[0]); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } if(argc > 5) { convert_to_long(argv[5]); mode = Z_LVAL_P(argv[5]); } if(mode == 1) cpdf_rawRect(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), (float) Z_DVAL_P(argv[4])); else cpdf_rect(pdf, (float) Z_DVAL_P(argv[1]), (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), (float) Z_DVAL_P(argv[4])); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_newpath(int pdfdoc) Starts new path */PHP_FUNCTION(cpdf_newpath){ pval *arg1; int id, type; CPDFdoc *pdf; if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); id=Z_LVAL_P(arg1); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } cpdf_newpath(pdf); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_closepath(int pdfdoc) Close path */PHP_FUNCTION(cpdf_closepath){ pval *arg1; int id, type; CPDFdoc *pdf; if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); id=Z_LVAL_P(arg1); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } cpdf_closepath(pdf); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_closepath_stroke(int pdfdoc) Close path and draw line along path */PHP_FUNCTION(cpdf_closepath_stroke){ pval *arg1; int id, type; CPDFdoc *pdf; if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); id=Z_LVAL_P(arg1); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } cpdf_closepath(pdf); cpdf_stroke(pdf); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_stroke(int pdfdoc) Draws line along path path */PHP_FUNCTION(cpdf_stroke){ pval *arg1; int id, type; CPDFdoc *pdf; if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); id=Z_LVAL_P(arg1); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } cpdf_stroke(pdf); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_fill(int pdfdoc) Fills current path */PHP_FUNCTION(cpdf_fill){ pval *arg1; int id, type; CPDFdoc *pdf; if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); id=Z_LVAL_P(arg1); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } cpdf_fill(pdf); RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_fill_stroke(int pdfdoc) Fills and stroke current path */PHP_FUNCTION(cpdf_fill_stroke){ pval *arg1; int id, type; CPDFdoc *pdf; if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); id=Z_LVAL_P(arg1); pdf = zend_list_find(id, &type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id); RETURN_FALSE; } cpdf_fill(pdf); cpdf_stroke(pdf); RETURN_TRUE;}/* }}} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -