Module: Asposebarcodejava::SaveBarcodeImageToTtreams

Defined in:
lib/asposebarcodejava/BarcodeImage/savebarcodeimagetostreams.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/asposebarcodejava/BarcodeImage/savebarcodeimagetostreams.rb', line 3

def initialize()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
            
    # Instantiate barcode object
    builder = Rjb::import('com.aspose.barcode.BarCodeBuilder').new

    # Set symbology of the barcode
    builder.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)

    # Set code text
    builder.setCodeText("123456")

    # Initialize ByteArrayOutputStream object
    out_stream = Rjb::import('java.io.ByteArrayOutputStream').new

    # Save barcode image
    builder.save(out_stream, Rjb::import('com.aspose.barcode.BarCodeImageFormat').Jpeg)

    # Display Status.
    puts "Save Barcode Image to Streams, please check the output file."
end