Closed psaravanan-vss closed 2 years ago
Solution: In Prawn, table allowing to insert image, so I converted the Barcode to image and placed that image in table. Using below gem I generated base64 image content and temporarily stored in /tmp directory (since we have give absolute image path) and placed inside the Table. gem 'chunky_png'
barcode_string = 'barcode_string'.to_s
barcode = Barby::Code128B.new(barcode_string)
blob = Barby::PngOutputter.new(barcode).to_png #Raw PNG data
File.open('tmp/barcode.png', 'wb'){|f| f.write blob }
File.open("tmp/barcode1.png", 'wb'){|f| f.write barcode.to_png } # Temporarily store in tmp directory to print into pdf
data = [ {image: "#{Rails.root.to_s}/tmp/barcode1.png", image_width: 120, image_height: 40, position: :center} ]
@psaravanan-vss , thank you so much!
@pointlessone I think this can be closed or converted into a discussion at your discretion.
Any solution for this?