We are trying to generate barcodes on the pdf without using any external site. I have the generated base64 string which i am calling on my vf page to generate the image of barcode. My barcode is not generating with below code.

Controller -

public  string base64Image{get;set;}


VF page -

 <apex:image value="data:image/png;base64,{base64Image}" styleClass="barcodeFirst" />

enter image description here

  • Please keep the original code/markup in your question. If you edit it to incorporate things from answers, then the answers lose context and don't make much sense. If you think that you must incorporate feedback from an answer, you should add it as a new section to your question (i.e. you would add another <apex:image> code block under the "broken image" in your question).
    – Derek F
    May 17, 2023 at 22:09

2 Answers 2


Merge fields need to be in the form of {!...}. You forgot the !:

<apex:image value="data:image/png;base64,{!base64Image}" styleClass="barcodeFirst" />
  • I used it but not working. @sfdcfox May 17, 2023 at 17:53
  • @SalesforceKid Yeah, looks like there's an Idea for this. In the meantime, workaround would be to render client-side with html2pdf.
    – sfdcfox
    May 17, 2023 at 18:41

i would suggest using a barcode font. Much cleaner and easier solution. Depending on the standard you can choose it from https://fonts.google.com/?query=barcode.

Hope this helps.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .