+ Start a Discussion
Rajesh ShahRajesh Shah 

Creating barcode in PDF


I have a requirement wherein I need to create and display barcode in a pdf page genereated using Visualforce. Does any one have an idea on how to do this?

I understand that there are special fonts which can displays the text in a barcode format. But there are limitations too on the salesforce server which generates Fonts for pdf. Will Visualforce Pdf support such a font?

PDF's embed fonts at the point of creation, so using a barcode font will not work in conjunction with SF's PDF generator. Probably would work on most web browsers if the page is just HTML and the user has the font installed, though.

I looked into barcode generation for a client and concluded the most likely solution involved either using a barcode font with an HTML page, or using a 3rd party solution which creates barcode images (GIF/JPG) and uploading them to the salesforce instance.

Jeremy Kraybill
Austin, TX
I tried a couple of things w.r.t. barcode generation and came to the same conclusion as Jeremy:

"using a 3rd party solution which creates barcode images (GIF/JPG) and uploading them to the salesforce instance"

and in Spring '09 release we have added support for PDF generation to be able to access external content using the Remote Sites configuration already in place for apex code callouts and the ajax toolkit proxy!

Message Edited by dchasman on 01-13-2009 11:20 AM

Hi Doug,


in looking through the Spring '09 VF docs, I could not find a mention of the new "support for PDF generation to be able to access external content". Is there a page in the dev guide on this, or some other place that describes how it works now?


Jeremy Kraybill

Austin, TX

gary chengary chen

I got similar question. I used a  .NET barcode generator. But I do not know  how to generate barcode in PDF, here is my code, what code should I write to output the barcode to PDFfile..Thank you.


 BarcodeLib.Barcode.Linear msi = new BarcodeLib.Barcode.Linear();
            msi.Type = BarcodeType.MSI;
            msi.Data = "1234567890";
            msi.AddCheckSum = true;


beco fuanbeco fuan
Hi, rajesh
I also only got a .net bar code encoder (http://www.businessrefinery.com/products/barcode_net/main.html), I'm not sure whether I can use it to crete bar code (http://www.businessrefinery.com/products/barcode_asp_net/main.html) in PDF, I don't know whether your problem has been solved, if you have any solutions, hope you can share me with it.
Thanks in advance.
Hi Rajesh Shah 

Directly using apex tag outputtext has no use

so create a controller like below :
public with sharing class Pdfimage{   
public List<Payment__C> Paylist {get; set;}
      public String imageUrl{get;set;} //CH07
       public Pdfimage(){
        Paylist = [SELECT Id, Name  FROM Payment__C
                        WHERE Id =: Apexpages.currentPage().getParameters().get('Id')];
      imageUrl='https://www.barcodesinc.com/generator/image.php?code='+Paylist .get(0).name+'&style=325&type=C128B&width=200&height=50&xres=1&font=3';
 In visualforce page add like below :
<apex:page showHeader="false" sidebar="false" controller="Pdfimage" cache="false" standardstylesheets="false" renderAs="pdf" applyHtmlTag="false">
                  <td colspan="8">         
                    <apex:image value="{!imageUrl}"/>
Last step Enter Given URL In Remote site settings https://www.barcodesinc.com

If you find helpful Please Hit a like and give the best Answer

Thanks ,
Venkat Pattapu
Krishna RadhakrishnanKrishna Radhakrishnan
Hi Venkat, I tried the approachyou had suggested. It still doesnt show up.