asposebarcodejava 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/asposebarcodejava.gemspec +27 -0
- data/config/aspose.yml +5 -0
- data/data/barcode.jpg +0 -0
- data/data/orientation.jpg +0 -0
- data/data/symbologies.png +0 -0
- data/data/test.png +0 -0
- data/lib/asposebarcodejava.rb +71 -0
- data/lib/asposebarcodejava/2DBarcode/creating2dbarcode.rb +25 -0
- data/lib/asposebarcodejava/2DBarcode/creatingaztecbarcode.rb +20 -0
- data/lib/asposebarcodejava/2DBarcode/creatingdatamatrixbarcode.rb +20 -0
- data/lib/asposebarcodejava/2DBarcode/creatingpdf417barcode.rb +20 -0
- data/lib/asposebarcodejava/2DBarcode/creatingqrbarcode.rb +25 -0
- data/lib/asposebarcodejava/2DBarcode/generatemultiplemacropdf417barcodes.rb +33 -0
- data/lib/asposebarcodejava/2DBarcode/hidecodetext.rb +25 -0
- data/lib/asposebarcodejava/2DBarcode/setaspectratio.rb +23 -0
- data/lib/asposebarcodejava/2dbarcode.rb +8 -0
- data/lib/asposebarcodejava/Barcode/australiapostbarcode.rb +20 -0
- data/lib/asposebarcodejava/Barcode/codetext.rb +61 -0
- data/lib/asposebarcodejava/Barcode/managecaption.rb +41 -0
- data/lib/asposebarcodejava/Barcode/managedimension.rb +43 -0
- data/lib/asposebarcodejava/Barcode/patchcode.rb +22 -0
- data/lib/asposebarcodejava/Barcode/setbarsheight.rb +31 -0
- data/lib/asposebarcodejava/Barcode/specifysymbologies.rb +34 -0
- data/lib/asposebarcodejava/Barcode/startstopsymbol.rb +22 -0
- data/lib/asposebarcodejava/Barcode/usechecksumandsupplementdata.rb +25 -0
- data/lib/asposebarcodejava/Barcode/widenarrowratio.rb +39 -0
- data/lib/asposebarcodejava/BarcodeImage/customizebarcodeimageresolution.rb +24 -0
- data/lib/asposebarcodejava/BarcodeImage/generatebarcodebycustomimagesize.rb +25 -0
- data/lib/asposebarcodejava/BarcodeImage/generatebarcodewithemptybars.rb +19 -0
- data/lib/asposebarcodejava/BarcodeImage/printingbarcodeimage.rb +17 -0
- data/lib/asposebarcodejava/BarcodeImage/rotateimage.rb +24 -0
- data/lib/asposebarcodejava/BarcodeImage/savebarcodeimagetostreams.rb +25 -0
- data/lib/asposebarcodejava/BarcodeImage/setbarcodeimageborders.rb +34 -0
- data/lib/asposebarcodejava/BarcodeImage/setbarcodeimagecolor.rb +33 -0
- data/lib/asposebarcodejava/BarcodeImage/setbarcodeimagemargins.rb +28 -0
- data/lib/asposebarcodejava/BarcodeImage/setbarcodeimagequality.rb +24 -0
- data/lib/asposebarcodejava/BarcodeImage/setbarcodeimageunitsize.rb +22 -0
- data/lib/asposebarcodejava/BarcodeRecognition/barcodeorientation.rb +24 -0
- data/lib/asposebarcodejava/BarcodeRecognition/fastandbetterbarcodeprocessing.rb +25 -0
- data/lib/asposebarcodejava/BarcodeRecognition/getallonedbarcodes.rb +37 -0
- data/lib/asposebarcodejava/BarcodeRecognition/getbarcoderecognitionquality.rb +23 -0
- data/lib/asposebarcodejava/BarcodeRecognition/getbarcoderegioninfo.rb +31 -0
- data/lib/asposebarcodejava/BarcodeRecognition/makingbarcoderegions.rb +42 -0
- data/lib/asposebarcodejava/BarcodeRecognition/readbarcodefromspecificregion.rb +24 -0
- data/lib/asposebarcodejava/BarcodeRecognition/recognizebarcode.rb +21 -0
- data/lib/asposebarcodejava/BarcodeRecognition/recognizemultiplesymbologies.rb +21 -0
- data/lib/asposebarcodejava/BarcodeRecognition/recognizespecificsymbology.rb +21 -0
- data/lib/asposebarcodejava/BarcodeRecognition/switchbarcoderecognitionmodes.rb +27 -0
- data/lib/asposebarcodejava/asposebarcode.rb +4 -0
- data/lib/asposebarcodejava/barcode.rb +10 -0
- data/lib/asposebarcodejava/barcodeimage.rb +10 -0
- data/lib/asposebarcodejava/barcoderecognition.rb +11 -0
- data/lib/asposebarcodejava/version.rb +3 -0
- data/samples/2dbarcode.rb +16 -0
- data/samples/barcode.rb +18 -0
- data/samples/barcodeimage.rb +18 -0
- data/samples/barcoderecognition.rb +19 -0
- metadata +162 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module ManageCaption
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set up code text (data to be encoded)
|
10
|
+
bb.setCodeText("1234567")
|
11
|
+
|
12
|
+
# Set the symbology type to Code128
|
13
|
+
bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)
|
14
|
+
|
15
|
+
caption = Rjb::import('com.aspose.barcode.Caption').new
|
16
|
+
caption.setText("Captions")
|
17
|
+
caption.setTextAlign(Rjb::import('com.aspose.barcode.Alignment').Middle)
|
18
|
+
|
19
|
+
bb.setCaptionAbove(caption)
|
20
|
+
bb.setCaptionBelow(caption)
|
21
|
+
|
22
|
+
bb.getCaptionAbove().setTextAlign(Rjb::import('com.aspose.barcode.Alignment').Left)
|
23
|
+
bb.getCaptionAbove().setText("Aspose")
|
24
|
+
bb.getCaptionAbove().setVisible(true)
|
25
|
+
#bb.getCaptionAbove().setFont(new java.awt.Font("Pristina", java.awt.Font.PLAIN, 14));
|
26
|
+
#bb.getCaptionAbove().setForeColor(java.awt.Color.RED);
|
27
|
+
|
28
|
+
bb.getCaptionBelow().setTextAlign(Rjb::import('com.aspose.barcode.Alignment').Right)
|
29
|
+
bb.getCaptionBelow().setText("Aspose.BarCode Caption Below")
|
30
|
+
bb.getCaptionBelow().setVisible(true)
|
31
|
+
#bb.getCaptionBelow().setFont(new java.awt.Font("Pristina", Font.PLAIN, 14));
|
32
|
+
#bb.getCaptionBelow().setForeColor(java.awt.Color.RED);
|
33
|
+
|
34
|
+
# Save the image to your system and set its image format to Jpeg
|
35
|
+
bb.save(data_dir + "barcode.jpg", Rjb::import('com.aspose.barcode.BarCodeImageFormat').Jpeg)
|
36
|
+
|
37
|
+
# Display Status
|
38
|
+
puts "Barcode with Captions saved successfully."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module ManageDimension
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set up code text (data to be encoded)
|
10
|
+
bb.setCodeText("1234567")
|
11
|
+
|
12
|
+
# Set the symbology type to Code128
|
13
|
+
bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)
|
14
|
+
|
15
|
+
# Save the image to file
|
16
|
+
bb.save(data_dir + "barcode.jpg")
|
17
|
+
|
18
|
+
# Set the x-dimension for the bars of the barcode
|
19
|
+
bb.setxDimension(0.5)
|
20
|
+
# Save the image to file
|
21
|
+
bb.save(data_dir + "barcodeXDimensionChanged.jpg")
|
22
|
+
|
23
|
+
|
24
|
+
# Instantiate barcode object
|
25
|
+
bb1 = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
26
|
+
|
27
|
+
# Set the code text of the barcode
|
28
|
+
bb1.setCodeText("12345678")
|
29
|
+
|
30
|
+
# Set the symbology type to code128
|
31
|
+
bb1.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Pdf417)
|
32
|
+
|
33
|
+
# Set the x-dimension for the bars of the barcode
|
34
|
+
bb1.setxDimension(0.5)
|
35
|
+
|
36
|
+
# Save the image to file
|
37
|
+
bb1.save(data_dir + "barcodeYDimensionChanged.jpg")
|
38
|
+
|
39
|
+
# Display Status.
|
40
|
+
puts "BarCodes with different dimensions have been created successfully."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module PatchCode
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
builder = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set Symbology type
|
10
|
+
builder.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').PatchCode)
|
11
|
+
|
12
|
+
# Set code text
|
13
|
+
builder.setCodeText("Patch T")
|
14
|
+
|
15
|
+
# Save the image to your system and set its image format to Jpeg
|
16
|
+
builder.save(data_dir + "PatchCode.jpg")
|
17
|
+
|
18
|
+
# Display Status
|
19
|
+
puts "Generated PatchCode Successfully."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module SetBarsHeight
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set up code text (data to be encoded)
|
10
|
+
bb.setCodeText("1234567")
|
11
|
+
|
12
|
+
# Set the symbology type to Code128
|
13
|
+
bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)
|
14
|
+
|
15
|
+
# Set the bar height to be 3 milimeter
|
16
|
+
bb.setBarHeight(3.0)
|
17
|
+
bb.save(data_dir + "barcode3.jpg")
|
18
|
+
|
19
|
+
# Set the bar height to be 7 milimeter
|
20
|
+
bb.setBarHeight(7.0)
|
21
|
+
bb.save(data_dir + "barcode7.jpg")
|
22
|
+
|
23
|
+
# Set the bar height to be 11 milimeter
|
24
|
+
bb.setBarHeight(11.0)
|
25
|
+
bb.save(data_dir + "barcode11.jpg")
|
26
|
+
|
27
|
+
# Display Status.
|
28
|
+
puts "Barcode with different heights has been created successfully."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module SpecifySymbologies
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
builder = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# ============ Code39Standard =====================
|
10
|
+
# set symbology type
|
11
|
+
builder.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code39Standard)
|
12
|
+
|
13
|
+
# Save image to disk
|
14
|
+
builder.save(data_dir + "code39Standard.out.png")
|
15
|
+
|
16
|
+
# ================== QR ===========================
|
17
|
+
# set symbology type
|
18
|
+
builder.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').QR)
|
19
|
+
|
20
|
+
# Save image to disk
|
21
|
+
builder.save(data_dir + "QR.out.png")
|
22
|
+
|
23
|
+
# =============== Code128 =========================
|
24
|
+
# set symbology type
|
25
|
+
builder.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)
|
26
|
+
|
27
|
+
# Save image to disk
|
28
|
+
builder.save(data_dir + "code128.out.png")
|
29
|
+
|
30
|
+
# Print message
|
31
|
+
puts "Barcode image(s) generated successfully."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module StartStopSymbol
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Create instance of BarCodeBuilder, specify codetext and symbology in the constructor
|
7
|
+
builder = Rjb::import('com.aspose.barcode.BarCodeBuilder').new("$ 123:50", Rjb::import('com.aspose.barcode.Symbology').Codabar)
|
8
|
+
|
9
|
+
# Set the codabar start symbol to A
|
10
|
+
builder.setCodabarStartSymbol(Rjb::import('com.aspose.barcode.CodabarSymbol').A)
|
11
|
+
|
12
|
+
# Set the codabar stop symbol to D
|
13
|
+
builder.setCodabarStopSymbol(Rjb::import('com.aspose.barcode.CodabarSymbol').D)
|
14
|
+
|
15
|
+
# Save the image to disk in PNG format
|
16
|
+
builder.save(data_dir + "barcode.out.png")
|
17
|
+
|
18
|
+
# Print message
|
19
|
+
puts "Barcode image generated successfully."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module UseChecksumAndSupplementData
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set the Code text for the barcode
|
10
|
+
bb.setCodeText("1234567")
|
11
|
+
|
12
|
+
# Set the symbology type to Code39
|
13
|
+
bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code39Standard)
|
14
|
+
|
15
|
+
# Make the checksum to be visible on the barcode
|
16
|
+
bb.setEnableChecksum(Rjb::import('com.aspose.barcode.EnableChecksum').Default)
|
17
|
+
|
18
|
+
# Save the image to disk in JPG format
|
19
|
+
bb.save(data_dir + "barcode.jpg")
|
20
|
+
|
21
|
+
# Print message
|
22
|
+
puts "Barcode image generated successfully."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module WideNarrowRatio
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set the code text of the barcode
|
10
|
+
bb.setCodeText("12345678")
|
11
|
+
|
12
|
+
# Set the symbology type to code39
|
13
|
+
bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code39Extended)
|
14
|
+
|
15
|
+
# Set the wide to narrow ratio for the barcode
|
16
|
+
bb.setWideNarrowRatio(3.0)
|
17
|
+
# Save the image to file
|
18
|
+
bb.save(data_dir + "barcode_ratio_3.jpg")
|
19
|
+
|
20
|
+
# Set the wide to narrow ratio for the barcode
|
21
|
+
bb.setWideNarrowRatio(5.0)
|
22
|
+
# Save the image to file
|
23
|
+
bb.save(data_dir + "barcode_ratio_5.jpg")
|
24
|
+
|
25
|
+
# Set the wide to narrow ratio for the barcode
|
26
|
+
bb.setWideNarrowRatio(7.0)
|
27
|
+
# Save the image to file
|
28
|
+
bb.save(data_dir + "barcode_ratio_7.jpg")
|
29
|
+
|
30
|
+
# Set the wide to narrow ratio for the barcode
|
31
|
+
bb.setWideNarrowRatio(9.0)
|
32
|
+
# Save the image to file
|
33
|
+
bb.save(data_dir + "barcode_ratio_9.jpg")
|
34
|
+
|
35
|
+
# Display Status.
|
36
|
+
puts "BarCodes with different wide narrow ratios have been created successfully."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module CustomizeBarcodeImageResolution
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set the Code text for the barcode
|
10
|
+
bb.setCodeText("1234567")
|
11
|
+
|
12
|
+
# Set the symbology type to Code128
|
13
|
+
bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)
|
14
|
+
|
15
|
+
# Create an instance of resolution
|
16
|
+
bb.setResolution(Rjb::import('com.aspose.barcode.Resolution').new(200,400,Rjb::import('com.aspose.barcode.ResolutionMode').Graphics))
|
17
|
+
|
18
|
+
bb.save(data_dir + "CustomizeBarcodeImageResolution.jpg")
|
19
|
+
|
20
|
+
# Display Status.
|
21
|
+
puts "Customized Barcode Image Resolution, please check the output file."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module GenerateBarcodeByCustomImageSize
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
symbology = Rjb::import('com.aspose.barcode.Symbology')
|
8
|
+
builder = Rjb::import('com.aspose.barcode.BarCodeBuilder').new("1234567890", symbology.Code39Standard)
|
9
|
+
|
10
|
+
# Set auto size false
|
11
|
+
builder.setAutoSize(false)
|
12
|
+
|
13
|
+
# Set height
|
14
|
+
builder.setImageHeight(50)
|
15
|
+
|
16
|
+
# Set width
|
17
|
+
builder.setImageWidth(120)
|
18
|
+
|
19
|
+
builder.save(data_dir + "GenerateBarcodeByCustomImageSize.jpg")
|
20
|
+
|
21
|
+
# Display Status.
|
22
|
+
puts "Generate Barcode By Custom Image Size, please check the output file."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module GenerateBarcodeWithEmptyBars
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
symbology = Rjb::import('com.aspose.barcode.Symbology')
|
8
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new("TEXT", symbology.Code128)
|
9
|
+
|
10
|
+
# Set the FilledBars property to false
|
11
|
+
bb.setFilledBars(false)
|
12
|
+
|
13
|
+
bb.save(data_dir + "GenerateBarcodeWithEmptyBars.jpg")
|
14
|
+
|
15
|
+
# Display Status.
|
16
|
+
puts "Generate Barcode With Empty Bars, please check the output file."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module PrintingBarcodeImage
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
symbology = Rjb::import('com.aspose.barcode.Symbology')
|
8
|
+
builder = Rjb::import('com.aspose.barcode.BarCodeBuilder').new("12345678", symbology.Code128)
|
9
|
+
|
10
|
+
# Set printer name
|
11
|
+
builder.setPrinterName("ML-1640 Series")
|
12
|
+
|
13
|
+
# Start a print job
|
14
|
+
builder.print()
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module RotateImage
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set the code text of the barcode
|
10
|
+
bb.setCodeText("12345678")
|
11
|
+
|
12
|
+
# Roate clockwise for 180 degree (upside down)
|
13
|
+
bb.setRotationAngleF(180)
|
14
|
+
|
15
|
+
# Set the symbology type to code39
|
16
|
+
bb.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code39Extended)
|
17
|
+
|
18
|
+
bb.save(data_dir + "Rotate.jpg")
|
19
|
+
|
20
|
+
# Display Status.
|
21
|
+
puts "Done with image rotation, please check the output file."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module SaveBarcodeImageToTtreams
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
builder = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
# Set symbology of the barcode
|
10
|
+
builder.setSymbologyType(Rjb::import('com.aspose.barcode.Symbology').Code128)
|
11
|
+
|
12
|
+
# Set code text
|
13
|
+
builder.setCodeText("123456")
|
14
|
+
|
15
|
+
# Initialize ByteArrayOutputStream object
|
16
|
+
out_stream = Rjb::import('java.io.ByteArrayOutputStream').new
|
17
|
+
|
18
|
+
# Save barcode image
|
19
|
+
builder.save(out_stream, Rjb::import('com.aspose.barcode.BarCodeImageFormat').Jpeg)
|
20
|
+
|
21
|
+
# Display Status.
|
22
|
+
puts "Save Barcode Image to Streams, please check the output file."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Asposebarcodejava
|
2
|
+
module SetBarcodeImageBorders
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate barcode object
|
7
|
+
bb = Rjb::import('com.aspose.barcode.BarCodeBuilder').new
|
8
|
+
|
9
|
+
margins = Rjb::import('com.aspose.barcode.MarginsF').new
|
10
|
+
# 6 milimeter space from left, right, top and bottom side of border
|
11
|
+
margins.setLeft(2)
|
12
|
+
margins.setRight(2)
|
13
|
+
margins.setTop(2)
|
14
|
+
margins.setBottom(2)
|
15
|
+
|
16
|
+
# Set border's width to be 0.5 milimeter
|
17
|
+
bb.setBorderWidth(0.5)
|
18
|
+
|
19
|
+
# Border will be visible
|
20
|
+
bb.setBorderVisible(true)
|
21
|
+
|
22
|
+
# Set the border's color to red
|
23
|
+
bb.setBorderColor(Rjb::import('java.awt.Color').RED)
|
24
|
+
|
25
|
+
# Set margins
|
26
|
+
bb.setMargins(margins)
|
27
|
+
|
28
|
+
bb.save(data_dir + "border.jpg")
|
29
|
+
|
30
|
+
# Display Status.
|
31
|
+
puts "Set border margins, please check the output file."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|