⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpdf.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* {{{ proto bool cpdf_closepath_fill_stroke(int pdfdoc)   Close, fill and stroke current path */PHP_FUNCTION(cpdf_closepath_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_closepath(pdf);	cpdf_fill(pdf);	cpdf_stroke(pdf);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_clip(int pdfdoc)   Clips to current path */PHP_FUNCTION(cpdf_clip){	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_clip(pdf);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_setgray_fill(int pdfdoc, float value)   Sets filling color to gray value */PHP_FUNCTION(cpdf_setgray_fill){	pval *arg1, *arg2;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_double(arg2);	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_setgrayFill(pdf, (float) Z_DVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_setgray_stroke(int pdfdoc, float value)   Sets drawing color to gray value */PHP_FUNCTION(cpdf_setgray_stroke){	pval *arg1, *arg2;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_double(arg2);	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_setgrayStroke(pdf, (float) Z_DVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_setgray(int pdfdoc, float value)   Sets drawing and filling color to gray value */PHP_FUNCTION(cpdf_setgray){	pval *arg1, *arg2;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_double(arg2);	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_setgray(pdf, (float) Z_DVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_setrgbcolor_fill(int pdfdoc, float red, float green, float blue)   Sets filling color to rgb color value */PHP_FUNCTION(cpdf_setrgbcolor_fill){	pval *arg1, *arg2, *arg3, *arg4;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_double(arg2);	convert_to_double(arg3);	convert_to_double(arg4);	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_setrgbcolorFill(pdf, (float) Z_DVAL_P(arg2), (float) Z_DVAL_P(arg3), (float) Z_DVAL_P(arg4));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_setrgbcolor_stroke(int pdfdoc, float red, float green, float blue)   Sets drawing color to RGB color value */PHP_FUNCTION(cpdf_setrgbcolor_stroke){	pval *arg1, *arg2, *arg3, *arg4;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_double(arg2);	convert_to_double(arg3);	convert_to_double(arg4);	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_setrgbcolorStroke(pdf, (float) Z_DVAL_P(arg2), (float) Z_DVAL_P(arg3), (float) Z_DVAL_P(arg4));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_setrgbcolor(int pdfdoc, float red, float green, float blue)   Sets drawing and filling color to RGB color value */PHP_FUNCTION(cpdf_setrgbcolor){	pval *arg1, *arg2, *arg3, *arg4;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_double(arg2);	convert_to_double(arg3);	convert_to_double(arg4);	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_setrgbcolor(pdf, (float) Z_DVAL_P(arg2), (float) Z_DVAL_P(arg3), (float) Z_DVAL_P(arg4));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_page_animation(int pdfdoc, int transition, float duration, float direction, int orientation, int inout)   Sets transition between pages */PHP_FUNCTION(cpdf_set_page_animation){	pval *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 6 || getParameters(ht, 6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_long(arg2);	convert_to_double(arg3);	convert_to_double(arg4);	convert_to_long(arg5);	convert_to_long(arg6);	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_setPageTransition(pdf, Z_LVAL_P(arg2), Z_DVAL_P(arg3), Z_DVAL_P(arg4),	                       Z_LVAL_P(arg5), Z_LVAL_P(arg6));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_finalize(int pdfdoc)   Creates PDF doc in memory */PHP_FUNCTION(cpdf_finalize){	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_finalizeAll(pdf);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_output_buffer(int pdfdoc)   Returns the internal memory stream as string */PHP_FUNCTION(cpdf_output_buffer){	pval *arg1;	int id, type, lenght;	CPDFdoc *pdf;	char *buffer;	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;	}	buffer = cpdf_getBufferForPDF(pdf, &lenght);	php_write(buffer, lenght TSRMLS_CC);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_save_to_file(int pdfdoc, string filename)   Saves the internal memory stream to a file */PHP_FUNCTION(cpdf_save_to_file){	pval *arg1, *arg2;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_string(arg2);	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 APACHE	if(strcmp(Z_STRVAL_P(arg2), "-") == 0)		php_error(E_WARNING, "%s(): Writing to stdout as described in the ClibPDF manual is not possible if php is used as an Apache module. Use cpdf_output_buffer() instead.", get_active_function_name(TSRMLS_C));#endif	if (php_check_open_basedir(Z_STRVAL_P(arg2) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(arg2), "wb+", CHECKUID_CHECK_MODE_PARAM))) {		RETURN_FALSE;	}	cpdf_savePDFmemoryStreamToFile(pdf, Z_STRVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_import_jpeg(int pdfdoc, string filename, float x, float y, float angle, float width, float height, float x_scale, float y_scale, int gsave [, int mode])   Includes JPEG image */PHP_FUNCTION(cpdf_import_jpeg){	pval *argv[11];	int id, type, argc, mode=0;	float width, height, xscale, yscale;	CPDFdoc *pdf;	argc = ZEND_NUM_ARGS();	if((argc < 10) || (argc > 11))		WRONG_PARAM_COUNT;	if (getParametersArray(ht, argc, argv) == FAILURE)		WRONG_PARAM_COUNT;	convert_to_long(argv[0]);	convert_to_string(argv[1]);	if (php_check_open_basedir(Z_STRVAL_P(argv[1]) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(argv[1]), "rb+", CHECKUID_CHECK_MODE_PARAM))) {		RETURN_FALSE;	}	convert_to_double(argv[2]);	convert_to_double(argv[3]);	convert_to_double(argv[4]);	convert_to_double(argv[5]);	width = (float) Z_DVAL_P(argv[5]);	convert_to_double(argv[6]);	height = (float) Z_DVAL_P(argv[6]);	convert_to_double(argv[7]);	xscale = (float) Z_DVAL_P(argv[7]);	convert_to_double(argv[8]);	yscale = (float) Z_DVAL_P(argv[8]);	convert_to_long(argv[9]);	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 > 10) {		convert_to_long(argv[10]);		mode = Z_LVAL_P(argv[10]);	}	if(mode == 1)		cpdf_rawImportImage(pdf, Z_STRVAL_P(argv[1]),	                	    JPEG_IMG,	                	    (float) Z_DVAL_P(argv[2]),	                	    (float) Z_DVAL_P(argv[3]),	                	    (float) Z_DVAL_P(argv[4]),	                	    &width,	                	    &height,	                	    &xscale,	                	    &yscale,	                	    Z_LVAL_P(argv[9]));	else		cpdf_rawImportImage(pdf, Z_STRVAL_P(argv[1]),	                	    JPEG_IMG,	                	    (float) Z_DVAL_P(argv[2]),	                	    (float) Z_DVAL_P(argv[3]),	                	    (float) Z_DVAL_P(argv[4]),	                	    &width,	                	    &height,	                	    &xscale,	                	    &yscale,	                	    Z_LVAL_P(argv[9]));	RETURN_TRUE;}/* }}} */#if HAVE_LIBGD13/* {{{ proto bool cpdf_place_inline_image(int pdfdoc, int gdimage, float x, float y, float angle, fload width, float height, int gsave [, int mode])   Includes image */PHP_FUNCTION(cpdf_place_inline_image){	pval *argv[11];	int id, gid, type, argc, mode=0;	int count, i, j, color;	CPDFdoc *pdf;	unsigned char *buffer, *ptr;	gdImagePtr im;	argc = ZEND_NUM_ARGS();	if((argc < 8) || (argc > 9))		WRONG_PARAM_COUNT;	if (getParametersArray(ht, argc, argv) == FAILURE)		WRONG_PARAM_COUNT;	convert_to_long(argv[0]);	convert_to_long(argv[1]);	convert_to_double(argv[2]);	convert_to_double(argv[3]);	convert_to_double(argv[4]);	convert_to_double(argv[5]);	convert_to_double(argv[6]);	convert_to_long(argv[7]);	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;	}	gid=Z_LVAL_P(argv[1]);	im = zend_list_find(gid, &type);		ZEND_GET_RESOURCE_TYPE_ID(CPDF_GLOBAL(le_gd), "gd");	if(!CPDF_GLOBAL(le_gd))	{		php_error(E_ERROR, "%s(): Unable to find handle for GD image stream. Please check the GD extension is loaded.", get_active_function_name(TSRMLS_C));	}	if (!im || type != CPDF_GLOBAL(le_gd)) {		php_error(E_WARNING, "%s(): Unable to find image pointer", get_active_function_name(TSRMLS_C));		RETURN_FALSE;	}	if(argc > 8) {		convert_to_long(argv[8]);		mode = Z_LVAL_P(argv[8]);	}	count = 3 * im->sx * im->sy;	buffer = (unsigned char *) safe_emalloc(3 * im->sx, im->sy, 0);	ptr = buffer;	for(i=0; i<im->sy; i++) {		for(j=0; j<im->sx; j++) {#if HAVE_LIBGD20			if(gdImageTrueColor(im)) {				if (im->tpixels && gdImageBoundsSafe(im, j, i)) {					color = gdImageTrueColorPixel(im, j, i);					*ptr++ = (color >> 16) & 0xFF;					*ptr++ = (color >> 8) & 0xFF;					*ptr++ = color & 0xFF;				}			} else {#endif				if (im->pixels && gdImageBoundsSafe(im, j, i)) {					color = im->pixels[i][j];					*ptr++ = im->red[color];					*ptr++ = im->green[color];					*ptr++ = im->blue[color];				}#if HAVE_LIBGD20			}#endif		}	}	if(mode == 1)		cpdf_placeInLineImage(pdf, buffer, count,	                	    (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]),	                	    im->sx,	                	    im->sy,	                	    8, 2, Z_LVAL_P(argv[7]));	else		cpdf_rawPlaceInLineImage(pdf, buffer, count,	                	    (float) Z_DVAL_P(argv[2]),	                	    (float) Z_DVAL_P(argv[3]),	                	    (float) Z_DVAL_P(argv[4]),	        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -