note 15693 added to ref.cpdf

From: Date: Wed, 26 Sep 2001 21:09:53 +0000
Subject: note 15693 added to ref.cpdf
Groups: php.notes 
Request: Send a blank email to php-notes+get-18347@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 ------------ -- http://www.php.net/manual/en/ref.cpdf.php http://master.php.net/manage/user-notes.php?action=edit+15693 http://master.php.net/manage/user-notes.php?action=delete+15693 http://master.php.net/manage/user-notes.php?action=reject+15693

« previous php.notes (#18347) next »