sybil6
10-24-2009, 03:20 PM
i am trying to achieve a php to pdf simple example with PDFlib (bounded with php) but i get the error :
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\_PHP\php_pdf\index.php:1) in C:\xampp\htdocs\_PHP\php_pdf\index.php on line 14
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\_PHP\php_pdf\index.php:1) in C:\xampp\htdocs\_PHP\php_pdf\index.php on line 15
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\_PHP\php_pdf\index.php:1) in C:\xampp\htdocs\_PHP\php_pdf\index.php on line 16
%PDF-1.4 %���� 3 0 obj <> stream x�s ��w3P04PI�2T0
the code is:
<?php
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 10);
PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
PDF_end_page($mypdf);
PDF_close($mypdf);
$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: $mylen");
header("Content-Disposition: inline; filename=gen01.pdf");
print $mybuf;
PDF_delete($mypdf);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
</body>
</html>
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\_PHP\php_pdf\index.php:1) in C:\xampp\htdocs\_PHP\php_pdf\index.php on line 14
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\_PHP\php_pdf\index.php:1) in C:\xampp\htdocs\_PHP\php_pdf\index.php on line 15
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\_PHP\php_pdf\index.php:1) in C:\xampp\htdocs\_PHP\php_pdf\index.php on line 16
%PDF-1.4 %���� 3 0 obj <> stream x�s ��w3P04PI�2T0
the code is:
<?php
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 10);
PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
PDF_end_page($mypdf);
PDF_close($mypdf);
$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: $mylen");
header("Content-Disposition: inline; filename=gen01.pdf");
print $mybuf;
PDF_delete($mypdf);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
</body>
</html>