I have successfully installed pdflib with PHP4.0.4pl1 and all the
necessary components. However, I don't know how to output a generated
pdf to the browser without writing it to disk first and then reading it
in. Below are the examples that I use.
This example tries to directly output the pdf to the browser and doesn't
work. The browser says "An error has occured while trying to use this
document."
------------
<?
header( "Content-type: application/pdf" );
$pdf = PDF_open();
pdf_set_info_author($pdf, "Me");
PDF_set_info_title($pdf, "Test");
PDF_set_info_author($pdf, "Name of Author");
pdf_set_info_creator($pdf, "See Author");
pdf_set_info_subject($pdf, "Testing");
PDF_begin_page($pdf, 595, 842);
PDF_add_outline($pdf, "Page 1");
pdf_set_font($pdf, "Times-Roman", 30, "winansi");
pdf_set_text_rendering($pdf, 1);
PDF_show_xy($pdf, "Times Roman outlined", 50, 750);
pdf_moveto($pdf, 50, 740);
pdf_lineto($pdf, 330, 740);
pdf_stroke($pdf);
PDF_end_page($pdf);
PDF_close($pdf);
?>
------------
However, the following script that writes the pdf to disk first and is
then read in works fine:
------------
<?
$fp = fopen("pdftesting.pdf", w);
$pdf = PDF_open($fp);
pdf_set_info_author($pdf, "Me");
PDF_set_info_title($pdf, "Test");
PDF_set_info_author($pdf, "Name of Author");
pdf_set_info_creator($pdf, "See Author");
pdf_set_info_subject($pdf, "Testing");
PDF_begin_page($pdf, 595, 842);
PDF_add_outline($pdf, "Page 1");
pdf_set_font($pdf, "Times-Roman", 30, "winansi");
pdf_set_text_rendering($pdf, 1);
PDF_show_xy($pdf, "Times Roman outlined", 50, 750);
pdf_moveto($pdf, 50, 740);
pdf_lineto($pdf, 330, 740);
pdf_stroke($pdf);
PDF_end_page($pdf);
PDF_close($pdf);
fclose($fp);
header( "Content-type: application/pdf" );
$fp = fopen("pdftesting.pdf", "r");
fpassthru($fp);
fclose($fp);
?>
------------
Any reason why I have to write the pdf to disk instead of just sending
it to the browser? Am I missing an output function? Thanks.
--
Dominic
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]