I am pretty new to salesforce. We are storing Barcode information in a formula field, and I need a lwc to print a pdf of the barcode from the formula field. I'd appreciate any help, thank you in advance.

1 Answer 1


There are several parts to what you're asking. Let's unpack it.

PDF generation in Salesforce has traditionally been done using Visualforce and Apex -- see the official documentation. Your LWC can call an Apex method that in turn generates the PDF.

Barcode generation in Visualforce has been covered here and here.

In LWC, you also have the option of client-side PDF generation using separate JavaScript libraries for the barcode generation piece and the PDF generation piece. You may not find as many examples out there, and there's more than one library to choose from on both fronts, so research and test accordingly. You may want to borrow from one of these LWC + client-side PDF generation examples: Example 1, Example 2

The best solution may depend on whether you plan to save the PDF back to Salesforce (in which case, consider using server-side Apex and Visualforce), or if it will be exclusively downloaded to users' local devices (which might be a good reason to keep execution on the client side, among other considerations).

You must log in to answer this question.

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