[PHP] FPDF output to a variable

2004-11-24 Thread Justin Palmer
Hi List,

I have done some searching on Google and the Archives for what I am
trying to do, but it seems I am searching up the wrong avenues.  Here is
my situation:

I generate pdf files with fpdf (fpdf.org) and I would like to catch the
output of the pdf stream into a variable so that I can attach it to an
email.  The email and attaching the file to the email is working great,
but when I get the email adobe can not open the pdf.  It seems that it
is not being decoded properly.  I attach another pdf that is in the file
system already, but sense this one is created dynamically it is not
saved anywhere.  I just am trying to get the ouput in a variable instead
of outputing it to the browser.  Below is some code for the pdf and what
I was trying to do to send it.

The below code may have errors, I just typed it quickly in the email.
The concept is there though.

//Creating the pdf  [create_pdf.php]
?
require(FpdfProtection.class.php); //
[http://www.cetusa.org/temp/fpdf_protection.phps]
session_cache_limiter('private');
session_start();
header(Cache-Control: no-store, no-cache, must-revalidate);
define('FPDF_FONTPATH','font/');


$pdf = new FPDF_Protection();
$pdf-Open();
$pdf-SetMargins(3,3);
$pdf-AddPage();
$pdf-Cell(100,0,'This is the text to be put into the pdf.' );
$pdf-SetProtection(array('print'),'','87df9dfn43*%^uskaid');
$pdf-Close();
$pdf-Output();
exit();
?

?
//Get the output and send the email  send_mail.php
//uses the class MIME_mail (http://www.cetusa.org/temp/MIME.class.phps)
//WARNING I know that this is not how it is intended to be used, 
//but this is the what I want to accomplish.
$fp = fopen(create_pdf.php);
$pdf = fpassthru($fp);//actually returns the number of characters read,
I want the content of the executed path.
fclose($fp);
//END WARNING
$from='[EMAIL PROTECTED]';
$to='[EMAIL PROTECTED]';
$subject='PDF FILE';
$message='Attached is the PDF file.';
$mail = new MIME_mail($from, $to, $subject,$message);
$mail-attach($pdf, 'Profile', OCTET,BASE64,'attachment;
filename=Profile.pdf');
$mail-send_mail();
?

Any help on this would be great.  If you know of some search terms that
would get me going in the right direction that would be great also (I
don't mind doing the research).

If you need more clarification please let me know.

Regards,

Justin Palmer
__
KISS (Keep It Simple, SEARCH)!
Google::getUri( http://www.google.com );
Archives::getUri( http://marc.theaimsgroup.com/?l=php-general );

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FPDF output to a variable

2004-11-24 Thread Jason Wong
On Thursday 25 November 2004 01:27, Justin Palmer wrote:

 ?
 //Get the output and send the email  send_mail.php
 //uses the class MIME_mail (http://www.cetusa.org/temp/MIME.class.phps)
 //WARNING I know that this is not how it is intended to be used,
 //but this is the what I want to accomplish.
 $fp = fopen(create_pdf.php);

This is going to open 'create_pdf.php' via the local filesystem. 

 $pdf = fpassthru($fp);//actually returns the number of characters read,

Here you've stored the contents of 'create_pdf.php' into $pdf which is 
definitely not what you want.

 Any help on this would be great.  If you know of some search terms that
 would get me going in the right direction that would be great also (I
 don't mind doing the research).

If fpdf does not allow its output to be saved directly to file then use the 
output buffering functions to capture the output. Examples in manual (as 
usual).

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I feel sorry for your brain... all alone in that great big head...
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php