Answer the question
In order to leave comments, you need to log in
How to save generated pdf file without errors in tcpdf?
I have a php page that needs to be converted to pdf. I use tcpdf for translation. I include a PHP page using include(). The page is rendered but not saved and throws TCPDF ERROR: Some data has already been output, can't send PDF file.
<?php
require_once('tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 001');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
$pdf->setFooterData(array(0,64,0), array(0,64,128));
$pdf->AddPage();
$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
$html = include('file.php');
$pdf->writeHTML($html, 'false', 'false', 'false', 'false', '');
$pdf->Output('example_001.pdf', 'I');
?>
Answer the question
In order to leave comments, you need to log in
Recently I was engaged in pdf generation, the only one that helped normally is mpdf www.mpdf1.com/mpdf/index.php
A good example of using it is here https://github.com/kartik-v/yii2-mpdf/blob/master/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question