带有TCPDF库的Datamatrix 16x48用于PHP

时间:2017-04-18 15:48:22

标签: php tcpdf datamatrix

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

文档要求的格式是16x48 datamatrix 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文件中,我评论了所有大小的数据矩阵,只留下了16x48(因为如果我全部留下,我的标准尺寸为32x32)。

这就是我得到的:

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

我做错了什么?

1 个答案:

答案 0 :(得分:0)

Datamatrix构造函数检查要使用的最合适的表单大小。表单定义(正方形和矩形)在Datamatrix类(l.147到l.177)中定义。出于测试目的,我在正方形之前放置了矩形形式定义。如果给定的数据不是太长,它会生成一个16x48的数据矩阵,但我没有测试数据的完整性。 include / 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,...