TCPDF

Hi,

I have downloaded the TCPDF extension and put it into the extension folder of my application. When i was running the my application the 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…

Make sure your paths are correct and also use DIRECTORY_SEPARATOR … seems you have an issue there… "\tcpdf/tcpdf/"

HI,

Personally, I don’t use any extension. I have downloaded the tcpdf code and put it in extensions/tcpdf folder.

And then, in the code (for example: in a static function of a Yii model), I do :




//Prepare the pdf exporter

$html2pdfPath = Yii::getPathOfAlias('ext.tcpdf');

spl_autoload_unregister(array('YiiBase','autoload'));

require_once("$html2pdfPath/config/lang/fra.php");

require_once("$html2pdfPath/tcpdf.php");

$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

spl_autoload_register(array('YiiBase','autoload'));

		

// set document information

$pdf->SetCreator(PDF_CREATOR);	

		

$pdf->SetTitle("title");		

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "title", "subtitle");

$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));

$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);

$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

$pdf->SetFont('helvetica', '', <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />;

$pdf->SetTextColor(80,80,80);

$pdf->AddPage();

		 

//Write the html from a Yii view

$html = Yii::app()->controller->renderPartial('//viewPath/_export'), true,true);


//Convert the Html to a pdf document

$pdf->writeHTML($html, true, false, true, false, '');

		

// reset pointer to the last page

$pdf->lastPage();


//Close and output PDF document

$pdf->Output('filename.pdf', 'I');




[color="#006400"]/* moved to extensions forum */[/color]

Hi mixeart, why my page return

[color="#FF0000"][b]Error 400

Your request is invalid.[/b][/color]

I’ve a controller with actionView_Pdf() then renderPartial a view_pdf.php file :( what wrong ?

controller code:


public function actionView_Pdf($id)

	{

		$this->renderPartial('view_pdf',array(

			'model'=>$this->loadModel($id)

		));

	}

tnx

Please check that you have passed your request with id. Like this, index.php?r=site_id/action_id&id=your value