public final class Margins
extends java.lang.Object
Specifies the margins of a barcode image in Unit
values.
This sample shows how to create and save a BarCode image.BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.CODE_128); generator.getMargins().getLeft().setMillimeters(2); generator.getMargins().getTop().setPixels(15); generator.getMargins().getRight().setInches(0.3f); generator.getMargins().getBottom().setPoint(14); generator.save("test.png");
<p>This class is used to manipulate margins in barcode image.</p>
Constructor and Description |
---|
Margins(Unit left,
Unit right,
Unit top,
Unit bottom)
Initializes a new instance of the
Margins class with specified left, right, top, bottom marigns. |
Modifier and Type | Method and Description |
---|---|
Unit |
getBottom()
Gets the
<b>bottom</b> marign in Unit value. |
Unit |
getLeft()
Gets the
<b>left</b> margin in Unit value. |
Unit |
getRight()
Gets the
<b>right</b> marign in Unit value. |
Unit |
getTop()
Gets the
<b>top</b> marign in Unit value. |
java.lang.String |
toString()
Returns a String that represents the current
MarginsMargins instance. |
public Margins(Unit left, Unit right, Unit top, Unit bottom)
Initializes a new instance of the Margins
class with specified left, right, top, bottom marigns.
left
- The Left marign.right
- The right marign.top
- The top marign.bottom
- The bottom marign.java.lang.IllegalArgumentException
- <p>The left parameter value is less than 0.</p>
<p>-or-</p>
<p>The right parameter value is less than 0.</p>
<p>-or-</p>
<p>The top parameter value is less than 0.</p>
<p>-or-</p>
<p>The bottom parameter value is less than 0.</p>
public Unit getBottom()
Gets the <b>bottom</b>
marign in Unit
value.
<p>The <b>Bottom</b> parameter value is less than 0.</p>
BarCodeException
- <p>The <b>Bottom</b> can't be specified when AutoSizeMode is set to Nearest.</p>
public Unit getLeft()
Gets the <b>left</b>
margin in Unit
value.
<p>The <b>Left</b> parameter value is less than 0.</p>
BarCodeException
- <p>The <b>Left</b> can't be specified when AutoSizeMode is set to Nearest.</p>
public Unit getRight()
Gets the <b>right</b>
marign in Unit
value.
<p>The <b>Right</b> parameter value is less than 0.</p>
BarCodeException
- <p>The <b>Right</b> can't be specified when AutoSizeMode is set to Nearest.</p>
public Unit getTop()
Gets the <b>top</b>
marign in Unit
value.
<p>The <b>Top</b> parameter value is less than 0.</p>
BarCodeException
- <p>The <b>Top</b> can't be specified when AutoSizeMode is set to Nearest.</p>
public java.lang.String toString()
Returns a String that represents the current MarginsMargins
instance.
toString
in class java.lang.Object
System.StringString
that represents the current Object.