Jump to content

Recommended Posts

 

I am using the fpdf library for my project, and I'm using this to extend one of the drupal module. These lines

$pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output();

give me an error: FPDF error: Some data has already been output, can't send PDF

I tried creating this in a separate file outside the drupal area name test.php and when viewed it worked. Anyone here know why this don't work? Or anyone here can point me a right pdf library which I can use in drupal to view HTML to PDF format.

Link to comment
https://forums.phpfreaks.com/topic/314733-fpdf-problem/
Share on other sites

Always put FPDF code in a script by itself. Link to that script to get the pdf file

<a href='create_pdf.php'>Create PDF</a>

The TCPDF library has a "WriteHTML()" function. Don't expect much by way of documentation for this library. Apart from the source code, I haven't found any yet.

Link to comment
https://forums.phpfreaks.com/topic/314733-fpdf-problem/#findComment-1595743
Share on other sites

Your script is poorly constructed.  You are sending something to the client prior to the pdf content.  No can do.  Probably a blank line outside of php mode.  One trick?  Never Leave PHP mode in your scripts

PS - what line does the error message give you?  That IS the problem.

Link to comment
https://forums.phpfreaks.com/topic/314733-fpdf-problem/#findComment-1595748
Share on other sites

Where did you download the zip file from?  Perhaps this can help you.

http://www.fpdf.org/

And I noticed that you are using a less-than-common character set.  Probably from looking at out-dated code examples.  Switch to UTF-8.

Edited by ginerjm
Link to comment
https://forums.phpfreaks.com/topic/314733-fpdf-problem/#findComment-1595753
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.