www.webdeveloper.com
Results 1 to 10 of 10

Thread: Need guidance printing a 128 barcode with fpdf

  1. #1
    Join Date
    Mar 2013
    Location
    Andrews, SC
    Posts
    7

    Unhappy Need guidance printing a 128 barcode with fpdf

    Need to place a database generated 128 bar code on a fpdf label (lower right corner). No idea where to start with barcode script.

    Code:
    <?php
    require('fpdf.php');
    
    $monthCode = array("02", "03", "04", "06", "09", "10", "10", "11", "11", "12", "12", "01");
    $monthLetterCode = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M");
    
    $realMonthCode = date("n"); 
    $labelYearCode = date("y");
    $arrayMonthCode = $realMonthCode - 1;
    $labelMonthCode = $monthCode[$arrayMonthCode];
    $labelLetterCode = $monthLetterCode[$arrayMonthCode];
    $myString = "Sh" . $labelMonthCode . $labelYearCode . $labelLetterCode;
    
    
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,12,'P4-830R',0,1);
    $pdf->SetFont('Arial','B',8);
    $pdf->Cell(40,5,'Suntec "A" Series Fuel Unit',0,1);
    $pdf->Cell(40,5,'Kerosene Only',0,1);
    $pdf->SetFont('Arial','B',6);
    $pdf->Cell(3,5,'OEM');
    $pdf->SetFont('Arial','',6);
    $pdf->Cell(3);
    $pdf->Cell(3,5,'#A1VA-7112');
    $pdf->Cell(10);
    $pdf->SetFont('Arial','B',6);
    $pdf->Cell(3,5,'STG');
    $pdf->SetFont('Arial','',6);
    $pdf->Cell(3);
    $pdf->Cell(3,5,'Single');
    $pdf->Cell(10);
    $pdf->SetFont('Arial','B',6);
    $pdf->Cell(3,5,'ROT');
    $pdf->SetFont('Arial','',6);
    $pdf->Cell(3);
    $pdf->Cell(3,5,'CW-R',0);
    $pdf->Cell(35);
    $pdf->Cell(3,5,$myString,0,1);
    
    
    $pdf->SetFont('Arial','B',6);
    $pdf->Cell(3,5,'MNT');
    $pdf->SetFont('Arial','',6);
    $pdf->Cell(3);
    $pdf->Cell(3,5,'Flange');
    $pdf->Cell(10);
    $pdf->SetFont('Arial','B',6);
    $pdf->Cell(3,5,'STG');
    $pdf->SetFont('Arial','',6);
    $pdf->Cell(3);
    $pdf->Cell(3,5,'Single');
    $pdf->Cell(10);
    $pdf->SetFont('Arial','B',6);
    $pdf->Cell(3,5,'ROT');
    $pdf->SetFont('Arial','',6);
    $pdf->Cell(3);
    $pdf->Cell(3,5,'CW-R',0,1);
    
    $pdf->SetFont('Arial','',4);
    $pdf->Cell(80,5,'Sid Harvey Industries, Inc.   605 Locust St.,     Garden City, NY 11530',0,0,'C');
    
    $pdf->Image('Sid.JPG',90,10,15,15);
    
    
    $pdf->Output();
    ?>

  2. #2
    Join Date
    Mar 2013
    Location
    Andrews, SC
    Posts
    7

    UPC-A (not 128), oops!

    Looking at http://barcode-coder.com/en/barcode-php-class-203.html

    Have a sample running, but it's pretty unreadable at the size my label uses.

    Code:
    <?php
      include('../php-barcode.php');
      require('fpdf.php');
      
      // -------------------------------------------------- //
      //                      USEFUL
      // -------------------------------------------------- //
      
      class eFPDF extends FPDF{
        function TextWithRotation($x, $y, $txt, $txt_angle, $font_angle=0)
        {
            $font_angle+=90+$txt_angle;
            $txt_angle*=M_PI/180;
            $font_angle*=M_PI/180;
        
            $txt_dx=cos($txt_angle);
            $txt_dy=sin($txt_angle);
            $font_dx=cos($font_angle);
            $font_dy=sin($font_angle);
        
            $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj ET',$txt_dx,$txt_dy,$font_dx,$font_dy,$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
            if ($this->ColorFlag)
                $s='q '.$this->TextColor.' '.$s.' Q';
            $this->_out($s);
        }
      }
    
      // -------------------------------------------------- //
      //                  PROPERTIES
      // -------------------------------------------------- //
      
      $fontSize = 5;
      $marge    = 3;   // between barcode and hri in pixel
      $x        = 200;  // barcode center
      $y        = 75;  // barcode center
      $height   = 15;   // barcode height in 1D ; module size in 2D
      $width    = .4;    // barcode width in 1D ; not use in 2D
      $angle    = 0;   // rotation in degrees
      
      $code     = '0123456789012'; // barcode, of course ;)
      $type     = 'ean13';
      $black    = '000000'; // color in hexa
      
      
      // -------------------------------------------------- //
      //            ALLOCATE FPDF RESSOURCE
      // -------------------------------------------------- //
        
      $pdf = new eFPDF('P', 'pt');
      $pdf->AddPage();
      
      // -------------------------------------------------- //
      //                      BARCODE
      // -------------------------------------------------- //
      
      $data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
      
      // -------------------------------------------------- //
      //                      HRI
      // -------------------------------------------------- //
      
      $pdf->SetFont('Arial','B',$fontSize);
      $pdf->SetTextColor(0, 0, 0);
      $len = $pdf->GetStringWidth($data['hri']);
      Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
      $pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
      
      $pdf->Output();
    ?>

  3. #3
    Join Date
    Mar 2013
    Location
    Andrews, SC
    Posts
    7
    Alternatively, I have a UPC-A truetype font, but having issues displaying it with imagettftext. Any suggestions?

  4. #4
    Join Date
    Jun 2013
    Posts
    37
    Did you mean that you need a help on how to created and display UPC-A barcode on image? or Code 128 generating tutorial? here is a UPC-A image barcode generating tutorial in c# .net, take a look and if you got any question,you can email for support.

  5. #5
    Join Date
    Mar 2013
    Location
    Andrews, SC
    Posts
    7
    Quote Originally Posted by Alcottpdf View Post
    Did you mean that you need a help on how to created and display UPC-A barcode on image? or Code 128 generating tutorial? here is a UPC-A image barcode generating tutorial in c# .net, take a look and if you got any question,you can email for support.
    I'm not using C#, I'm using php/fpdf. You did read the subject line, right? I needed the syntax for telling fpdf to display a barcode from a database field of 12 digits.

    It was:

    //barcode
    $pdf->setXY(0,0);
    $pdf->write1DBarcode($row['Bar Code'], 'UPCA', 2.875, 1.125, .625, 0.3125, '', array('text'=>true,'fontsize' => 6,'font' => 'helvetica'), 'M');

  6. #6
    Join Date
    Aug 2013
    Posts
    1
    I am not familiar with php. I only created UPC-A barcode in .NET. You may take a look at the professional barcode site to find php related barcode tool. Hope this is good clue. I can only offer this info.

  7. #7
    Join Date
    Aug 2013
    Posts
    30
    er, i'm not so clear about this problem,but i wanna offer you a resource about upc-a barcode generator displayed on google,you may take a look and find a clue

  8. #8
    Join Date
    Apr 2012
    Posts
    38
    Since fpdf has an integrated barcode function this might be useful:

    http://www.fpdf.org/en/script/script5.php

  9. #9
    Join Date
    Aug 2013
    Posts
    30
    Quote Originally Posted by versiondays View Post
    I am not familiar with php. I only created UPC-A barcode in .NET. You may take a look at the professional barcode site to find php related barcode tool. Hope this is good clue. I can only offer this info.
    hey , does it have the free trail version ?

  10. #10
    Join Date
    May 2014
    Location
    Walnut
    Posts
    1

    Only free to test

    Quote Originally Posted by cindy313 View Post
    I am not familiar with php. I only created UPC-A barcode in .NET. You may take a look at the professional barcode site to find php related barcode tool. Hope this is good clue. I can only offer this info.

    hey , does it have the free trail version ?
    As i know, this barcode tool is free to test and i've ever gotten a free evaluation from online.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.26409 seconds
  • Memory Usage 2,953KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates