www.webdeveloper.com
Results 1 to 7 of 7

Thread: PHP barcode generator code print in ZEBRA printer

  1. #1
    Join Date
    Oct 2011
    Posts
    357

    PHP barcode generator code print in ZEBRA printer

    Hi,

    I just created a barcode image generator where I found out in internet, when I test it and I print it in a ordinary printer it was okay. Same size, what the barcode display on my web page is the same size of what I got printed, but when I tried to print it on Zebra Barcode Printer its become small and only half was printed.


    this is my code:
    PHP Code:
    <?php

    $bc 
    = new barCode();
    $bc->build($_GET['id']);

    $q = new MySQL();
    $q->Fetch(wms_receiving);
    class 
    barCode
    {
        public 
    $bcHeight$bcThinWidth$bcThickWidth$bcFontSize$mode;
        
       
    // function __construct($mode='gif', $height=25, $thin=1, $thick=3, $fSize=2)
       
    function __construct($mode='gif'$height=75$thin=1$thick=4$fSize=3)
        {
            
    $this->bcHeight $height;
            
    $this->bcThinWidth $thin;
            
    $this->bcThickWidth $this->bcThinWidth $thick;
            
    $this->fontSize $fSize;
            
    $this->mode $mode;       
            
    $this->outMode = array('gif'=>'gif''png'=>'png''jpeg'=>'jpeg''wbmp'=>'vnd.wap.wbmp');
            
    $this->codeMap = array(
                
    '0'=>'010000101',    '1'=>'100100001',    '2'=>'001100001',    '3'=>'101100000',
                
    '4'=>'000110001',    '5'=>'100110000',    '6'=>'001110000',    '7'=>'000100101',    
                
    '8'=>'100100100',    '9'=>'001100100',    'A'=>'100001001',    'B'=>'001001001',
                
    'C'=>'101001000',    'D'=>'000011001',    'E'=>'100011000',    'F'=>'001011000',
                
    'G'=>'000001101',    'H'=>'100001100',    'I'=>'001001100',    'J'=>'000011100',
                
    'K'=>'100000011',    'L'=>'001000011',    'M'=>'101000010',    'N'=>'000010011',
                
    'O'=>'100010010',    'P'=>'001010010',    'Q'=>'000000111',    'R'=>'100000110',
                
    'S'=>'001000110',    'T'=>'000010110',    'U'=>'110000001',    'V'=>'011000001',
                
    'W'=>'111000000',    'X'=>'010010001',    'Y'=>'110010000',    'Z'=>'011010000',
                
    ' '=>'011000100',    '$'=>'010101000',    '%'=>'000101010',    '*'=>'010010100',
                
    '+'=>'010001010',    '-'=>'000110100',    '.'=>'110000100',    '/'=>'010100010'
                
    );        
        }
        

        
        public function 
    build($text=''$showText=false$fileName=null)
        {   
            if (
    trim($text) <= ' '
                throw new 
    exception('barCode::build - must be passed text to operate');
            if (!
    $fileType $this->outMode[$this->mode]) 
                throw new 
    exception("barCode::build - unrecognized output format ({$this->mode})");
            if (!
    function_exists("image{$this->mode}")) 
                throw new 
    exception("barCode::build - unsupported output format ({$this->mode} - check phpinfo)");
      
            
    $text  =  strtoupper($text);
            
    $dispText "* $text *";
            
    $text "*$text*"// adds start and stop chars
            
    $textLen  =  strlen($text); 
            
    $barcodeWidth  =  $textLen * ($this->bcThinWidth $this->bcThickWidth) - $this->bcThinWidth
            
    $im imagecreate($barcodeWidth$this->bcHeight); 
            
    $black imagecolorallocate($im000); 
            
    $white imagecolorallocate($im255255255); 
            
    imagefill($im00$white); 
            
            
    $xpos 0;
            for (
    $idx=0$idx<$textLen$idx++)
            { 
                if (!
    $char $text[$idx]) $char '-';
                for (
    $ptr=0$ptr<=8$ptr++)
                { 
                    
    $elementWidth = ($this->codeMap[$char][$ptr]) ? $this->bcThickWidth $this->bcThinWidth
                    if ((
    $ptr 1) % 2
                        
    imagefilledrectangle($im$xpos0$xpos $elementWidth-1$this->bcHeight$black); 
                    
    $xpos += $elementWidth
                }
                
    $xpos += $this->bcThinWidth
            }
            
            if (
    $showText)
            {
                
    $pxWid imagefontwidth($this->fontSize) * strlen($dispText) + 10;
                
    $pxHt imagefontheight($this->fontSize) + 2;
                
    $bigCenter $barcodeWidth 2;
                
    $textCenter $pxWid 2;
                
    imagefilledrectangle($im$bigCenter $textCenter$this->bcHeight $pxHt$bigCenter $textCenter$this->bcHeight$white);
                
    imagestring($im$this->fontSize, ($bigCenter $textCenter) + 5, ($this->bcHeight $pxHt) + 1$dispText$black);
            }

            if (!
    $fileNameheader("Content-type:  image/{$fileType}");
            switch(
    $this->mode)
            {
                case 
    'gif'imagegif($im$fileName);
                case 
    'png'imagepng($im$fileName);
                case 
    'jpeg'imagejpeg($im$fileName);
                case 
    'wbmp'imagewbmp($im$fileName);
            }

            
    imagedestroy($im);         
        }
    }

    ?>
    I don't have any idea how can I print my barcode image in Zebra. Is this any configuration?


    Thank you

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    i think it is more about ur printer than your code, try modifiying the size of the image.

  3. #3
    Join Date
    Oct 2011
    Posts
    357
    Thank you... I will try it

  4. #4
    Join Date
    Apr 2013
    Posts
    36
    Did it work?
    Have you found anything wrong with your printer?
    Or you can choose another barcode generater instead.
    I have tested many barcode generators.
    As for the better, i'd like to recommend this barcode generator, it can empower users with the ability to include an image viewer and pre-processing capabilities such as deskew, despeckle, and annotations alongside barcode reading & writing functionalities.
    You can try to modifiy the size of the barcode image.


    Hope it helps.


    Kind Regards,
    Arron

  5. #5
    Join Date
    Aug 2013
    Posts
    2
    Quote Originally Posted by arronlee View Post
    Did it work?
    Have you found anything wrong with your printer?
    Or you can choose another barcode generater instead.
    I have tested many barcode generators.
    As for the better, i'd like to recommend this barcode generator, it can empower users with the ability to include an image viewer and pre-processing capabilities such as deskew, despeckle, and annotations alongside barcode reading & writing functionalities.
    You can try to modifiy the size of the barcode image.


    Hope it helps.


    Kind Regards,
    Arron
    I think different barcode generators have different barcode image settings. So this should be only available for your barcode generator. So I suggest him read the image settings of his barcode generator first. If his barcode tool does not support this funciton. He can consider to use another tool.

  6. #6
    Join Date
    Aug 2013
    Posts
    30
    maybe you need to read carefully about the characters of php barcode generator

  7. #7
    Join Date
    Dec 2013
    Posts
    5
    Here is the result I got from Google when I typed in configuration of zebra barcode printer:
    Zebra Setup Utility can be used to configure printer settings.The 1st screen for Label Parameters is where you can set the Lbel Size and Orientation. I can't upload a pic here, you can refer to the link I give, detailed pics and steps are shown over there:
    https://km.zebra.com/kb/index?page=content&id=SO7953

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.37332 seconds
  • Memory Usage 2,987KB
  • 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
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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 (72):
  • 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_postinfo_query
  • fetch_postinfo
  • 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