mirror of
https://github.com/vdm-io/tcpdf.git
synced 2024-11-26 06:17:33 +00:00
5.9.117
This commit is contained in:
parent
6b246ab063
commit
d303c731f8
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : 2dbarcodes.php
|
||||
// Version : 1.0.011
|
||||
// Version : 1.0.012
|
||||
// Begin : 2009-04-07
|
||||
// Last Update : 2011-09-13
|
||||
// Last Update : 2011-09-15
|
||||
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
@ -37,14 +37,14 @@
|
||||
* PHP class to creates array representations for 2D barcodes to be used with TCPDF.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.011
|
||||
* @version 1.0.012
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF2DBarcode
|
||||
* PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org).
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.011
|
||||
* @version 1.0.012
|
||||
* @author Nicola Asuni
|
||||
*/
|
||||
class TCPDF2DBarcode {
|
||||
@ -85,7 +85,7 @@ class TCPDF2DBarcode {
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodeSVG($w=3, $h=3, $color='black') {
|
||||
// send XML headers
|
||||
// send headers
|
||||
$code = $this->getBarcodeSVGcode($w, $h, $color);
|
||||
header('Content-Type: application/svg+xml');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
@ -114,11 +114,10 @@ class TCPDF2DBarcode {
|
||||
$svg .= "\t".'<desc>'.strtr($this->barcode_array['code'], $repstr).'</desc>'."\n";
|
||||
$svg .= "\t".'<g id="elements" fill="'.$color.'" stroke="none">'."\n";
|
||||
// print barcode elements
|
||||
$xstart = 0;
|
||||
$y = 0;
|
||||
// for each row
|
||||
for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) {
|
||||
$x = $xstart;
|
||||
$x = 0;
|
||||
// for each column
|
||||
for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) {
|
||||
if ($this->barcode_array['bcode'][$r][$c] == 1) {
|
||||
@ -146,11 +145,10 @@ class TCPDF2DBarcode {
|
||||
// replace table for special characters
|
||||
$html = '<div style="font-size:0;position:relative;">'."\n";
|
||||
// print barcode elements
|
||||
$xstart = 0;
|
||||
$y = 0;
|
||||
// for each row
|
||||
for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) {
|
||||
$x = $xstart;
|
||||
$x = 0;
|
||||
// for each column
|
||||
for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) {
|
||||
if ($this->barcode_array['bcode'][$r][$c] == 1) {
|
||||
@ -165,6 +163,70 @@ class TCPDF2DBarcode {
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a PNG image representation of barcode (requires GD or Imagick library).
|
||||
* @param $w (int) Width of a single rectangle element in pixels.
|
||||
* @param $h (int) Height of a single rectangle element in pixels.
|
||||
* @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
|
||||
* @return image or false in case of error.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodePNG($w=3, $h=3, $color=array(0,0,0)) {
|
||||
// calculate image size
|
||||
$width = ($this->barcode_array['num_cols'] * $w);
|
||||
$height = ($this->barcode_array['num_rows'] * $h);
|
||||
if (function_exists('imagecreate')) {
|
||||
// GD library
|
||||
$imagick = false;
|
||||
$png = imagecreate($width, $height);
|
||||
$bgcol = imagecolorallocate($png, 255, 255, 255);
|
||||
imagecolortransparent($png, $bgcol);
|
||||
$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
|
||||
} elseif (extension_loaded('imagick')) {
|
||||
$imagick = true;
|
||||
$bgcol = new imagickpixel('rgb(255,255,255');
|
||||
$fgcol = new imagickpixel('rgb('.$color[0].','.$color[1].','.$color[2].')');
|
||||
$png = new Imagick();
|
||||
$png->newImage($width, $height, 'none', 'png');
|
||||
$bar = new imagickdraw();
|
||||
$bar->setfillcolor($fgcol);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// print barcode elements
|
||||
$y = 0;
|
||||
// for each row
|
||||
for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) {
|
||||
$x = 0;
|
||||
// for each column
|
||||
for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) {
|
||||
if ($this->barcode_array['bcode'][$r][$c] == 1) {
|
||||
// draw a single barcode cell
|
||||
if ($imagick) {
|
||||
$bar->rectangle($x, $y, ($x + $w), ($y + $h));
|
||||
} else {
|
||||
imagefilledrectangle($png, $x, $y, ($x + $w), ($y + $h), $fgcol);
|
||||
}
|
||||
}
|
||||
$x += $w;
|
||||
}
|
||||
$y += $h;
|
||||
}
|
||||
// send headers
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
if ($imagick) {
|
||||
$png->drawimage($bar);
|
||||
echo $png;
|
||||
} else {
|
||||
imagepng($png);
|
||||
imagedestroy($png);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the barcode.
|
||||
* @param $code (string) code to print
|
||||
|
@ -1,3 +1,6 @@
|
||||
5.9.117 (2011-09-17)
|
||||
- TCPDFBarcode and TCPDF2DBarcode were extended to include a method for exporting barcodes as PNG images.
|
||||
|
||||
5.9.116 (2011-09-14)
|
||||
- Datamatrix class was improved and documentation was fixed.
|
||||
|
||||
|
@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
|
||||
------------------------------------------------------------
|
||||
|
||||
Name: TCPDF
|
||||
Version: 5.9.116
|
||||
Release date: 2011-09-14
|
||||
Version: 5.9.117
|
||||
Release date: 2011-09-15
|
||||
Author: Nicola Asuni
|
||||
|
||||
Copyright (c) 2002-2011:
|
||||
|
71
barcodes.php
71
barcodes.php
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : barcodes.php
|
||||
// Version : 1.0.020
|
||||
// Version : 1.0.021
|
||||
// Begin : 2008-06-09
|
||||
// Last Update : 2011-09-13
|
||||
// Last Update : 2011-09-15
|
||||
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
@ -37,14 +37,14 @@
|
||||
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.020
|
||||
* @version 1.0.021
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDFBarcode
|
||||
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.020
|
||||
* @version 1.0.021
|
||||
* @author Nicola Asuni
|
||||
*/
|
||||
class TCPDFBarcode {
|
||||
@ -91,7 +91,7 @@ class TCPDFBarcode {
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodeSVG($w=2, $h=30, $color='black') {
|
||||
// send XML headers
|
||||
// send headers
|
||||
$code = $this->getBarcodeSVGcode($w, $h, $color);
|
||||
header('Content-Type: application/svg+xml');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
@ -163,6 +163,67 @@ class TCPDFBarcode {
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a PNG image representation of barcode (requires GD or Imagick library).
|
||||
* @param $w (int) Width of a single bar element in pixels.
|
||||
* @param $h (int) Height of a single bar element in pixels.
|
||||
* @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
|
||||
* @return image or false in case of error.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodePNG($w=2, $h=30, $color=array(0,0,0)) {
|
||||
// calculate image size
|
||||
$width = ($this->barcode_array['maxw'] * $w);
|
||||
$height = $h;
|
||||
if (function_exists('imagecreate')) {
|
||||
// GD library
|
||||
$imagick = false;
|
||||
$png = imagecreate($width, $height);
|
||||
$bgcol = imagecolorallocate($png, 255, 255, 255);
|
||||
imagecolortransparent($png, $bgcol);
|
||||
$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
|
||||
} elseif (extension_loaded('imagick')) {
|
||||
$imagick = true;
|
||||
$bgcol = new imagickpixel('rgb(255,255,255');
|
||||
$fgcol = new imagickpixel('rgb('.$color[0].','.$color[1].','.$color[2].')');
|
||||
$png = new Imagick();
|
||||
$png->newImage($width, $height, 'none', 'png');
|
||||
$bar = new imagickdraw();
|
||||
$bar->setfillcolor($fgcol);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// print bars
|
||||
$x = 0;
|
||||
foreach ($this->barcode_array['bcode'] as $k => $v) {
|
||||
$bw = round(($v['w'] * $w), 3);
|
||||
$bh = round(($v['h'] * $h / $this->barcode_array['maxh']), 3);
|
||||
if ($v['t']) {
|
||||
$y = round(($v['p'] * $h / $this->barcode_array['maxh']), 3);
|
||||
// draw a vertical bar
|
||||
if ($imagick) {
|
||||
$bar->rectangle($x, $y, ($x + $bw), ($y + $bh));
|
||||
} else {
|
||||
imagefilledrectangle($png, $x, $y, ($x + $bw), ($y + $bh), $fgcol);
|
||||
}
|
||||
}
|
||||
$x += $bw;
|
||||
}
|
||||
// send headers
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
if ($imagick) {
|
||||
$png->drawimage($bar);
|
||||
echo $png;
|
||||
} else {
|
||||
imagepng($png);
|
||||
imagedestroy($png);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the barcode.
|
||||
* @param $code (string) code to print
|
||||
|
10
tcpdf.php
10
tcpdf.php
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf.php
|
||||
// Version : 5.9.116
|
||||
// Version : 5.9.117
|
||||
// Begin : 2002-08-03
|
||||
// Last Update : 2011-09-14
|
||||
// Last Update : 2011-09-15
|
||||
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
|
||||
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS.
|
||||
// -------------------------------------------------------------------
|
||||
@ -136,7 +136,7 @@
|
||||
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 5.9.116
|
||||
* @version 5.9.117
|
||||
*/
|
||||
|
||||
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
|
||||
@ -148,7 +148,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php');
|
||||
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief PHP class for generating PDF documents without requiring external extensions.
|
||||
* @version 5.9.116
|
||||
* @version 5.9.117
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF {
|
||||
@ -159,7 +159,7 @@ class TCPDF {
|
||||
* Current TCPDF version.
|
||||
* @private
|
||||
*/
|
||||
private $tcpdf_version = '5.9.116';
|
||||
private $tcpdf_version = '5.9.117';
|
||||
|
||||
// Protected properties
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user