I get this error “FPDF error: Some data has already been output, can't send PDF file” when I run the Mailing Label module.
I have attached the exported version of the view I am running it on...
| Comment | File | Size | Author |
|---|---|---|---|
| mailinglabelview.txt | 8.45 KB | waltonjones |
Comments
Comment #1
acouch commentedI've tried but can't recreate this error. Can 1) try from the latest head version, and 2) if you get the same error, tell me when it is giving you this error? Thank you.
Comment #2
waltonjones commentedStill having the same error when I click the "Print pdf" button to actually produce the pdf. Are there any other setup steps that I may be missing? I just loaded it like any other module. Then I created a page with views and attached the mailing labels to that page. Both the page and the mailing label setup menus have the same options for sorts, filters, and fields.
Another issue for me after we get this working will be altering the presets so that I can use labels that come on A4 size sheets. I live abroad, so this will be really helpful. I can't get Avery labels here!
Comment #3
acouch commentedHi Walton:
Can you contact me via email? I'd like to setup a phone or chat session where I can try and figure out what is going wrong for you here.
best,
-Aaron
Comment #4
asak commentedI'm getting the same error using mailing_label.info,v 1.3 2009/07/26... on all label options using a page view...
I'll investigate some more and return if i find anything helpfull...
Comment #5
acouch commentedThanks, I am investigating as well. I am having trouble reproducing this locally so am not sure what the problem is.
Comment #6
waltonjones commentedAny luck reproducing this error?
Comment #7
waltonjones commentedStill looking for some help on this issue. Anyone got any ideas?
Comment #8
acouch commentedhi Walton:
can you install devel module on your site?
Comment #9
waltonjones commentedDone. Thanks for still being willing to help out with this.
Comment #10
waltonjones commentedCould this be a problem of using the utf-8 character encoding? I noticed a few threads regarding this error on other websites. My site is bilingual (English and Korean), so I use utf-8.
Comment #11
acouch commentedhi Walton,
that could be a problem. the error message you receive comes from the following lines in fpdf:
if(ob_get_contents())
$this->Error('Some data has already been output, can\'t send PDF file');
which i think is saying that something has already been output (http://us3.php.net/manual/en/function.ob-get-contents.php) but i can't figure out what or where it is coming from (esp since I can't recreate this).
can you download the latest dev version and see what happens?
Comment #12
waltonjones commentedI am using the latest dev version now, but I get the same error. I guess if the problem is indeed coming from the fact that the database is utf-8 it won't help to shut of the content translations.
Comment #13
waltonjones commentedDude! You totally fixed the problem with the new version. What was the deal? Was it a utf-8 issue or something else?
Anyway, thank you!
Comment #14
acouch commentedI added an 'exit;' after the pdf is generated and removed the error message that is tripped by ob_get_contents().
Glad to hear it is working and good luck with your research and teaching.
Comment #15
svergeylen commentedI added ob_start() before Output() to clear the PHP buffer how contains already 6 elements... even if I had no print or echo before Output().... This solved my problem but the use of ob_clean() didn't help
Comment #16
aashishv12 commentedfunction Output($name='', $dest='')
{
// Output PDF to some destination
if($this->state<3)
$this->Close();
$dest = strtoupper($dest);
ob_clean();
if($dest=='')
{
if($name=='')
{
$name = 'doc.pdf';
$dest = 'I';
}
else
$dest = 'F';
}
switch($dest)
{
case 'I':
// Send to standard output
$this->_checkoutput();
if(PHP_SAPI!='cli')
{
// We send to a browser
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$name.'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
}
echo $this->buffer;
break;
case 'D':
// Download file
$this->_checkoutput();
header('Content-Type: application/x-download');
header('Content-Disposition: attachment; filename="'.$name.'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
echo $this->buffer;
break;
case 'F':
// Save to local file
$f = fopen($name,'wb');
if(!$f)
$this->Error('Unable to create output file: '.$name);
fwrite($f,$this->buffer,strlen($this->buffer));
fclose($f);
break;
case 'S':
// Return as a string
return $this->buffer;
default:
$this->Error('Incorrect output destination: '.$dest);
}
return '';
}
used ob_clean(); in the above code and got my pdf. try this out in fpdf.php file.