0

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;}

 base64Image ='iVBORw0KGgoAAAANSUhEUgAAAX4AAAGbAQAAAADrKMZgAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAEnRFWHRTb2Z0d2FyZQBCYXJjb2RlNEryjnYuAAABL0lEQVR42u3cMYrDMBCF4SdUuLMuEKxrpFjQlVKmi7qUuZLAha/hkAsknYrgWTn9LuuFDSz8gimE5usfMyDZtvMU4G+ApNDv0l1+ukgpu7Ec5OvJWQ3RsruO2bW+9mx9nAAAAAAAAAAAPwfaH2ZvLxCtakh2t3EF1QAAAAAAAAAA7wDuNmU1oDTlIVUt6kJLdP3wIUUAAAAAAAAAwHYw7BRmddnGuiay4Czb4s+9fAUAAAAAAAAA/Aa4WwlzsuxKl+PzKDfmIJ/dtXR3DwAAAAAAAAB4A9Buvy4ecyw6zL6G2VurFehhAAAAAAAAAIDtwN2q1hlZLMliOZ4Wb1pSfiw6fjUjAwAAAAAAAAB8B66zgpV0kTobWiJrTbakc9/uAAAAAAAAAIAtgP/I/iX4BA/r6xFNW/F3AAAAAElFTkSuQmCC';

VF page -

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

enter image description here

1
  • 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
    Commented May 17, 2023 at 22:09

2 Answers 2

1

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

<apex:image value="data:image/png;base64,{!base64Image}" styleClass="barcodeFirst" />
2
  • I used it but not working. @sfdcfox Commented 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
    Commented May 17, 2023 at 18:41
0

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.

2

You must log in to answer this question.

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