function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
p1 force developerp1 force developer 

Generating Barcode image on Visualforce and Formula Field

Is there is a way you for Generating Barcode image on Visualforce and Formula Field. I need to show these on VF pages and also on screens so that it can be exposed on mobile devices or ipad....

 

thanks

 

Cory CowgillCory Cowgill

You can use Javascript Barcode Libraries and exeucte Javascript in your VF Page to accomplish this.

 

There are lots of different Javascript Libraries available, so you'll have to google to find the right library for your barcode type.

 

For Example, for Barcode 39 you can do the following:

 

1. Upload the Javascript Library "Code39.js" from this tutorial website: http://www.codeproject.com/KB/HTML/Code-39-Barcode.aspx as a Static Resource to your Salesforce Org.

 

2. Create a VF Page. Execute the Javascript in the JS Library which will generate your Data. Here is an example:

<apex:page standardController="Position__c">
    <apex:includeScript value="{!$Resource.BarcodeScript}"/>
    <apex:detail relatedList="false"></apex:detail>
    <br/>
    <br/>
    <div id="inputdata">{!Position__c.Name}</div>
    <div id="externalbox" style="width:5in"></div>
    <script type="text/javascript">
    /* <![CDATA[ */
      function get_object(id) {
      alert('Executed');
       var object = null;
       if (document.layers) {
        object = document.layers[id];
       } else if (document.all) {
        object = document.all[id];
       } else if (document.getElementById) {
        object = document.getElementById(id);
       }
       return object;
      }
      get_object("inputdata").innerHTML=DrawCode39Barcode(get_object("inputdata").innerHTML,1);
     /* ]]> */
    </script>
</apex:page>

 

3. You can see the Barcode is generated on the VF Page.