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

📄 cpdf.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* }}} */#define BUFFERLEN 40/* {{{ proto bool cpdf_page_init(int pdfdoc, int pagenr, int orientation, int height, int width [, float unit])   Starts page */PHP_FUNCTION(cpdf_page_init){	pval *argv[6];	int id, type, pagenr, orientation;	int height, width, argc;	char buffer[BUFFERLEN];	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_long(argv[1]);	convert_to_long(argv[2]);	convert_to_long(argv[3]);	convert_to_long(argv[4]);	id=Z_LVAL_P(argv[0]);	pagenr=Z_LVAL_P(argv[1]);	orientation=Z_LVAL_P(argv[2]);	height = Z_LVAL_P(argv[3]);	width = Z_LVAL_P(argv[4]);	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_double(argv[5]);		if(Z_DVAL_P(argv[5]) > 0.0)			cpdf_setDefaultDomainUnit(pdf, Z_DVAL_P(argv[5]));	}	snprintf(buffer, BUFFERLEN, "0 0 %d %d", width, height);	cpdf_pageInit(pdf, pagenr, orientation, buffer, buffer);	RETURN_TRUE;}/* }}} */#undef BUFFERLEN/* {{{ proto bool cpdf_finalize_page(int pdfdoc, int pagenr)   Ends the page to save memory */PHP_FUNCTION(cpdf_finalize_page){	pval *arg1, *arg2;	int id, type, pagenr;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_long(arg2);	id=Z_LVAL_P(arg1);	pagenr=Z_LVAL_P(arg2);	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_finalizePage(pdf, pagenr);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_current_page(int pdfdoc, int pagenr)   Sets page for output */PHP_FUNCTION(cpdf_set_current_page){	pval *arg1, *arg2;	int id, type, pagenr;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_long(arg2);	id=Z_LVAL_P(arg1);	pagenr=Z_LVAL_P(arg2);	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_setCurrentPage(pdf, pagenr);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_begin_text(int pdfdoc)   Starts text section */PHP_FUNCTION(cpdf_begin_text){	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_beginText(pdf, 0);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_end_text(int pdfdoc)   Ends text section */PHP_FUNCTION(cpdf_end_text){	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_endText(pdf);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_show(int pdfdoc, string text)   Output text at current position */PHP_FUNCTION(cpdf_show){	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;	}	cpdf_textShow(pdf, Z_STRVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_show_xy(int pdfdoc, string text, float x-koor, float y-koor [, int mode])   Output text at position */PHP_FUNCTION(cpdf_show_xy){	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_string(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 == 5) {		convert_to_long(argv[4]);		mode = Z_LVAL_P(argv[4]);	}	if(mode == 1)		cpdf_rawText(pdf, (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), 0.0, Z_STRVAL_P(argv[1]));	else		cpdf_text(pdf, (float) Z_DVAL_P(argv[2]), (float) Z_DVAL_P(argv[3]), 0.0, Z_STRVAL_P(argv[1]));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_continue_text(int pdfdoc, string text)   Outputs text in next line */PHP_FUNCTION(cpdf_continue_text){	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;	}	cpdf_textCRLFshow(pdf, Z_STRVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_text(int pdfdoc, string text [, float x-koor, float y-koor [, int mode [, float orientation [, int alignmode]]]])   Outputs text */PHP_FUNCTION(cpdf_text){	pval *argv[7];	int id, type, argc, mode=0;	CPDFdoc *pdf;	argc = ZEND_NUM_ARGS();	if((argc < 2) || (argc == 3) || (argc > 7) || getParametersArray(ht, argc, argv) == FAILURE)			WRONG_PARAM_COUNT;	convert_to_long(argv[0]);	convert_to_string(argv[1]);	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[2]);	}	switch(argc) {		case 2:			cpdf_textShow(pdf, Z_STRVAL_P(argv[1]));			break;		case 4:			convert_to_double(argv[2]);			convert_to_double(argv[3]);			cpdf_text(pdf, (float) Z_DVAL_P(argv[2]),			          (float) Z_DVAL_P(argv[3]),			           0.0,			           Z_STRVAL_P(argv[1]));			break;		case 5:			convert_to_double(argv[2]);			convert_to_double(argv[3]);			if(mode == 1)				cpdf_rawText(pdf, (float) Z_DVAL_P(argv[2]),			             	(float) Z_DVAL_P(argv[3]),			             	0.0,			              	Z_STRVAL_P(argv[1]));			else				cpdf_text(pdf, (float) Z_DVAL_P(argv[2]),				          (float) Z_DVAL_P(argv[3]),				          0.0,				          Z_STRVAL_P(argv[1]));			break;		case 6:			convert_to_double(argv[2]);			convert_to_double(argv[3]);			convert_to_double(argv[5]);			if(mode == 1)				cpdf_rawText(pdf, (float) Z_DVAL_P(argv[2]),			             	(float) Z_DVAL_P(argv[3]),			             	(float) Z_DVAL_P(argv[5]),			              	Z_STRVAL_P(argv[1]));			else				cpdf_text(pdf, (float) Z_DVAL_P(argv[2]),			             	(float) Z_DVAL_P(argv[3]),			             	(float) Z_DVAL_P(argv[5]),			              	Z_STRVAL_P(argv[1]));			break;		case 7:			convert_to_double(argv[2]);			convert_to_double(argv[3]);			convert_to_double(argv[5]);			convert_to_long(argv[6]);			if(mode == 1)				cpdf_rawTextAligned(pdf, (float) Z_DVAL_P(argv[2]),			             	(float) Z_DVAL_P(argv[3]),			             	(float) Z_DVAL_P(argv[5]),			             	Z_LVAL_P(argv[6]),			              	Z_STRVAL_P(argv[1]));			else				cpdf_textAligned(pdf, (float) Z_DVAL_P(argv[2]),			             	(float) Z_DVAL_P(argv[3]),			             	(float) Z_DVAL_P(argv[5]),			             	Z_LVAL_P(argv[6]),			              	Z_STRVAL_P(argv[1]));			break;	}	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_font(int pdfdoc, string font, float size, string encoding)   Selects the current font face, size and encoding */PHP_FUNCTION(cpdf_set_font){	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_string(arg2);	convert_to_double(arg3);	convert_to_string(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;	}	/*	if(Z_LVAL_P(arg4) > 6) {		php_error(E_WARNING, "%s(): Font encoding set to 5", get_active_function_name(TSRMLS_C));		Z_LVAL_P(arg4) = 5;	}*/	cpdf_setFont(pdf, Z_STRVAL_P(arg2), Z_STRVAL_P(arg4), (float) Z_DVAL_P(arg3));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_font_directories(int pdfdoc, string pfmdir, string pfbdir)   Sets directories to search when using external fonts */PHP_FUNCTION(cpdf_set_font_directories){	pval *arg1, *arg2, *arg3;	int id, type;	CPDFdoc *pdf;	if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(arg1);	convert_to_string(arg2);	convert_to_string(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;	}	cpdf_setFontDirectories(pdf, Z_STRVAL_P(arg2), Z_STRVAL_P(arg3));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_font_map_file(int pdfdoc, string filename)   Sets fontname to filename translation map when using external fonts */PHP_FUNCTION(cpdf_set_font_map_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 (php_check_open_basedir(Z_STRVAL_P(arg2) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(arg2), "rb+", CHECKUID_CHECK_MODE_PARAM))) {		RETURN_FALSE;	}	cpdf_setFontMapFile(pdf, Z_STRVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_leading(int pdfdoc, float distance)   Sets distance between text lines */PHP_FUNCTION(cpdf_set_leading){	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_setTextLeading(pdf, (float) Z_DVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_text_rendering(int pdfdoc, int rendermode)   Determines how text is rendered */PHP_FUNCTION(cpdf_set_text_rendering){	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_long(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_setTextRenderingMode(pdf, Z_LVAL_P(arg2));	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_horiz_scaling(int pdfdoc, float scale)   Sets horizontal scaling of text */PHP_FUNCTION(cpdf_set_horiz_scaling){	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_setHorizontalScaling(pdf, (float) Z_DVAL_P(arg2) * 100.0);	RETURN_TRUE;}/* }}} *//* {{{ proto bool cpdf_set_text_rise(int pdfdoc, float value)   Sets the text rise */

⌨️ 快捷键说明

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