467,913 Members | 1,798 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,913 developers. It's quick & easy.

Error creating PDF with PHP library

Bit
I am using the fpdf php library to create a PDF file from php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. require('lib/fpdf.php');
  4.  
  5. $pdf = new FPDF();
  6. $pdf->AddPage();
  7. $pdf->SetFont('Verdana','B',16);
  8. $pdf->Cell(40,10,'Create this pdf now!');
  9. $pdf->Output("new_pdf_file.pdf", "D");
  10.  
  11. ?>
  12.  
I get the following error

This page isnít working localhost is currently unable to handle this request. HTTP ERROR 500
4 Weeks Ago #1
  • viewed: 2139
Share:
2 Replies
Expert 256MB
Enable error reporting to see the error(s).
4 Weeks Ago #2
16bit
The problem is that FPDF requires you to enable http PUT method in the affected directories on the server, in able to serve the PDF file directly to the client browser. In the case of Apache, this would be done in apache2.conf file.

The workaround would be to use Output ("/path/to/file.pdf" "F") and then include a header redirect to /path/to/file.pdf, or to use Output(); which is Output("""I") by default. Also, the Path in the Output command needs to be a full path that is writable.
1 Week Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Altramagnus | last post: by
reply views Thread by Matt Warner | last post: by
3 posts views Thread by J | last post: by
4 posts views Thread by =?Utf-8?B?Z3JlZw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.