note 15693 deleted from ref.cpdf by jimw

From: Date: Sat, 08 Dec 2001 22:24:49 +0000
Subject: note 15693 deleted from ref.cpdf by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22299@lists.php.net to get a copy of this message
Patch that allows you to get the length in bytes of the output buffer for a finalized pdf document that has been created in memory. * Description: int cpdf_buffer_length(int pdf document) Returns the length in bytes of the output buffer for a finalized pdf document that has been created in memory. This is good for sending a 'Content-Length' header before outputting your pdf file from memory. MSIE requires a properly set 'Content-Length' header in order to display the pdf document correctly. * Usage: cpdf_finalize($pdf); $size = cpdf_buffer_length($pdf); header("Content-Type: application/pdf"); header("Content-Length: $size"); cpdf_output_buffer($pdf); * Patch: Add the following entry to the cpdf_functions array at the top of ext/cpdf/cpdf.c PHP_FE(cpdf_buffer_length, NULL) Add the following entry to the PHP_FUNCTION list in ext/cpdf/php_cpdf.h PHP_FUNCTION(cpdf_buffer_length); Add the below patch to ext/cpdf/cpdf.c ------------ START PATCH ------------ /* {{{ proto int cpdf_buffer_length(int pdfdoc) Returns current length of the output buffer */ PHP_FUNCTION(cpdf_buffer_length) { pval *arg1; int id, type, length; CPDFdoc *pdf; CPDF_TLS_VARS; if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(arg1); id=arg1->value.lval; pdf = zend_list_find(id,&type); if(!pdf || type!=CPDF_GLOBAL(le_cpdf)) { php_error(E_WARNING,"Unable to find identifier %d",id); RETURN_FALSE; } cpdf_getBufferForPDF(pdf, &length); RETURN_LONG(length); } /* }}} */ ------------ END PATCH ------------

« previous php.notes (#22299) next »