public function domeshippingnew()
    {
        $this->layout = '';
        $this->autoRender = false;
        $this->loadModel('Template');
        $id = $this->request->data['pkorderid'];
        require_once APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php';
        spl_autoload_register('DOMPDF_autoload');
        $dompdf = new DOMPDF();
        $order = $this->getOpenOrderById($id);
        $serviceLevel = $order['shipping_info']->PostalServiceName;
        $assignedservice = $order['assigned_service'];
        $courier = $order['courier'];
        $manifest = $order['manifest'] == 1 ? '1' : '0';
        $cn22 = $order['cn22'] == 1 ? '1' : '0';
        $barcode = $order['assign_barcode'];
        $subtotal = $order['totals_info']->Subtotal;
        $totlacharge = $order['totals_info']->TotalCharge;
        $ordernumber = $order['num_order_id'];
        $fullname = $order['customer_info']->Address->FullName;
        $address1 = $order['customer_info']->Address->Address1;
        $address2 = $order['customer_info']->Address->Address2;
        $address3 = $order['customer_info']->Address->Address3;
        $town = $order['customer_info']->Address->Town;
        $resion = $order['customer_info']->Address->Region;
        $postcode = $order['customer_info']->Address->PostCode;
        $country = $order['customer_info']->Address->Country;
        $phone = $order['customer_info']->Address->PhoneNumber;
        $paymentmethod = $order['totals_info']->PaymentMethod;
        $postagecost = $order['totals_info']->PostageCost;
        $tax = $order['totals_info']->Tax;
        $barcode = $order['assign_barcode'];
        $items = $order['items'];
        $templateId = $order['template_id'];
        $str = '';
        $totlaWeight = 0;
        foreach ($items as $item) {
            $str .= '<tr>
							<td class="noleftborder rightborder bottomborder">' . $item->Quantity . ' x ' . substr($item->Title, 0, 15) . '</td>
							<td valign="top" class="center rightborder bottomborder">' . $item->Weight . '</td>
							<td valign="top" class="center norightborder bottomborder">£' . $item->Quantity * $item->PricePerUnit . '</td>
							</tr>';
            $totlaWeight = $totlaWeight + $item->Weight;
        }
        $address = '';
        //$address			.=		($address2 != '') ? $address2.'<br>' : '' ;
        $address .= $address3 != '' ? $address3 . '<br>' : '';
        $address .= isset($town) ? $town . '<br>' : '';
        $address .= isset($resion) ? $resion . '<br>' : '';
        $address .= isset($postcode) ? $postcode . '<br>' : '';
        $address .= isset($country) ? $country . '<br>' : '';
        $recivedate = explode('T', $order['general_info']->ReceivedDate);
        $currentdate = date("j, F  Y");
        $setRepArray = array();
        $setRepArray[] = $address1;
        $setRepArray[] = $address2;
        $setRepArray[] = $address3;
        $setRepArray[] = $town;
        $setRepArray[] = $resion;
        $setRepArray[] = $address;
        $setRepArray[] = $country;
        $barcode = $order['assign_barcode'];
        $barcodenum = explode('.', $barcode);
        $barcodePath = Router::url('/', true) . 'img/orders/barcode/';
        $barcodeimg = '<img src=' . $barcodePath . $barcode . ' >';
        $barcodenum = explode('.', $barcode);
        $setRepArray[] = $barcodeimg;
        $setRepArray[] = $barcodenum[0];
        $setRepArray[] = $str;
        $setRepArray[] = $totlaWeight;
        $setRepArray[] = $tax;
        $setRepArray[] = $currentdate;
        $logopath = Router::url('/', true) . 'img/';
        $setRepArray[] = '<img src="' . $logopath . 'logo.jpg" >';
        $logo = '<img src="' . $logopath . 'logo.jpg" >';
        $signature = '<img src="' . $logopath . 'sig.jpg" >';
        $setRepArray[] = $logo;
        $setRepArray[] = '';
        $setRepArray[] = $signature;
        $dompdf->set_paper(array(0, 0, 245, 450), 'portrait');
        $cssPath = WWW_ROOT . 'css/';
        $imgPath = Router::url('/', true) . 'img/';
        /*$html 	= '<body>
        <div id="label">
        <div class="container">
        <table class="header row">
        <tr>
        <td width="60%">_LOGO_</td>
        <td width="40%" align="right">
        <table class="jpoststamp "><tr>
        <td class="stampnumber">1</td>
        <td class="jerseyserial">Postage Paid<br>
        Jersey<br>
        Serial 216</td>
        </tr>
        <tr>
        <td colspan="2" class="vatnumber">UK Import VAT Pre-Paid<br>
        Auth No 393</td>
        </tr>
        </table>
        </td>
        </tr>
        </table>
        
        <div class="cn22 row">
        <table>
        <tr>
        <td class="leftside leftheading"><h1>CUSTOMS DECLARATION</h1>
        Great Britain
        </td>
        <td class="rightside rightheading"><h1>CN 22</h1>
        May be opened officially
        </td>
        </tr>
        </table>
        
        
        <div class="fullwidth"><h2>Important!</h2></div>
        <div class="producttype">
        <table>
        <tr>
        <td><span>&nbsp;</span>Gift</td>
        <td><span>&nbsp;</span>Documents</td>
        <td><span>&nbsp;</span>Commercial</td>
        <td><span>X</span>Merchandise</td>
        </tr>
        </table>
        
        </div>
        
        <table class="" cellpadding="5px" cellspacing="0" style="border-collapse:collapse" width="100%">
        <tr>
        <th class="noleftborder topborder rightborder bottomborder" width="60%">Quantity and detailed description of contents</th>
        <th valign="top" class="center topborder rightborder bottomborder " width="20%">Weight (kg)</th>
        <th valign="top" class="center topborder norightborder bottomborder" width="20%">Value</th>
        </tr>
        _ORDERDETAIL_
        <tr>
        <td valign="top" class="noleftborder rightborder bottomborder"></td>
        <td valign="top " class="rightborder bottomborder">
        <table>
        <tr><td class="center">P & P<br>VAT</td></tr>
        </table></td>
        <td valign="top " class="norightborder bottomborder">
        <table>
        <tr><td class="center">£ 0<br>£_TAX_</td></tr>
        </table>
        </td>
        </tr>
        <tr>
        <td valign="top" height="auto" class="noleftborder bottomborder rightborder">
        <table height="100%">
        <tr><td><span class="bold">For commercial items only</span><br>If known, HS tariff number and country of origin of goods</td></tr>
        <tr><td class="center">876534</td></tr>
        </table></td>
        <td valign="top" height="auto" class="bottomborder rightborder">
        <table height="100%" >
        <tr><td class="center bold">Total Weight (kg)</td></tr>
        <tr><td class="center">175.00</td></tr>
        </table></td>
        <td valign="top" height="auto"  class="norightborder bottomborder">
        <table height="100%">
        <tr><td class="center bold">Total Value</td></tr>
        <tr><td class="center">£101.98</td></tr>
        </table></td>
        </tr>
        </table>
        <div class="fullwidth"><p>I the undersigned, whose name and address are given on the item, certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or articles prohibited by legislation or by postal or customs regulations.</p>
        <table>
        <tr>
        <td class="date bold">Date: _CURRENTDATE_</td>
        <td class="sign right">_SIGNATURE_</td>
        </tr>
        </table>
        </div>
        </div>
        <div class="footer row">
        
        <table>
        <tr>
        <td class="leftside leftheading address"><h3>SHIP TO:</h3>
        <span class="bold">_ADDRESS1_</span><br>
        _ADDRESS_
        United Country<br>
        </td>
        <td class="rightside rightheading leftborder">
        <div class="tracking bottomborder"><h3>TRACKING #:</h3>
        1Z A90 26X 03 9015 6318
        </div>
        <div class="barcode center">Purchase Order<div>_BARCODEIMAGE_</div>_BARCODENUMBER_</div>
        </td>
        </tr>
        </table>
        </div>
        <div class="footer row"><span class="bold">If undelivered please return to:</span> Unit 4, Cargo Centre, Jersey Airport, L’Avenue de la Commune, St Peter, JE3 7BY</div>
        
        </div>
        </div>
        
        </body>';*/
        $htmlcontent = $this->Template->find('first', array('conditions' => array('Template.id' => $templateId)));
        $html = $htmlcontent['Template']['html'];
        $html .= '<style>' . file_get_contents($cssPath . 'pdfstyle.css') . '</style>';
        $html = $this->setReplaceValueLabel($setRepArray, $html);
        $dompdf->load_html(utf8_decode($html), Configure::read('App.encoding'));
        $dompdf->render();
        $dompdf->stream("OrderIdslip-{$ordernumber}.pdf");
        $imgPath = WWW_ROOT . 'img/printPDF/';
        $path = Router::url('/', true) . 'img/printPDF/';
        $date = new DateTime();
        $timestamp = $date->getTimestamp();
        $name = 'Packagin_Slip_' . $ordernumber . '.pdf';
        file_put_contents($imgPath . $name, $dompdf->output());
        $serverPath = $path . $name;
        $sendData = array('printerId' => '74828', 'title' => 'Now Print', 'contentType' => 'pdf_uri', 'content' => $serverPath, 'source' => 'Direct');
        App::import('Controller', 'Coreprinters');
        $Coreprinter = new CoreprintersController();
        $d = $Coreprinter->toPrint($sendData);
        pr($d);
        exit;
    }
 public function toPrint($customFeilds = array())
 {
     CoreprintersController::run($customFeilds);
 }