ruby on rails - Displaying Png image using Barby Barcode generator -
i using barby , png outputter. have gotten compile fine, not sure how can display image. here code..
controller:
@barcode = barby::code128b.new(@num) @blob = barby::pngoutputter.new(@barcode).to_png #raw png data file.open('barcode.png', 'w'){|f| f.write @blob }
application helper:
require 'barby' require 'barby/barcode/code_128' require 'barby/outputter/png_outputter'
view:
<%= @blob %>
since @blob
image data, can't "print" regular string. need use image_tag instead, , give path image. like:
<%= image_tag("barcode.png") %>
Comments
Post a Comment