ETcPdf is a wrapper for the TCPDF class, which is not bundled, since it's huge (not so much the class itself, but the associated files, making a 9 Mb tarball or 13 Mb unpacked). You can download the class here. Notice that TCPDF is updated almost daily, so I recommend you to update the class file frequently, since new cool features are added on every release. I used TCPDF 4.2.007 while developing this wrapper.
protected/extensionsSee the following code example:
$pdf = Yii::createComponent('application.extensions.tcpdf.ETcPdf', 'P', 'cm', 'A4', true, 'UTF-8'); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor("Nicola Asuni"); $pdf->SetTitle("TCPDF Example 002"); $pdf->SetSubject("TCPDF Tutorial"); $pdf->SetKeywords("TCPDF, PDF, example, test, guide"); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont("times", "BI", 20); $pdf->Cell(0,10,"Example 002",1,1,'C'); $pdf->Output("example_002.pdf", "I");
Total 20 comments
The answer lies in this link: Your text to link here...
I have issue with header and footer.. how to set header and footer and how to erase the line at top and bottom of the pages...? can anyone help with this issue?
I have started using tcpdf and have it working, but for a mysterious line that appears at the top of the page. I have just the following as code, yet the line keeps appearing:
Anyone else have this issue?
I confirm same error report for me. I delete the line
and then it works again .I do not know precisely the consequences... but seems this methods no more exist in tcpdf.
just installed the extension and
solved the "K_PATH_CACHE already defined" error thanks to @Pablovp
but, now i get the following error:
any cues?
Unfortunately this extension is not a converter from HTLM to PDF. It 'just' give you access to the tcpdf function you must draw your report by yourself...
how i tell tcpdf to generate pdf of particular view ?
i have a view and want its pdf format. how can i get ?
i have this code
$this->renderPartial('application.views.reportcard.report',array( 'student_info'=>$student_info, ));
$pdf = Yii::createComponent('application.extensions.tcpdf.ETcPdf', 'P', 'cm', 'A4', true, 'UTF-8'); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor("Nicola Asuni"); $pdf->SetTitle("TCPDF Example 002"); $pdf->SetSubject("TCPDF Tutorial"); $pdf->SetKeywords("TCPDF, PDF, example, test, guide"); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont("times", "BI", 20); $pdf->Cell(0,10,"Example 002",1,1,'C'); $pdf->Output("example_002.pdf", "I");
The solution is to use blank layout, which only contains
<?php echo $content; ?>This prevents any appending html tags to the generated pdf.
Cheers!
Change line 85 from:
To:
@husnoo
Make sure you have a tcpdf subdirectory. Look in you folder structure you may have the files in extensions\tcpdf. If so move all the files in extensions\tcpdf to extensions\tcpdf\tcpdf.
Hi,
i got the following error require_once(D:\Dev\Apache\htdocs\first\protected\extensions\tcpdf/tcpdf/tcpdf.php): failed to open stream: No such file or directory.
Please suggest the solution. thnks to all...
I love the extension and am using it successfully.
One thing I haven't been able to figure out is how to replace the header footer functions of tcpdf. In order to be able to customize the footer, you must redefine the Footer function. Since this extension does not technically extend the tcpdf class, redefining the footer function does not work.
naga --
make sure you have a subdirectory called tcpdf with the tcpdf files(not the wrapper) in there. The wrapper files go in extensions\tcpdf in there you have a sub directory tcpdf that contains the tcpdf files
Hi I got the following error require_once(D:\Dev\Apache\htdocs\first\protected\extensions\tcpdf/tcpdf/tcpdf.php): failed to open stream: No such file or director,
You can get source class of TCPDF from site mentioned by extension author (www.tecnick.com) or from www.tcpdf.org. But both sites gets often overloaded and results in timeouts instead of real content. In this situation, you may try to get the class from SourceForge, at: http://sourceforge.net/projects/tcpdf/.
Hi, I want to use a table in the Header. It dosen't work. Any Idea??
hi guys... I setting up this extension right now, but... i have one problem!! browser send me an alert.. it says:"file does not begin with '%PDF-'". I try the tcpdf library in a stand alone script (withous using YII) and it work fine!! i need help! thank you
PS i'm sorry for my bad english, i'm italian!! :D
An extension should actually give some functionality specific to the yii framework. This is actually just a "include tcpdf" done the yii way - there is NO functionalty like "print model data" or an auto-pdf-view generation or ANYTHING of interest. Thus it is nothing more than a fake addition to this extension collection and should be removed. A better place for this would be the tips and snippets wiki to show a way how to include libraries. But please rempove it from here to keep a clean extension collection.
I think you could add to the constructor an array parameter to put main information. Like this
$params = array("author" => "Nicola Asuni", "title" =>TCPDF Example 002", "subject" => "TCPDF Tutorial", "keywords"=>array("TCPDF, PDF, example, test, guide"), "header" => false, "footer" => false, "output" => "example_002.pdf");
$pdf = Yii::createComponent('application.extensions.tcpdf.ETcPdf', 'P', 'cm', 'A4', true, 'UTF-8', $params);
I think this should be more Yii-style.
Great Job!
Leave a comment
Please login to leave your comment.