如何修复Linux服务器中的'TCPDF barcode not show'?



我已经在本地服务器(Windows(中使用了tcpdf条形码,并且条形码出现了。将我的代码上传到 linux 服务器后,只有条形码没有出现。

我正在使用代码点火器和作曲家 tcpdf

截图本地: 屏幕截图本地窗口

截图Linux服务器: 屏幕截图 Linux 服务器

这是我在应用程序/库中的代码:

<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Pdf extends TCPDF{
/**
* PDF filename
* @var String
*/
public function __construct(){
parent::__construct();
}
public function Header() {
// Logo
$image_file = base_url().'assets/images/logo/logo-wide.png';
$this->Image($image_file, 10, 10, 50, '', 'PNG', '', 'T', false, 300, 'C', false, false, 0, false, false, false);
}
// Page footer
public function Footer() {
$image_file = base_url().'assets/images/email/footer_email.png'; 
$this->Image($image_file, 0, 278, 210, 20, "PNG", "", "T", false, 300, "", false, false, 0, false, false, false);
// Position at 15 mm from bottom 
$this->SetY(0);
// Set font 
$this->SetFont("dejavusans", "", 9);
}
public function setupTicket($pdfName,$data){
$this->SetCreator(PDF_CREATOR);
$this->SetTitle($pdfName);
$this->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdfName, PDF_HEADER_STRING);
$this->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$this->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$this->SetDefaultMonospacedFont('helvetica');
$this->SetHeaderMargin(PDF_MARGIN_HEADER);
$this->SetFooterMargin(PDF_MARGIN_FOOTER);
$this->SetMargins(PDF_MARGIN_LEFT, 35, PDF_MARGIN_RIGHT);
$this->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$this->SetFont('helvetica', '', 9);
$this->setFontSubsetting(false);
$this->AddPage(); 
$style = array(
'border' => 2,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255)
'module_width' => 1, // width of a single module in points
'module_height' => 1 // height of a single module in points
);
$params = $this->serializeTCPDFtagParameters(array($data['link_barcode'], 'QRCODE,H', 132, "", 25, 25, $style, 'N'));
$htmlBarcode = '<tcpdf method="write2DBarcode" params="'.$params.'" />';
$content = '
<table cellpadding="4" >
<tr>
<td align="center" colspan="3" style="font-size:10px;border: 1px solid #e0e0e0;">
<b>'.$data["ticket_name"].'</b>
<br><br>'.$htmlBarcode.'
<br>
<b>'.$data["product_code"].'</b>
</td>
</tr>
</table>';
$this->writeHTML($content, true, false, true, false, '');
}
public function show_ticket($pdfName,$data){
$this->setupTicket($pdfName,$data);
$this->Output($pdfName.'.pdf', 'I');
}
}

我忘了更改我的tcpdf配置。如果使用作曲家,请打开文件夹vendor/tecnickcom/tcpdf/config/tcpdf_config.php。将define('K_TCPDF_CALLS_IN_HTML', false);更改为true

最新更新