繁体   English   中英

如何修复 linux 服务器中的“TCPPDF 条码不显示”?

[英]How to fix 'TCPDF barcode not show' in linux server?

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

我正在使用 codeigniter 和 composer tcpdf

本地截图:本地截图 windows

截图 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM