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...

CommentFileSizeAuthor
mailinglabelview.txt8.45 KBwaltonjones

Comments

acouch’s picture

Assigned: Unassigned » acouch
Status: Needs work » Postponed (maintainer needs more info)

I'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.

waltonjones’s picture

Version: » 6.x-1.1-alpha2

Still 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!

acouch’s picture

Hi 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

asak’s picture

I'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...

acouch’s picture

Thanks, I am investigating as well. I am having trouble reproducing this locally so am not sure what the problem is.

waltonjones’s picture

Any luck reproducing this error?

waltonjones’s picture

Still looking for some help on this issue. Anyone got any ideas?

acouch’s picture

hi Walton:

can you install devel module on your site?

waltonjones’s picture

Done. Thanks for still being willing to help out with this.

waltonjones’s picture

Could 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.

acouch’s picture

hi 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?

waltonjones’s picture

Version: 6.x-1.1-alpha2 »

I 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.

waltonjones’s picture

Version: » 6.x-1.1-beta1

Dude! 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!

acouch’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I 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.

svergeylen’s picture

I 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

aashishv12’s picture

Version: 6.x-1.1-beta1 » 6.x-1.x-dev
Assigned: acouch » aashishv12

function 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.