Module: Asposebarcodejava::ManageCaption

Defined in:
lib/asposebarcodejava/Barcode/managecaption.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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/asposebarcodejava/Barcode/managecaption.rb', line 3

def initialize()
    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 the symbology type to Code128
    bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)

    caption = Rjb::import('com.aspose.barcode.Caption').new
    caption.setText("Captions")
    caption.setTextAlign(Rjb::import('com.aspose.barcode.Alignment').Middle)

    bb.setCaptionAbove(caption)
    bb.setCaptionBelow(caption)

    bb.getCaptionAbove().setTextAlign(Rjb::import('com.aspose.barcode.Alignment').Left)
    bb.getCaptionAbove().setText("Aspose")
    bb.getCaptionAbove().setVisible(true)
    #bb.getCaptionAbove().setFont(new java.awt.Font("Pristina", java.awt.Font.PLAIN, 14));
    #bb.getCaptionAbove().setForeColor(java.awt.Color.RED);

    bb.getCaptionBelow().setTextAlign(Rjb::import('com.aspose.barcode.Alignment').Right)
    bb.getCaptionBelow().setText("Aspose.BarCode Caption Below")
    bb.getCaptionBelow().setVisible(true)
    #bb.getCaptionBelow().setFont(new java.awt.Font("Pristina", Font.PLAIN, 14));
    #bb.getCaptionBelow().setForeColor(java.awt.Color.RED);

    # 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 Captions saved successfully."
end