Since storing as an image in a container field allows for clean printing in all platforms that FileMaker supports, this is a preferred way to generate and store barcodes. There is also nothing to install on client machines like 3rd party plugins or fonts to maintain.
Github Project used here: https://github.com/lindell/JsBarcode
Also note that some barcode types may have requirements on the values they can represent, such as EAN type must be a 13 digit number. See the documentation for the barcode type you are using before implementing in your solution.
Added better support for Windows version where long URLs are not supported and may fail. Note that this uses the user clipboard to transfer data from the web viewer to a field.
Updated for FileMaker 16 with security setting to allow for fmpurl protocol.
Update: The ability to generate PDF417 barcodes was added by using the GitHub project here: https://github.com/bkuzmic/pdf417-js
This addition also highlights the technique to get the result of an HTML5 canvas object and return it to a FileMaker container as a PNG.