[英]Barcode not showing on rails [Barby Gem]
Ruby '1.9.3'
Rails '3.2.11'
Bbarby', '~> 0.5.1'
Chunky_png', '~> 1.3.0'
require 'barby'
require 'barby/barcode/code_128'
require 'barby/barcode/ean_13'
require 'barby/outputter/png_outputter'
require 'barby/outputter/ascii_outputter'
require 'chunky_png'
barcode = Barby::Code128B.new('The noise of mankind has become too much')
File.open('code128b.png', 'w'){|f|
f.write barcode.to_png(:height => 20, :margin => 5)
}
<%= image_tag("code128b.png") %>
The pages renders but not the barcode: 页面呈现但不呈现条形码:
Please find the link for detailed bar code implementation : 请找到有关详细条形码实施的链接:
http://blog.andolasoft.com/2012/11/how-to-generate-barcode-using-barby-gem-in-rails-2-3-8.html
http://blog.andolasoft.com/2012/11/how-to-generate-barcode-using-barby-gem-in-rails-2-3-8.html
File.open('code128b.png', 'w'){|f|
f.write barcode.to_png(:height => 20, :margin => 5)
}
this is create file "code128b.png" in your root app path, and <%= image_tag("code128b.png") %>
call image from assets / public 这是在您的根应用程序路径中创建文件“ code128b.png”,并且
<%= image_tag("code128b.png") %>
从资产/公共中调用图像
why you not upload your barcode into cloudinary and save it as url into your db :) 为什么不将条形码上载到cloudinary并将其另存为url到数据库中:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.