我想在RoR上通过rghost创建条形码jpg文件。
当我渲染RGhost条形码内容时,我得到了以下例外...
failed created_jpg_new: private method `readlines' called for nil:NilClass
image file is an unrecognised format
我的编码开始create_jpg(code_word)
def create_jpg(code_word)
begin
img = encode(code_word)
rescue => exc
Rails.logger.info("failed create_jpg: #{exc}")
else
File.open(img_path, "w+b") { |f|
f << img
}
end
end
def encode(code_word)
doc = RGhost::Document.new
doc.barcode_rationalizedCodabar code_word
return doc.render_stream(:jpg)
end
doc.render_stream(:jpg)
或其他方面有什么问题?