BarcodeParameters
Inheritance: java.lang.Object
public class BarcodeParameters
Container class for barcode parameters to pass-through to BarcodeGenerator.
To learn more, visit the Working with Fields documentation article.
Remarks:
The set of parameters are according to DISPLAYBARCODE field options. See the exact list at
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Methods
Method | Description |
---|---|
getAddStartStopChar() | Whether to add Start/Stop characters for barcode types NW7 and CODE39. |
getBackgroundColor() | Bar code background color (0x000000 - 0xFFFFFF) |
getBarcodeType() | Bar code type. |
getBarcodeValue() | Data to be encoded. |
getCaseCodeStyle() | Style of a Case Code for barcode type ITF14. |
getDisplayText() | Whether to display barcode data (text) along with image. |
getErrorCorrectionLevel() | Error correction level of QR Code. |
getFacingIdentificationMark() | Type of a Facing Identification Mark (FIM). |
getFixCheckDigit() | Whether to fix the check digit if it\u2019s invalid. |
getForegroundColor() | Bar code foreground color (0x000000 - 0xFFFFFF) |
getPosCodeStyle() | Style of a Point of Sale barcode (barcode types UPCA |
getPostalAddress() | Barcode postal address. |
getScalingFactor() | Scaling factor for the symbol. |
getSymbolHeight() | Bar code image height (in twips - 1/1440 inches) |
getSymbolRotation() | Rotation of the barcode symbol. |
isBookmark() | Whether getPostalAddress() / setPostalAddress(java.lang.String) is the name of a bookmark. |
isBookmark(boolean value) | Whether getPostalAddress() / setPostalAddress(java.lang.String) is the name of a bookmark. |
isUSPostalAddress() | Whether getPostalAddress() / setPostalAddress(java.lang.String) is a U.S. |
isUSPostalAddress(boolean value) | Whether getPostalAddress() / setPostalAddress(java.lang.String) is a U.S. |
setAddStartStopChar(boolean value) | Whether to add Start/Stop characters for barcode types NW7 and CODE39. |
setBackgroundColor(String value) | Bar code background color (0x000000 - 0xFFFFFF) |
setBarcodeType(String value) | Bar code type. |
setBarcodeValue(String value) | Data to be encoded. |
setCaseCodeStyle(String value) | Style of a Case Code for barcode type ITF14. |
setDisplayText(boolean value) | Whether to display barcode data (text) along with image. |
setErrorCorrectionLevel(String value) | Error correction level of QR Code. |
setFacingIdentificationMark(String value) | Type of a Facing Identification Mark (FIM). |
setFixCheckDigit(boolean value) | Whether to fix the check digit if it\u2019s invalid. |
setForegroundColor(String value) | Bar code foreground color (0x000000 - 0xFFFFFF) |
setPosCodeStyle(String value) | Style of a Point of Sale barcode (barcode types UPCA |
setPostalAddress(String value) | Barcode postal address. |
setScalingFactor(String value) | Scaling factor for the symbol. |
setSymbolHeight(String value) | Bar code image height (in twips - 1/1440 inches) |
setSymbolRotation(String value) | Rotation of the barcode symbol. |
getAddStartStopChar()
public boolean getAddStartStopChar()
Whether to add Start/Stop characters for barcode types NW7 and CODE39.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: boolean - The corresponding boolean value.
getBackgroundColor()
public String getBackgroundColor()
Bar code background color (0x000000 - 0xFFFFFF)
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getBarcodeType()
public String getBarcodeType()
Bar code type.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getBarcodeValue()
public String getBarcodeValue()
Data to be encoded.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getCaseCodeStyle()
public String getCaseCodeStyle()
Style of a Case Code for barcode type ITF14. The valid values are [STD|EXT|ADD]
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getDisplayText()
public boolean getDisplayText()
Whether to display barcode data (text) along with image.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: boolean - The corresponding boolean value.
getErrorCorrectionLevel()
public String getErrorCorrectionLevel()
Error correction level of QR Code. Valid values are [0, 3].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getFacingIdentificationMark()
public String getFacingIdentificationMark()
Type of a Facing Identification Mark (FIM).
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getFixCheckDigit()
public boolean getFixCheckDigit()
Whether to fix the check digit if it\u2019s invalid.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: boolean - The corresponding boolean value.
getForegroundColor()
public String getForegroundColor()
Bar code foreground color (0x000000 - 0xFFFFFF)
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getPosCodeStyle()
public String getPosCodeStyle()
Style of a Point of Sale barcode (barcode types UPCA|UPCE|EAN13|EAN8). The valid values (case insensitive) are [STD|SUP2|SUP5|CASE].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getPostalAddress()
public String getPostalAddress()
Barcode postal address.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getScalingFactor()
public String getScalingFactor()
Scaling factor for the symbol. The value is in whole percentage points and the valid values are [10, 1000].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getSymbolHeight()
public String getSymbolHeight()
Bar code image height (in twips - 1/1440 inches)
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
getSymbolRotation()
public String getSymbolRotation()
Rotation of the barcode symbol. Valid values are [0, 3].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: java.lang.String - The corresponding java.lang.String value.
isBookmark()
public boolean isBookmark()
Whether getPostalAddress() / setPostalAddress(java.lang.String) is the name of a bookmark.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: boolean - The corresponding boolean value.
isBookmark(boolean value)
public void isBookmark(boolean value)
Whether getPostalAddress() / setPostalAddress(java.lang.String) is the name of a bookmark.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |
isUSPostalAddress()
public boolean isUSPostalAddress()
Whether getPostalAddress() / setPostalAddress(java.lang.String) is a U.S. postal address.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Returns: boolean - The corresponding boolean value.
isUSPostalAddress(boolean value)
public void isUSPostalAddress(boolean value)
Whether getPostalAddress() / setPostalAddress(java.lang.String) is a U.S. postal address.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |
setAddStartStopChar(boolean value)
public void setAddStartStopChar(boolean value)
Whether to add Start/Stop characters for barcode types NW7 and CODE39.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |
setBackgroundColor(String value)
public void setBackgroundColor(String value)
Bar code background color (0x000000 - 0xFFFFFF)
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setBarcodeType(String value)
public void setBarcodeType(String value)
Bar code type.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setBarcodeValue(String value)
public void setBarcodeValue(String value)
Data to be encoded.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setCaseCodeStyle(String value)
public void setCaseCodeStyle(String value)
Style of a Case Code for barcode type ITF14. The valid values are [STD|EXT|ADD]
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setDisplayText(boolean value)
public void setDisplayText(boolean value)
Whether to display barcode data (text) along with image.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |
setErrorCorrectionLevel(String value)
public void setErrorCorrectionLevel(String value)
Error correction level of QR Code. Valid values are [0, 3].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setFacingIdentificationMark(String value)
public void setFacingIdentificationMark(String value)
Type of a Facing Identification Mark (FIM).
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setFixCheckDigit(boolean value)
public void setFixCheckDigit(boolean value)
Whether to fix the check digit if it\u2019s invalid.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |
setForegroundColor(String value)
public void setForegroundColor(String value)
Bar code foreground color (0x000000 - 0xFFFFFF)
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setPosCodeStyle(String value)
public void setPosCodeStyle(String value)
Style of a Point of Sale barcode (barcode types UPCA|UPCE|EAN13|EAN8). The valid values (case insensitive) are [STD|SUP2|SUP5|CASE].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setPostalAddress(String value)
public void setPostalAddress(String value)
Barcode postal address.
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setScalingFactor(String value)
public void setScalingFactor(String value)
Scaling factor for the symbol. The value is in whole percentage points and the valid values are [10, 1000].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setSymbolHeight(String value)
public void setSymbolHeight(String value)
Bar code image height (in twips - 1/1440 inches)
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setSymbolRotation(String value)
public void setSymbolRotation(String value)
Rotation of the barcode symbol. Valid values are [0, 3].
Examples:
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.getFieldOptions().setBarcodeGenerator(new CustomBarcodeGenerator());
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("QR");
barcodeParameters.setBarcodeValue("ABC123");
barcodeParameters.setBackgroundColor("0xF8BD69");
barcodeParameters.setForegroundColor("0xB5413B");
barcodeParameters.setErrorCorrectionLevel("3");
barcodeParameters.setScalingFactor("250");
barcodeParameters.setSymbolHeight("1000");
barcodeParameters.setSymbolRotation("0");
}
BufferedImage img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.QR.jpg"));
builder.insertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("EAN13");
barcodeParameters.setBarcodeValue("501234567890");
barcodeParameters.setDisplayText(true);
barcodeParameters.setPosCodeStyle("CASE");
barcodeParameters.setFixCheckDigit(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.EAN13.jpg"));
builder.insertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("CODE39");
barcodeParameters.setBarcodeValue("12345ABCDE");
barcodeParameters.setAddStartStopChar(true);
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.CODE39.jpg"));
builder.insertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters();
{
barcodeParameters.setBarcodeType("ITF14");
barcodeParameters.setBarcodeValue("09312345678907");
barcodeParameters.setCaseCodeStyle("STD");
}
img = doc.getFieldOptions().getBarcodeGenerator().getBarcodeImage(barcodeParameters);
ImageIO.write(img, "jpg", new File(getArtifactsDir() + "FieldOptions.BarcodeGenerator.ITF14.jpg"));
builder.insertImage(img);
doc.save(getArtifactsDir() + "FieldOptions.BarcodeGenerator.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |