Connecting Tech Pros Worldwide Help | Site Map

php to pdf

Newbie
 
Join Date: Nov 2008
Posts: 28
#1: 4 Weeks Ago
hello,
i am trying to achieve a php to pdf simple example with PDFlib (bounded with php) but i get the error :
Expand|Select|Wrap|Line Numbers
  1. 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
  2.  
  3. 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
  4.  
  5. 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
  6. %PDF-1.4 %���� 3 0 obj <> stream x�s ��w3P04PI�2T0
  7.  

the code is:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $mypdf = PDF_new();
  3. PDF_open_file($mypdf, "");
  4. PDF_begin_page($mypdf, 595, 842);
  5. $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
  6. PDF_setfont($mypdf, $myfont, 10);
  7. PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
  8. PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
  9. PDF_end_page($mypdf);
  10. PDF_close($mypdf);
  11.  
  12. $mybuf = PDF_get_buffer($mypdf);
  13. $mylen = strlen($mybuf);
  14. header("Content-type: application/pdf");
  15. header("Content-Length: $mylen");
  16. header("Content-Disposition: inline; filename=gen01.pdf");
  17. print $mybuf;
  18.  
  19. PDF_delete($mypdf);
  20.  ?>
  21. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  22.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  23.  
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25.  
  26. <head>
  27.   <title></title>
  28.  
  29. </head>
  30.  
  31. <body>
  32.  
  33. </body>
  34.  
  35. </html>
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: 4 Weeks Ago

re: php to pdf


Hey, Arty.

Please see this thread (note the BOM part).

Mark.
Newbie
 
Join Date: Nov 2008
Posts: 28
#3: 4 Weeks Ago

re: php to pdf


hi,
i found a solution, i just changed my file from UTF to ANSI an d now it works.
do you know how can i make table cell looking with php to pdf ?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#4: 4 Weeks Ago

re: php to pdf


Quote:

Originally Posted by arty View Post

hi,
i found a solution, i just changed my file from UTF to ANSI an d now it works.
do you know how can i make table cell looking with php to pdf ?

A table cell looking with php to pdf? I don't understand the question.

P.S. It was the BOM then.
Reply


Similar PHP bytes