【问题标题】:Datamatrix 16x48 with TCPDF library for PHPDatamatrix 16x48 和 PHP 的 TCPDF 库
【发布时间】:2017-04-18 15:48:22
【问题描述】:

我需要在我的 pdf 上打印一个数据矩阵代码。

文档要求的格式是 16x48 数据矩阵 ECC 200。

示例代码如下:18800000571920119916120010109364801000000128003896

结果必须是这个:

我正在为 PHP 使用 TCPDF 库,这是我的代码:

$code = '18800000571920119916120010109364801000000128003896';
$style = array(
    'border' => true,
    '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
    'position' => 'S'
);
$pdf->write2DBarcode($code, 'DATAMATRIX', 150, 10, 80, 50, $style, 'N', true);

在 include/barcodes/datamatrix.php 文件中,我注释了 datamatrix 的所有尺寸,只留下 16x48(因为如果我全部留下,我得到的标准尺寸为 32x32)。

这是我得到的:

左边部分与正确结果非常相似,但右边部分完全是白色的!!!

我做错了什么?

【问题讨论】:

    标签: php tcpdf datamatrix


    【解决方案1】:

    Datamatrix 构造函数检查给定数据最适合使用的表单大小。表单定义(正方形和矩形)在 Datamatrix 类(l.147 到 l.177)中定义。出于测试目的,我将矩形形式定义放在正方形之前。如果给定的数据不是太长,它会生成一个 16x48 的数据矩阵,但我没有测试数据的完整性。包括/barcodes/datamatrix.php:

    protected $symbattr = array(
        // rectangular form (currently unused) ---------------------------------------------------------------------------
        array(0x008,0x012,0x006,0x010,0x008,0x012,0x006,0x010,0x001,0x001,0x001,0x005,0x007,0x001,0x005,0x007), // 8x18
        array(0x008,0x020,0x006,0x01c,0x008,0x010,0x006,0x00e,0x001,0x002,0x002,0x00a,0x00b,0x001,0x00a,0x00b), // 8x32
        array(0x00c,0x01a,0x00a,0x018,0x00c,0x01a,0x00a,0x018,0x001,0x001,0x001,0x010,0x00e,0x001,0x010,0x00e), // 12x26
        array(0x00c,0x024,0x00a,0x020,0x00c,0x012,0x00a,0x010,0x001,0x002,0x002,0x00c,0x012,0x001,0x00c,0x012), // 12x36
        array(0x010,0x024,0x00e,0x020,0x010,0x012,0x00e,0x010,0x001,0x002,0x002,0x020,0x018,0x001,0x020,0x018), // 16x36
        array(0x010,0x030,0x00e,0x02c,0x010,0x018,0x00e,0x016,0x001,0x002,0x002,0x031,0x01c,0x001,0x031,0x01c),  // 16x48
    
        // square form ---------------------------------------------------------------------------------------
        array(0x00a,0x00a,0x008,0x008,0x00a,0x00a,0x008,0x008,0x001,0x001,0x001,0x003,0x005,0x001,0x003,0x005), // 10x10
        array(0x00c,0x00c,0x00a,0x00a,0x00c,0x00c,0x00a,0x00a,0x001,0x001,0x001,0x005,0x007,0x001,0x005,0x007), // 12x12
        array(0x00e,0x00e,0x00c,0x00c,0x00e,0x00e,0x00c,0x00c,0x001,0x001,0x001,0x008,0x00a,0x001,0x008,0x00a), // 14x14
        array(0x010,0x010,...
    

    【讨论】:

      猜你喜欢
      • 2014-05-14
      • 2021-09-19
      • 1970-01-01
      • 2013-05-28
      • 2015-12-29
      • 2019-07-16
      • 1970-01-01
      • 2020-09-27
      • 2012-09-25
      相关资源
      最近更新 更多