本文整理汇总了PHP中TCPDF2DBarcode::getBarcodeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF2DBarcode::getBarcodeArray方法的具体用法?PHP TCPDF2DBarcode::getBarcodeArray怎么用?PHP TCPDF2DBarcode::getBarcodeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF2DBarcode
的用法示例。
在下文中一共展示了TCPDF2DBarcode::getBarcodeArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write2DBarcode
/**
* Print 2D Barcode.
* @param $code (string) code to print
* @param $type (string) type of barcode (see tcpdf_barcodes_2d.php for supported formats).
* @param $x (int) x position in user units
* @param $y (int) y position in user units
* @param $w (int) width in user units
* @param $h (int) height in user units
* @param $style (array) array of options:<ul>
* <li>boolean $style['border'] if true prints a border around the barcode</li>
* <li>int $style['padding'] padding to leave around the barcode in barcode units (set to 'auto' for automatic padding)</li>
* <li>int $style['hpadding'] horizontal padding in barcode units (set to 'auto' for automatic padding)</li>
* <li>int $style['vpadding'] vertical padding in barcode units (set to 'auto' for automatic padding)</li>
* <li>int $style['module_width'] width of a single module in points</li>
* <li>int $style['module_height'] height of a single module in points</li>
* <li>array $style['fgcolor'] color array for bars and text</li>
* <li>mixed $style['bgcolor'] color array for background or false for transparent</li>
* <li>string $style['position'] barcode position on the page: L = left margin; C = center; R = right margin; S = stretch</li><li>$style['module_width'] width of a single module in points</li>
* <li>$style['module_height'] height of a single module in points</li></ul>
* @param $align (string) Indicates the alignment of the pointer next to barcode insertion relative to barcode height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
* @param $distort (boolean) if true distort the barcode to fit width and height, otherwise preserve aspect ratio
* @author Nicola Asuni
* @since 4.5.037 (2009-04-07)
* @public
*/
public function write2DBarcode($code, $type, $x = '', $y = '', $w = '', $h = '', $style = '', $align = '', $distort = false)
{
if (TCPDF_STATIC::empty_string(trim($code))) {
return;
}
require_once dirname(__FILE__) . '/tcpdf_barcodes_2d.php';
// save current graphic settings
$gvars = $this->getGraphicVars();
// create new barcode object
$barcodeobj = new TCPDF2DBarcode($code, $type);
$arrcode = $barcodeobj->getBarcodeArray();
if ($arrcode === false or empty($arrcode) or !isset($arrcode['num_rows']) or $arrcode['num_rows'] == 0 or !isset($arrcode['num_cols']) or $arrcode['num_cols'] == 0) {
$this->Error('Error in 2D barcode string');
}
// set default values
if (!isset($style['position'])) {
$style['position'] = '';
}
if (!isset($style['fgcolor'])) {
$style['fgcolor'] = array(0, 0, 0);
// default black
}
if (!isset($style['bgcolor'])) {
$style['bgcolor'] = false;
// default transparent
}
if (!isset($style['border'])) {
$style['border'] = false;
}
// padding
if (!isset($style['padding'])) {
$style['padding'] = 0;
} elseif ($style['padding'] === 'auto') {
$style['padding'] = 4;
}
if (!isset($style['hpadding'])) {
$style['hpadding'] = $style['padding'];
} elseif ($style['hpadding'] === 'auto') {
$style['hpadding'] = 4;
}
if (!isset($style['vpadding'])) {
$style['vpadding'] = $style['padding'];
} elseif ($style['vpadding'] === 'auto') {
$style['vpadding'] = 4;
}
$hpad = 2 * $style['hpadding'];
$vpad = 2 * $style['vpadding'];
// cell (module) dimension
if (!isset($style['module_width'])) {
$style['module_width'] = 1;
// width of a single module in points
}
if (!isset($style['module_height'])) {
$style['module_height'] = 1;
// height of a single module in points
}
if ($x === '') {
$x = $this->x;
}
if ($y === '') {
$y = $this->y;
}
// check page for no-write regions and adapt page margins if necessary
list($x, $y) = $this->checkPageRegions($h, $x, $y);
// number of barcode columns and rows
$rows = $arrcode['num_rows'];
$cols = $arrcode['num_cols'];
if ($rows <= 0 || $cols <= 0) {
$this->Error('Error in 2D barcode string');
}
// module width and height
$mw = $style['module_width'];
$mh = $style['module_height'];
if ($mw <= 0 or $mh <= 0) {
$this->Error('Error in 2D barcode string');
//.........这里部分代码省略.........
示例2: write2DBarcode
/**
* Print 2D Barcode.
* @param string $code code to print
* @param string $type type of barcode (see 2dbarcodes.php for supported formats).
* @param int $x x position in user units
* @param int $y y position in user units
* @param int $w width in user units
* @param int $h height in user units
* @param array $style array of options:<ul><li>boolean $style['border'] if true prints a border around the barcode</li><li>int $style['padding'] padding to leave around the barcode in user units</li><li>array $style['fgcolor'] color array for bars and text</li><li>mixed $style['bgcolor'] color array for background or false for transparent</li></ul>
* @param string $align Indicates the alignment of the pointer next to barcode insertion relative to barcode height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
* @author Nicola Asuni
* @since 4.5.037 (2009-04-07)
* @access public
*/
public function write2DBarcode($code, $type, $x = '', $y = '', $w = '', $h = '', $style = '', $align = '')
{
if ($this->empty_string($code)) {
return;
}
require_once dirname(__FILE__) . '/2dbarcodes.php';
// save current graphic settings
$gvars = $this->getGraphicVars();
// create new barcode object
$barcodeobj = new TCPDF2DBarcode($code, $type);
$arrcode = $barcodeobj->getBarcodeArray();
if ($arrcode === false) {
$this->Error('Error in 2D barcode string');
}
// set default values
if (!isset($style['padding'])) {
$style['padding'] = 0;
}
if (!isset($style['fgcolor'])) {
$style['fgcolor'] = array(0, 0, 0);
// default black
}
if (!isset($style['bgcolor'])) {
$style['bgcolor'] = false;
// default transparent
}
if (!isset($style['border'])) {
$style['border'] = false;
}
// set foreground color
$this->SetDrawColorArray($style['fgcolor']);
if ($this->empty_string($x)) {
$x = $this->GetX();
}
if ($this->rtl) {
$x = $this->w - $x;
}
if ($this->empty_string($y)) {
$y = $this->GetY();
}
if ($this->empty_string($w) or $w <= 0) {
if ($this->rtl) {
$w = $x - $this->lMargin;
} else {
$w = $this->w - $this->rMargin - $x;
}
}
if ($this->empty_string($h) or $h <= 0) {
// 2d barcodes are square by default
$h = $w;
}
$prev_x = $this->x;
if ($this->checkPageBreak($h, $y)) {
$y = $this->GetY() + $this->cMargin;
if ($this->rtl) {
$x += $prev_x - $this->x;
} else {
$x += $this->x - $prev_x;
}
}
// calculate barcode size (excluding padding)
$bw = $w - 2 * $style['padding'];
$bh = $h - 2 * $style['padding'];
// calculate starting coordinates
if ($this->rtl) {
$xpos = $x - $w;
} else {
$xpos = $x;
}
$xpos += $style['padding'];
$ypos = $y + $style['padding'];
// barcode is always printed in LTR direction
$tempRTL = $this->rtl;
$this->rtl = false;
// print background color
if ($style['bgcolor']) {
$this->Rect($x, $y, $w, $h, $style['border'] ? 'DF' : 'F', '', $style['bgcolor']);
} elseif ($style['border']) {
$this->Rect($x, $y, $w, $h, 'D');
}
// print barcode cells
if ($arrcode !== false) {
$rows = $arrcode['num_rows'];
$cols = $arrcode['num_cols'];
// calculate dimension of single barcode cell
$cw = $bw / $cols;
//.........这里部分代码省略.........