Here is the CASE state for the the PDML::CloseTag function...
Again quick and dirty...
------------------------------------------------
case "BARCODE":
$this->_enforceState(51,50);
// auto-create a page if needed.
if (!$this->inPage) {
$this->inPage = true;
$this->AddPage();
}
This barcode doesn't really conform to barcode standards like EAN-18, but it outputs a barcode nonetheless.
My purposes for this is to generate a barcode for online job applications as a unique identifier for tracking.
I use PDML to generate the PDf application after the user/job-seeker has filled out the online counterpart. The barcode serves as a rendering of their session id...kind of a unique way of digital signature.
hope this helps, confuses, or whatever to whomever finds interest
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I took some code that was available on FPDF website and modified the PDML library to output a barcode with their tag system.
the PDML code looks something like this:
<barcode left=3% top=295px height=25 baseline="1">YOUR BARCODE DATA</barcode>
If anyone is interested, I'll post the mods.
COOL! Just post it!
I guess this is another feature where I may be underestimating the public interest in.
It seems like there are several different standards and not-so-standards defining how to render barcodes out there.
What barcode formats are considered the most useful? (and, out of curiosity, what do you use them for?)
Thanks,
Henri
function Code39($xpos, $ypos, $code, $baseline=0.5, $height=5){
$wide = $baseline;
$narrow = $baseline / 2 ;
$gap = $narrow;
$barChar['0'] = 'nnnwwnwnn';
$barChar['1'] = 'wnnwnnnnw';
$barChar['2'] = 'nnwwnnnnw';
$barChar['3'] = 'wnwwnnnnn';
$barChar['4'] = 'nnnwwnnnw';
$barChar['5'] = 'wnnwwnnnn';
$barChar['6'] = 'nnwwwnnnn';
$barChar['7'] = 'nnnwnnwnw';
$barChar['8'] = 'wnnwnnwnn';
$barChar['9'] = 'nnwwnnwnn';
$barChar['A'] = 'wnnnnwnnw';
$barChar['B'] = 'nnwnnwnnw';
$barChar['C'] = 'wnwnnwnnn';
$barChar['D'] = 'nnnnwwnnw';
$barChar['E'] = 'wnnnwwnnn';
$barChar['F'] = 'nnwnwwnnn';
$barChar['G'] = 'nnnnnwwnw';
$barChar['H'] = 'wnnnnwwnn';
$barChar['I'] = 'nnwnnwwnn';
$barChar['J'] = 'nnnnwwwnn';
$barChar['K'] = 'wnnnnnnww';
$barChar['L'] = 'nnwnnnnww';
$barChar['M'] = 'wnwnnnnwn';
$barChar['N'] = 'nnnnwnnww';
$barChar['O'] = 'wnnnwnnwn';
$barChar['P'] = 'nnwnwnnwn';
$barChar['Q'] = 'nnnnnnwww';
$barChar['R'] = 'wnnnnnwwn';
$barChar['S'] = 'nnwnnnwwn';
$barChar['T'] = 'nnnnwnwwn';
$barChar['U'] = 'wwnnnnnnw';
$barChar['V'] = 'nwwnnnnnw';
$barChar['W'] = 'wwwnnnnnn';
$barChar['X'] = 'nwnnwnnnw';
$barChar['Y'] = 'wwnnwnnnn';
$barChar['Z'] = 'nwwnwnnnn';
$barChar['-'] = 'nwnnnnwnw';
$barChar['.'] = 'wwnnnnwnn';
$barChar[' '] = 'nwwnnnwnn';
$barChar['*'] = 'nwnnwnwnn';
$barChar['$'] = 'nwnwnwnnn';
$barChar['/'] = 'nwnwnnnwn';
$barChar['+'] = 'nwnnnwnwn';
$barChar['%'] = 'nnnwnwnwn';
$this->SetFont('','B');
$this->SetFont('Arial','',6);
$this->Text($xpos, $ypos + $height + 7, strtoupper($code));
$this->SetFillColor(0);
$code = '*'.strtoupper($code).'*';
for($i=0; $i<strlen($code); $i++){
$char = $code{$i};
if(!isset($barChar[$char])){
$this->Error('Invalid character in barcode: '.$char);
}
$seq = $barChar[$char];
for($bar=0; $bar<9; $bar++){
if($seq{$bar} == 'n'){
$lineWidth = $narrow;
}else{
$lineWidth = $wide;
}
if($bar % 2 == 0){
$this->Rect($xpos, $ypos, $lineWidth, $height, 'F');
}
$xpos += $lineWidth;
}
$xpos += $gap;
}
}
The previous is the function ... place this inside your PDML class...
The following is a CASE that goes inside of the
PDML::OpenTag functions
I just copied another function, so there may be residual code that is not really necessary for this case...quick and dirty...sorry about the dirty
-------------------------------------------------
case "BARCODE":
$this->_enforceState(50,51);
$save_x = $this->GetX();
$x = $this->_getAttrUnit($save_x, $attr, "LEFT", $this->wPt);
$save_y = $this->GetY();
$y = $this->_getAttrUnit($save_y, $attr, "TOP", $this->hPt);
$width = $this->_getAttrUnit($this->wPt-$x, $attr, "WIDTH", $this->wPt);
// used by multicell only
$inter = $this->_getAttrUnit($this->font_size[0], $attr, "INTER", $this->font_size[0]);
// used by cell only.
$height = $this->_getAttrUnit($this->font_size[0], $attr, "HEIGHT", $this->font_size[0]);
$next = 0;
if (isset($attr["NEXT"])) {
$n = strtolower($attr["NEXT"]);
switch ($n) {
case "right": $next =0; break;
case "bottom": case "down": $next=2; break;
case "break": $next = 1; break;
}
}
$style="";
$color = "000000";
if (isset($attr["COLOR"])) {
$color = $attr["COLOR"];
if ($color[0]=="#") { $color = substr($color,1); }
$style.="D";
}
$fillflag = 0;
$fill = "000000";
if (isset($attr["BASELINE"])) {
$baseline = $attr["BASELINE"];
}else{
$baseline = "0.5";
}
$borderflag=0;
$border = $this->_getUnit("0.2mm");
if (isset($attr["BORDER"])) {
$border = $this->_getUnit($attr["BORDER"], $border);
$borderflag=1;
}
$align = ($tag=="CELL")?"L":"J";
if (isset($attr["ALIGN"])) {
$al = strtolower($attr["ALIGN"]);
switch ($al){
case "left": $align="L"; break;
case "center": $align="C"; break;
case "right": $align="R"; break;
case "justify": $align="J"; break;
}
}
$this->_setLineColor($color);
$this->SetLineWidth($border);
$this->_setRectColor($fill);
$this->SetXY($x,$y);
//$this->cell_info = array($width, $inter, $height, $borderflag, $align, $fillflag, $next);
$this->cell_info = array($x, $inter, $y, $height, $align, $fillflag, $baseline);
$this->cell_text = '';
break;
Here is the CASE state for the the PDML::CloseTag function...
Again quick and dirty...
------------------------------------------------
case "BARCODE":
$this->_enforceState(51,50);
// auto-create a page if needed.
if (!$this->inPage) {
$this->inPage = true;
$this->AddPage();
}
$this->Code39(
$this->cell_info[0],
$this->cell_info[2],
$this->cell_text,
$this->cell_info[6],
$this->cell_info[3]);
break;
As far as what I use the barcodes for...
This barcode doesn't really conform to barcode standards like EAN-18, but it outputs a barcode nonetheless.
My purposes for this is to generate a barcode for online job applications as a unique identifier for tracking.
I use PDML to generate the PDf application after the user/job-seeker has filled out the online counterpart. The barcode serves as a rendering of their session id...kind of a unique way of digital signature.
hope this helps, confuses, or whatever to whomever finds interest
I am interested on use it. I have try to use the screenshot of the version 1.0 but I receive an error here:
$this->_Code39(
Can you help? Thanks
This is the error I receive:
Fatal error: Call to undefined method PDML::Code39() in /home/ibouti29/public_html/admin/pdml/pdml.php on line 1167
Sorry, done it!
Hi Derbai, have you modified anything in the source code ? There should be no Code39 without a underscore in the source.
Regards,
Remi
It is possible to wrote the charters under the barcode in a bigger font? How?
Thanks, Daniele