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

📄 pdf.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	RETURN_STRING(value, 1);}/* }}} *//* {{{ proto void pdf_setgray_fill(int pdfdoc, float value)   Sets filling color to gray value */PHP_FUNCTION(pdf_setgray_fill){	zval **arg1, **arg2;	PDF *pdf;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_double_ex(arg2);#if (PDFLIB_MAJORVERSION >= 4)	PDF_setcolor(pdf, "fill", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0);#else	PDF_setgray_fill(pdf, (float) Z_DVAL_PP(arg2));#endif	RETURN_TRUE;}/* }}} *//* {{{ proto void pdf_setgray_stroke(int pdfdoc, float value)   Sets drawing color to gray value */PHP_FUNCTION(pdf_setgray_stroke) {	zval **arg1, **arg2;	PDF *pdf;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_double_ex(arg2);#if (PDFLIB_MAJORVERSION >= 4)	PDF_setcolor(pdf, "stroke", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0);#else	PDF_setgray_stroke(pdf, (float) Z_DVAL_PP(arg2));#endif	RETURN_TRUE;}/* }}} *//* {{{ proto void pdf_setgray(int pdfdoc, float value)   Sets drawing and filling color to gray value */PHP_FUNCTION(pdf_setgray){	zval **arg1, **arg2;	PDF *pdf;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_double_ex(arg2);#if (PDFLIB_MAJORVERSION >= 4)	PDF_setcolor(pdf, "both", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0);#else	PDF_setgray(pdf, (float) Z_DVAL_PP(arg2));#endif	RETURN_TRUE;}/* }}} *//* {{{ proto void pdf_setrgbcolor_fill(int pdfdoc, float red, float green, float blue)   Sets filling color to RGB color value */PHP_FUNCTION(pdf_setrgbcolor_fill){	zval **arg1, **arg2, **arg3, **arg4;	PDF *pdf;	if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_double_ex(arg2);	convert_to_double_ex(arg3);	convert_to_double_ex(arg4);#if (PDFLIB_MAJORVERSION >= 4)	PDF_setcolor(pdf, "fill", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0);#else	PDF_setrgbcolor_fill(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4));#endif	RETURN_TRUE;}/* }}} *//* {{{ proto void pdf_setrgbcolor_stroke(int pdfdoc, float red, float green, float blue)   Sets drawing color to RGB color value */PHP_FUNCTION(pdf_setrgbcolor_stroke){	zval **arg1, **arg2, **arg3, **arg4;	PDF *pdf;	if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_double_ex(arg2);	convert_to_double_ex(arg3);	convert_to_double_ex(arg4);#if (PDFLIB_MAJORVERSION >= 4)	PDF_setcolor(pdf, "stroke", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0);#else	PDF_setrgbcolor_stroke(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4));#endif	RETURN_TRUE;}/* }}} *//* {{{ proto void pdf_setrgbcolor(int pdfdoc, float red, float green, float blue)   Sets drawing and filling color to RGB color value */PHP_FUNCTION(pdf_setrgbcolor){	zval **arg1, **arg2, **arg3, **arg4;	PDF *pdf;	if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_double_ex(arg2);	convert_to_double_ex(arg3);	convert_to_double_ex(arg4);#if (PDFLIB_MAJORVERSION >= 4)	PDF_setcolor(pdf, "both", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0);#else	PDF_setrgbcolor(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4));#endif	RETURN_TRUE;}/* }}} *//* {{{ proto int pdf_add_bookmark(int pdfdoc, string text [, int parent, int open])   Adds bookmark for current page */PHP_FUNCTION(pdf_add_bookmark){	zval **arg1, **arg2, **arg3, **arg4;	int parentid, open, id;	PDF *pdf;	switch (ZEND_NUM_ARGS()) {	case 2:		if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {			WRONG_PARAM_COUNT;		}		break;	case 3:		if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {			WRONG_PARAM_COUNT;		}		break;	case 4:		if (zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {			WRONG_PARAM_COUNT;		}	break;	default:		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_string_ex(arg2);	if (ZEND_NUM_ARGS() > 2) {		convert_to_long_ex(arg3);		parentid = Z_LVAL_PP(arg3);		if (ZEND_NUM_ARGS() > 3) {			convert_to_long_ex(arg4);			open = Z_LVAL_PP(arg4);		} else {			open = 0;		}	} else {		parentid = 0;		open = 0;	}	/* will never return 0 */	id = PDF_add_bookmark(pdf, Z_STRVAL_PP(arg2), parentid, open);	RETURN_LONG(id);}/* }}} *//* {{{ proto void pdf_set_transition(int pdfdoc, int transition)   Sets transition between pages */PHP_FUNCTION(pdf_set_transition){	zval **arg1, **arg2;	PDF *pdf;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_long_ex(arg2);	switch(Z_LVAL_PP(arg2)) {		case 0:			PDF_set_parameter(pdf, "transition", "none");			break;		case 1:			PDF_set_parameter(pdf, "transition", "split");			break;		case 2:			PDF_set_parameter(pdf, "transition", "blinds");			break;		case 3:			PDF_set_parameter(pdf, "transition", "box");			break;		case 4:			PDF_set_parameter(pdf, "transition", "wipe");			break;		case 5:			PDF_set_parameter(pdf, "transition", "dissolve");			break;		case 6:			PDF_set_parameter(pdf, "transition", "glitter");			break;		case 7:			PDF_set_parameter(pdf, "transition", "replace");			break;		default:			PDF_set_parameter(pdf, "transition", "none");	}	RETURN_TRUE;}/* }}} *//* {{{ proto void pdf_set_duration(int pdfdoc, float duration)   Sets duration between pages */PHP_FUNCTION(pdf_set_duration){	zval **arg1, **arg2;	PDF *pdf;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_double_ex(arg2);	PDF_set_value(pdf, "duration", (float) Z_DVAL_PP(arg2));	RETURN_TRUE;}/* }}} *//* {{{ _php_pdf_open_image */static void _php_pdf_open_image(INTERNAL_FUNCTION_PARAMETERS, char *type) {	zval **arg1, **arg2;	PDF *pdf;	int pdf_image;	char *image;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_string_ex(arg2);#ifdef VIRTUAL_DIR	virtual_filepath(Z_STRVAL_PP(arg2), &image TSRMLS_CC);#else	image = Z_STRVAL_PP(arg2);#endif  	if (php_check_open_basedir(image TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(image, "rb+", CHECKUID_CHECK_MODE_PARAM))) {		RETURN_FALSE;	}	pdf_image = PDF_open_image_file(pdf, type, image, "", 0);	RETURN_LONG(pdf_image+PDFLIB_IMAGE_OFFSET);}/* }}} *//* {{{ proto int pdf_open_gif(int pdf, string giffile)   Opens a GIF file and returns an image for placement in a pdf object */PHP_FUNCTION(pdf_open_gif){	_php_pdf_open_image(INTERNAL_FUNCTION_PARAM_PASSTHRU,"gif");}/* }}} *//* {{{ proto int pdf_open_jpeg(int pdf, string jpegfile)   Opens a JPEG file and returns an image for placement in a PDF document */PHP_FUNCTION(pdf_open_jpeg){	_php_pdf_open_image(INTERNAL_FUNCTION_PARAM_PASSTHRU,"jpeg");}/* }}} *//* {{{ proto int pdf_open_png(int pdf, string pngfile)   Opens a PNG file and returns an image for placement in a PDF document */PHP_FUNCTION(pdf_open_png){	_php_pdf_open_image(INTERNAL_FUNCTION_PARAM_PASSTHRU,"png");}/* }}} *//* {{{ proto int pdf_open_tiff(int pdf, string tifffile)   Opens a TIFF file and returns an image for placement in a PDF document */PHP_FUNCTION(pdf_open_tiff){	_php_pdf_open_image(INTERNAL_FUNCTION_PARAM_PASSTHRU,"tiff");}/* }}} *//* {{{ proto int pdf_open_image_file(int pdf, string type, string file, string stringparam, int intparam)   Opens an image file of the given type and returns an image for placement in a PDF document */PHP_FUNCTION(pdf_open_image_file){	zval **arg1, **arg2, **arg3, **arg4, **arg5;	PDF *pdf;	int pdf_image, argc;	char *image;	char *stringparam;	int intparam;	switch ((argc = ZEND_NUM_ARGS())) {	case 3:		if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)			WRONG_PARAM_COUNT;		break;	case 5:		if (zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE)			WRONG_PARAM_COUNT;		break;	default:		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_string_ex(arg2);	convert_to_string_ex(arg3);#ifdef VIRTUAL_DIR	virtual_filepath(Z_STRVAL_PP(arg3), &image TSRMLS_CC);#else	image = Z_STRVAL_PP(arg3);#endif  	if (php_check_open_basedir(image TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(image, "rb+", CHECKUID_CHECK_MODE_PARAM))) {		RETURN_FALSE;	}	if (argc == 3) {		pdf_image = PDF_open_image_file(pdf, Z_STRVAL_PP(arg2), image, "", 0);	} else {	    convert_to_string_ex(arg4);	    convert_to_long_ex(arg5);	    stringparam = Z_STRVAL_PP(arg4);	    intparam = Z_LVAL_PP(arg5);	    /* adjust the image handle */	    if (!strcmp(stringparam, "masked"))		intparam -= PDFLIB_IMAGE_OFFSET;	    pdf_image = PDF_open_image_file(pdf, Z_STRVAL_PP(arg2), image, stringparam, intparam);	}	if (pdf_image == -1) {	    /* pdflib will do this for you, will throw some exception	    php_error(E_WARNING, "Could not open image: %s", image);	    */	    RETURN_FALSE;	}	RETURN_LONG(pdf_image+PDFLIB_IMAGE_OFFSET);}/* }}} */#if HAVE_LIBGD13/* {{{ proto int pdf_open_memory_image(int pdf, int image)   Takes an GD image and returns an image for placement in a PDF document */PHP_FUNCTION(pdf_open_memory_image){	zval **arg1, **arg2;	int i, j, color;	int pdf_image;	gdImagePtr im;	unsigned char *buffer, *ptr;	PDF *pdf;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}		ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	ZEND_GET_RESOURCE_TYPE_ID(le_gd,"gd");	if(!le_gd)	{		php_error(E_ERROR, "Unable to find handle for GD image stream. Please check the GD extension is loaded.");	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, arg2, -1, "Image", le_gd);	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				}	}	pdf_image = PDF_open_image(pdf, "raw", "memory", buffer, im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL);	efree(buffer);	if(pdf_image == -1) {		/* pdflib will do this for you, will throw some exception		php_error(E_WARNING, "Could not open image");		*/		efree(buffer);		RETURN_FALSE;	}	RETURN_LONG(pdf_image+PDFLIB_IMAGE_OFFSET);}/* }}} */#endif /* HAVE_LIBGD13 *//* {{{ proto void pdf_close_image(int pdf, int pdfimage)   Closes the PDF image */PHP_FUNCTION(pdf_close_image){	zval **arg1, **arg2;	PDF *pdf;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_long_ex(arg2);	PDF_close_image(pdf, Z_LVAL_PP(arg2)-PDFLIB_IMAGE_OFFSET);}/* }}} *//* {{{ proto void pdf_place_image(int pdf, int pdfimage, float x, float y, float scale)   Places image in the PDF document */PHP_FUNCTION(pdf_place_image){	zval **arg1, **arg2, **arg3, **arg4, **arg5;	PDF *pdf;	if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {		WRONG_PARAM_COUNT;	}	ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);	convert_to_long_ex(arg2);	convert_to_double_ex(arg3);	convert_to_double_ex(arg4);	convert_to_double_ex(arg5);	PDF_place_image(pdf, Z_LVAL_PP(arg2)-PDFLIB_IMAGE_OFFSET, (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), (float) Z_DVAL_PP(arg5));	RETURN_TRUE;}/* }}} *//* {{{ proto int pdf_get_image_width(int pdf, int pdfimage)   Returns the width of an image */PHP_FUNCTION(pdf_get_image_width){	zval **arg1, **arg2;	PDF *pdf;	int width;

⌨️ 快捷键说明

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