Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've installed the Printer-friendly Pages version 6.x-1.0-rc5 with tcpdf_php5 version 4.0.006 as described in the documentation on drupal 6.3. The example pages of tcpdf generates PDF-files corectly but when I try to create a PDF-File by clicking on the PDF-Create Link I get the following error: TCPDF error: Some data has already been output, can't send PDF file.
Please help.
Comments
Comment #1
jcnventura CreditAttribution: jcnventura commentedHi,
I never saw that error. It's definitively a problem with TCPDF. Can you try dompdf instead?
João
Comment #2
xurubo93 CreditAttribution: xurubo93 commentedI cannot use dompdf, because it doesn't support UTF8.
Comment #3
jcnventura CreditAttribution: jcnventura commentedFrom what I have been able to find out, TCPDF shows that error when some kind of error was produced and logged before the actual PDF generation. Unfortunately, it can do so in more than one situation and I know of no way of finding out which was the actual error.
Without more info, I really cant' help you.
João
Comment #4
jcnventura CreditAttribution: jcnventura commentedNo further info received in 2 weeks, closing the issue.
Comment #5
jcnventura CreditAttribution: jcnventura commentedComment #6
Alpha5 CreditAttribution: Alpha5 commentedI have same problem.
Comment #7
jannalexx CreditAttribution: jannalexx commentedsame error here...
try this in print_pdf.pages.inc
in print_pdf.pages.inc
insert:
just before
$pdf->Output($filename, $output_dest);
Comment #8
jcnventura CreditAttribution: jcnventura commentedNote that this doesn't really solve the problem.. TCPDF reported some kind of error/warning and the PDF will have problems..
However, I would like to know if you used the above line, and if so, what were the results.
João
Comment #9
Alpha5 CreditAttribution: Alpha5 commentedIt work fine for me. Add this line and I get the pdf file support UTF8.
Comment #10
jcnventura CreditAttribution: jcnventura commentedAccording to the documentation for ob_end_clean, it turns off the output buffer. That may have severe side-effects inside TCPDF. Can you try ob_clean instead and tell me if it also solves your problem?
João
Comment #11
Alpha5 CreditAttribution: Alpha5 commentedTry ob_clean() also get correct pdf file. Thanks!
Comment #12
jcnventura CreditAttribution: jcnventura commentedAdded ob_clean() to CVS.
João
Comment #13
jannalexx CreditAttribution: jannalexx commentedob_clean() works here also
Comment #14
chaimkut CreditAttribution: chaimkut commentedHi
I have the latest 6.x-1.5 version of the Print module, and am experiencing the bug described above. I have attempted both suggested fixes of ob_end_clean() and ob_clean() but neither of them worked. The big difference in my configuration is that I'm using tcpdf_php4 on a PHP 4.3.11 system. I am able to successfully create the examples in tcpdf's 'examples' folder. Any ideas?
Edit: I installed the latest Dev cut of the Print module and I no longer receive this error. Now, when I try to retrieve a PDF for a 5 line article in UTF8, mty browser fails to download the entire 1.7 MB file. It usually gets to 1 MB or 1.5 MB and then fails. I'm suspecting that at this point it's a memory issue when trying to hold such a large file in memory at once. I will update if I figure anything else out.
Comment #15
jcnventura CreditAttribution: jcnventura commentedTwo weeks without furhter info.. Closing the issue.
Comment #16
firfin CreditAttribution: firfin commentedI am experiencing the same problem. Using the latest print (6.x-1.5) tcpdf (4.6.025) and drupal (6.13).
My version of print already had the
And I also tried ob_end_clean() .
After reading the tcpdf forums I realized I had some whitespace and newliness at the end of my template.php file. Nothing should be outputted before pdf->output is called! Once I removed the fluff is everything worked fine.
Probably the solution for others still experiencing problem after the ob_clean fix.
(so I mark this as fixed, hope that's ok)
Comment #18
nsvwa CreditAttribution: nsvwa commentedI'm using print (6.x-1.10) tcpdf (4.8.032) and drupal (6.15)
I found that if I edit code (ex. print_pdf.module or print_pdf.pages.inc) and save in UTF format, I'll get this error.
I must keep code in ANSI format, but I can use UTF for template file (ex. print.node-node_example.tpl.php) for thai language.
Comment #19
hacknslash CreditAttribution: hacknslash commentedThe ANSI save fixed this for me, too. Didn't try the ob_clean solution, so can't vouch for it.
- Cheers
Comment #20
pankaj01 CreditAttribution: pankaj01 commentedI had similar error.
To resolve this I had to remove the closing php tags '>' in the end of file
Comment #21
marthinal CreditAttribution: marthinal commentedI fixed it cleaning a whitespace line at the beggining of a custom module.
Comment #22
seers CreditAttribution: seers commentedThis error means HTML header has been output before creating the PDF file.
Just remove any HTML headers and HTML tags in the PDF building pages and it works!
Comment #23
svergeylen CreditAttribution: 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 #24
gaurav.matta CreditAttribution: gaurav.matta commentedob_start();
$tcpdf->output($filename, $output_dest);
ob_end_flush();
Comment #25
malveslin CreditAttribution: malveslin commentedcoloque require_once(dirname(__FILE__).'/html2pdf/html2pdf.class.php');
na primeira linha php como você faz com as sessões !
Comment #26
MarvinGP CreditAttribution: MarvinGP commentedHi I have an issue printing $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));, I'm using version of TCPDF 6.3.5 and PHP 7.4.29