Hi,
I am trying to create a dynamic pdf using php but can't seem to get it to work. I was looking at: PHP.net and tried an example but it's not ouputting a pdf just the code you would see if you opened a pdf in notepad.
The code I'm using is:
I am running php on apache under win32 and have uncommented the apporpriate line in the php.ini but when I call the page with that code I get the following output:
What do I do to get this to return a pdf file? And one other question is: Is it possible to open a pre-made pdf template and simply insert variables into certain parts and then output a new dynamic pdf with the data in it?
Thanks alot!
NATE
Got a question? Search G O O G L E for links to the fastest answers: www.google.com
I am trying to create a dynamic pdf using php but can't seem to get it to work. I was looking at: PHP.net and tried an example but it's not ouputting a pdf just the code you would see if you opened a pdf in notepad.
The code I'm using is:
Code:
<?php
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_begin_page($pdf, 595, 842);
pdf_set_font($pdf, "Times-Roman", 30, "host");
pdf_set_value($pdf, "textrendering", 1);
pdf_show_xy($pdf, "A PDF document created in memory!", 50, 750);
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header("Content-type: application/pdf");
header("Content-disposition: inline; filename=test.pdf");
header("Content-length: " . strlen($data));
echo $data;
?>
I am running php on apache under win32 and have uncommented the apporpriate line in the php.ini but when I call the page with that code I get the following output:
Code:
%PDF-1.3 %äãÏÒ 5 0 obj <> stream xœs áÒw3P06PIã2T)@h¨`j `Ä!¹\ I. G…7…”üäÒÜÔ¼…ä¢ÔÄ’Ô…Ì<…ÜÔÜü¢JEÍ,.×.!gˆendstream endobj 6 0 obj 84 endobj 4 0 obj <> endobj 8 0 obj <> >> endobj 3 0 obj <> endobj 7 0 obj <> endobj 1 0 obj <> endobj 2 0 obj <> endobj xref 0 9 0000000000 65535 f 0000000537 00000 n 0000000591 00000 n 0000000351 00000 n 0000000188 00000 n 0000000015 00000 n 0000000170 00000 n 0000000443 00000 n 0000000291 00000 n trailer <<1DD0F4665D017D8251424299BB688F26>] >> startxref 638 %%EOF
What do I do to get this to return a pdf file? And one other question is: Is it possible to open a pre-made pdf template and simply insert variables into certain parts and then output a new dynamic pdf with the data in it?
Thanks alot!
NATE

Got a question? Search G O O G L E for links to the fastest answers: www.google.com