+ 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....




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>
    <div id="inputdata">{!Position__c.Name}</div>
    <div id="externalbox" style="width:5in"></div>
    <script type="text/javascript">
    /* <![CDATA[ */
      function get_object(id) {
       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;
     /* ]]> */


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