Module: Asposebarcodejava::CodeText
- Defined in:
- lib/asposebarcodejava/Barcode/codetext.rb
Instance Method Summary collapse
Instance Method Details
#initialize ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/asposebarcodejava/Barcode/codetext.rb', line 3 def initialize() # Set appearance of the code text set_appearance() # Set code text for Barcode set_codetext() end |
#set_appearance ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/asposebarcodejava/Barcode/codetext.rb', line 11 def set_appearance() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate barcode object bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new # Set up code text (data to be encoded) bb.setCodeText("1234567") # Set up code text color bb.setCodeTextColor(Rjb::import('java.awt.Color').RED) # Set the location of the code text to above the barcode bb.setCodeLocation(Rjb::import('com.aspose.barcode.CodeLocation').Above) #Increase the space between code text and barcode to 1 point bb.setCodeTextSpace(1.0) # Set the symbology type to Code128 bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128) # Save the image to your system and set its image format to Jpeg bb.save(data_dir + "barcode.jpg", Rjb::import('com.aspose.barcode.BarCodeImageFormat').Jpeg) # Display Status puts "Barcode with custom appearance saved as JPEG image successfully." end |
#set_codetext ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/asposebarcodejava/Barcode/codetext.rb', line 39 def set_codetext() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate barcode object bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new # Set the code text for the barcode bb.setCodeText("Aspose-123") # Set the symbology type to Code128 bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128) # Set the width of the bars to 0.5 millimeter bb.setxDimension(0.5) # save the barcode image to file bb.save(data_dir + "codetext.out.jpg") # Print message puts "Barcode image generated successfully." end |