Html 2 PDF cakephp

1.Download html2pdf
2.Include the files in controller method as below

$this->autoRender = false;
$id = $this->params['pass'][0];
$this->Order=new Order();
$order = $this->Order->find('first', array('conditions'=>array(''=>$id)));
$view = new View($this, false);
$view->viewPath = 'orders';
$view_output = $view->render('admin_order_pdf');

$tcpdf = new XTCPDF();
$textfont = 'freesans'; // looks better, finer, and more condensed than 'dejavusans'

$tcpdf->SetAuthor("Worldwide Stone Order Details");
$tcpdf->SetAutoPageBreak( false );
$tcpdf->xheadercolor = array(150,250,170);
$tcpdf->xheadertext = '';
$tcpdf->xfootertext = 'Copyright © %d Worldwide Stone Order Details. All rights reserved.';
//$tcpdf->Cell(0,14, $html_for_pdf, 0,1,'L');

$tcpdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html_for_pdf, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$tcpdf->Output('test.pdf', 'D');
if (!$id)
$this->Session->setFlash('Sorry, there was no property ID submitted.');
$this->redirect(array('action'=>'admin_order_list'), null, true);
Configure::write('debug',0); // Otherwise we cannot use this method while developing

$id = intval($id);

// $property = $this->__admin_order_view($id); // here the data is pulled from the database and set for the view
$property = $this->Order->find('first',array('conditions'=>array(''=>$id)));
// pr($property);

if (empty($property))
$this->Session->setFlash('Sorry, there is no property with the submitted ID.');
$this->redirect(array('action'=>'admin_order_list'), null, true);

$this->layout = 'pdf'; //this will use the pdf.ctp layout


3.The view file to be converted to pdf is

<div><h4><b>Order Details Of </b></h4></div>
<h2>Order Information</h2>
&lt;img width=&quot;100&quot; height=&quot;100&quot; src=&quot;" /&gt;
<p>Order Name :<span><br />
Template Name : <br />
Material  Name : <br />
Material  Id : 
<h2>Template Information</h2>
<p>Template Title : <br />
Template Price : <br />
Template Price : <br />
Template Created : <br />
Die Id  : <br />
Die Styles : <br />
Die Styles Codes : <br />
Die Styles Complexity : <br />
Die Styles Instances : <br />
Die Styles Special Die Aplicables :<br />
Original width(Single/Double) : <br />
Width in Inches :<br />
Height in Inches  :<br />
Estimated Area in inches  :<br />
Estimated Area in cms :  :<br />
Thickness 4ins :<br />
Thickness 6ins :<br />
Thickness 8ins :
<h2>Material Information</h2>
<p>Material Name :<span><br />
Material Price :<span><br />
Material Country Of Origin :<br />
Material Stone Type : <br />
Material Color Tone :<br />
Material Instance : <br />
Material Color Code :<br />

3 thoughts on “Html 2 PDF cakephp

  1. you aгe truly a excellent webmaster. Ꭲhe site
    loading velocity іs incredible. Іt sort of feels that you’re doing any unique trick.
    Furtһermore, The contents ɑrе masterpiece. yⲟu hаve done a ɡreat activity in this topic!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s