Php 在pdf文件codeigniter中启用tcpdf打印选项

Php 在pdf文件codeigniter中启用tcpdf打印选项,php,codeigniter,pdf,Php,Codeigniter,Pdf,我已经在Codeigniter中使用TCPDF生成了PDF文件。使用上述代码启用了打印选项,但它不起作用?为什么?请帮帮我。是的,我知道了。事实上,最新版本代码不支持蒙特塞拉特字体,无论何时我们使用此字体打印选项都不起作用。请使用helvetica字体。它会起作用。您能在这里粘贴代码吗?因此,我可以帮助您。PDF文件中启用打印选项的代码生成$user\u pass和$owner\u pass PDF文件中启用了相同的打印选项,但当我单击该选项时,未通过引用工作此“我不打印”选项已启用,但未工作我

我已经在Codeigniter中使用TCPDF生成了PDF文件。使用上述代码启用了打印选项,但它不起作用?为什么?请帮帮我。

是的,我知道了。事实上,最新版本代码不支持蒙特塞拉特字体,无论何时我们使用此字体打印选项都不起作用。请使用helvetica字体。它会起作用。

您能在这里粘贴代码吗?因此,我可以帮助您。PDF文件中启用打印选项的代码生成$user\u pass和$owner\u pass PDF文件中启用了相同的打印选项,但当我单击该选项时,未通过引用工作此“我不打印”选项已启用,但未工作我在下面发布的代码,请按照此方式生成.PDF文件,但我希望启用打印选项,并单击打印选项打印任何内容。根据thik链接:您的代码必须是最新版本。是的,我得到了它。事实上,最新版本代码不受支持蒙特塞拉特字体每当我们使用此字体打印选项不起作用时。请使用helvetica字体。它将工作
$pdf->SetProtection($permissions=array('print', 'copy'),
$user_pass=$otp, $owner_pass=$otp, $mode=0, $pubkeys=null);
That is how pdf generates :

require_once('tcpdf_include.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Ken');
$pdf->SetTitle('Upgraded Images');
$pdf->SetSubject('Order Label');
$pdf->SetKeywords('upgraded images, PDF, ken greenle, upgradedimages.com, print label');

// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 049', PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins


// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}

// ---------------------------------------------------------

// set font
$pdf->SetFont('helvetica', '', 10);

// add a page
$pdf->AddPage();


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

IMPORTANT:
If you are printing user-generated content, tcpdf tag can be unsafe.
You can disable this tag by setting to false the K_TCPDF_CALLS_IN_HTML
constant on TCPDF configuration file.

For security reasons, the parameters for the 'params' attribute of TCPDF
tag must be prepared as an array and encoded with the
serializeTCPDFtagParameters() method (see the example below).

 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
$order_id = $_GET['order_id'];
/* get order details here*/
$sql = "select o.*,u.`first_name`,u.`last_name` from `tbl_orders` as o inner join `tbl_users` as u on o.`client_id` = u.`user_id` where o.`order_id` = '".$order_id."'";
$query = mysqli_query($con,$sql);
$result = mysqli_fetch_assoc($query);
$customer_name = $result['first_name'].' '.$result['last_name'];
$order_number = $result['order_number'];
$instructions = $result['instructions'];
$product_return_option = $result['product_return_option'];
$number_of_packages = $result['number_of_packages'];
$order_date = date("jS F", strtotime($result['order_date']));
if($result['rush_service'] != '')
{
    $rush_service = 'RUSH';
}
else
{
    $rush_service = '';
}

/* end here */
$html = '
<div style="border:2px solid #222; padding-right:10px;">
<table cellpadding="0" border="0" cellspacing="0" style="font-size:14px;">
 <tr>
 <td>
    <table width="100%">
    <tr>
    <td align="left">
    <span style="color:#000; text-align: left; font-size:24px;text-transform: uppercase;max-width: 200px;"><strong>'.$customer_name.'</strong></span><br>
    </td>
    <td align="left">
    <br>
    <span style="color:#000; text-align: right; font-size:14px;"><strong>'.$order_number.'</strong></span><br>
    <span>&nbsp;</span><span>&nbsp;</span><span style="color:#000; text-align: right; font-size:14px;"><strong>'.$order_date.'</strong></span>
    <br>
    </td>
    </tr>
    </table>
 </td>
 </tr>

 <tr>
 <td>
    <table width="100%">
    <tr>
        <td style="height:10px;">&nbsp;</td>
    </tr>
    <tr>
    <td align="left" style="color:#000; text-align: left; #000;font-weight: bold; font-size:14px;">
    '.$instructions.'
    </td>
    </tr>
    <tr>
        <td style="height:10px;">&nbsp;</td>
    </tr>
    </table>
 </td>
 </tr>
 <tr>
 <td>
    <table width="100%">
    <tr>
    <td style="">

    <span style="color:#000; text-align: left; font-size:54px;"><strong>'.$rush_service.'</strong></span><br>
    </td>
    <td align="left" style="padding-right:20px;">
    <span style="color:#000; text-align: right; font-size:14px;"><strong>'.$product_return_option.'</strong></span><br>
    </td>
    <td align="left" style="padding-right:20px;">
    <span style="color:#000; text-align: right; font-size:14px;"><strong>['.$number_of_packages.']</strong></span><br>
    </td>
    </tr>
    </table>
 </td>
 </tr>
  </table>
  </div>';


// output the HTML content
$pdf->writeHTML($html, true, 0, true, 0);

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// reset pointer to the last page
$pdf->lastPage();

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('text.pdf', 'D');exit;
// D for download and when you write I it will get opened.