Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. def get_barcode_img(string, xdim)
  2. binary_barcode = Barby::Code128C.new(string)
  3. outputter = Barby::RmagickOutputter.new(binary_barcode)
  4. outputter.height, outputter.xdim = 96, xdim
  5. encoded_image = Base64.encode64(outputter.to_jpg.to_s).gsub(/s+/, "")
  6. end
  7.  
  8. <% barcode = get_barcode_img("123456", 1.44) %>
  9. <%= image_tag("data:image/jpg;base64,#{Rack::Utils.escape(barcode)}") %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement