TCPDF ERROR: Some data has already been output, can't send PDF file

prettem

Member
Hello,
I tried to setup a custom button to use a custom function to create a pdf. It was working very well,
then I was trying to save the pdf file with this command:
$pdf->Output("/var/www/vhosts/.../uploads/test5.pdf", "F");

now I get one error message: TCPDF ERROR: Some data has already been output, can't send PDF file

from this point on the error never disapears. I can not make a PDF File,

my custom button/function does not work (with or without F or I): TCPDF ERROR:
the original button does not work with a template: TCPDF ERROR:
without template: TCPDF ERROR:
I removed the complete function: TCPDF ERROR:
with/without _settings.php: TCPDF ERROR:
logout/login, removing all templates and the function: TCPDF ERROR:

this is my function:
function dadabik_pdf(){
global $table_name, $dadabik_main_file;
require_once('include/tcpdf/tcpdf.php'); # I am not sure its necessary
$pdf = new TCPDF('P', 'mm', 'A4');
$pdf->AddPage();
$pdf->SetFont("helvetica","",12);
$pdf->Cell(50,50, "this is a pdf example 1", 0, 1, 'C', true);
$html = '<h1>HTML Example</h1>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Output("/var/www/vhosts/.../uploads/test5.pdf", "I");
header('Location:'.$dadabik_main_file.'?tablename='.urlencode($table_name).'&function=search');
}

Can someone help me please with this curious behaviour, thank you for your friendly help
best regards
Manuel


About/upgrade​

DaDaBIK™ is a product conceived and developed by Eugenio Tacchini
Copyright © 2001-2022 Eugenio Tacchini
Proudly ❤️ made in Emilia
dadabik.com

Your current DaDaBIK version​

You are using DaDaBIK version 11.8-Elba enterprise, installed on 10.02.2023 (installation code: 1865663e582dad9f52), the latest version of DaDaBIK is 11.8-Elba released on 05.12.2022

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 8.1.16

mysql version: 10.6.12-MariaDB-0ubuntu0.22.04.1

Web server: Apache

Client: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
 

taubes

Member
Hi
Did you try ob_start(); at the beginning of the function and
ob_end_clean();
ob_clean();
right before $pdf->Output

worked for me:)
 

prettem

Member
thank you, yes I tried to clean the buffer. nothing helped unless a fresh install for debugging and restore everything step by step. I found some mystical error in custom_buttons.php between 2 functions, I restored each function separately and it works again :)
 
Top