CakePdf插件-如何编写条形码和二维码 [英] CakePdf Plugin - how to write barcode and qr code

查看:129
本文介绍了CakePdf插件-如何编写条形码和二维码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需安装 CakePDF插件,然后使用

Just installed the CakePDF plugin, and using TCPDF as the engine. Now I'm trying to write bar codes and QR codes, but nothing I've tried has worked.

如果我直接使用 TCPDF引擎,我可以获得条形码和二维码,但现在我正在尝试使用插件,我不确定该怎么做,而只是直接重写我对引擎所做的事情……这让我想知道插件的意义是什么.

I can get bar codes and qr codes to work if I use the TCPDF engine directly, but now that I'm trying to use the plugin, I'm not sure what to do other that just rewrite what I did with the engine directly... which makes me wonder what the point of the plugin would be then.

我缺少明显的东西吗?如果我使用CakePDF插件,是否可以通过TCPDF创建条形码和二维码,还是应该直接将插件报废并直接带引擎使用?

Am I missing something obvious? Can I create bar codes and qr codes via TCPDF if I'm using the CakePDF Plugin or should I just scrap the plugin and go directly w/ the engine?

推荐答案

CakePDF插件是HTML到PDF的包装器,仅此而已.看一下源代码,它不支持单个PDF引擎的所有漂亮功能,它纯粹是"将HTML传递给引擎并返回输出".

The CakePDF plugin is a HTML to PDF wrapper, nothing more nothing less. Look at the source, it doesn't support all the nifty features of the individual PDF engines, it's purely "pass HTML to engine and return the output".

该插件的目的是将其轻松地与CakePHP视图集成.如果您需要更多控制权,那么通常需要直接使用引擎.

The point of the plugin is to integrate this easily with CakePHP views. If you need more control, then you'll usually need to to make use of the engines directly.

话虽如此,TCPDF支持特殊的<tcpdf>标记以通过HTML调用方法,这可能适合您的需求.

That being said, TCPDF supports a special <tcpdf> tag to invoke methods via HTML, which might suit your needs.

示例:

<?php
$params = TCPDF_STATIC::serializeTCPDFtagParameters(array(
    'CODE 39', 'C39', '', '', 80, 30, 0.4,
    array(
        'position' => 'S',
        'border' => true,
        'padding' => 4,
        'fgcolor' => array(0,0,0),
        'bgcolor' => array(255,255,255),
        'text' => true,
        'font' => 'helvetica',
        'fontsize' => 8,
        'stretchtext' => 4
    ),
    'N'
));
?>
<tcpdf method="write1DBarcode" params="<?php echo $params; ?>" />

另请参见 TCPDF示例:以HTML调用TCPDF方法

See also TCPDF Examples: call TCPDF methods in HTML

这篇关于CakePdf插件-如何编写条形码和二维码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆