Created
August 14, 2021 08:07
-
-
Save GroupDocsGists/3f07e4f0b5facbd3ff0c50efab29d840 to your computer and use it in GitHub Desktop.
Generate Barcode using Java - Add Barcodes to Documents and Images using Java Signature API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate and apply barcodes to documents (DOC, DOCX, PDF, PPT, XLS, XLSX, ...) in Java | |
Signature signature = new Signature("path/document.pdf"); | |
// Create barcode option with barcode text | |
BarcodeSignOptions options = new BarcodeSignOptions("<00-0-0000-0> 2021-08"); | |
options.setEncodeType(BarcodeTypes.Code128); | |
// Barcode Alignment and Appearance | |
options.setLeft(205); | |
options.setTop(170); | |
options.setHeight(50); | |
options.setWidth(200); | |
options.setForeColor(Color.BLUE); | |
options.setCodeTextAlignment(CodeTextAlignment.Below); | |
// Attach barcode with the document | |
signature.sign(outputFilePath, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// // Generate and apply barcodes to Images (JPG, PNG, BMP, ...) in Java | |
Signature signature = new Signature("path/image.jpg"); | |
// Create barcode option with barcode text | |
BarcodeSignOptions options = new BarcodeSignOptions("<00-0-0000-0> 2021-08"); | |
options.setEncodeType(BarcodeTypes.Code128); | |
// Barcode Alignment and Appearance | |
options.setLeft(100); | |
options.setTop(100); | |
options.setHeight(50); | |
options.setWidth(200); | |
options.setForeColor(Color.BLUE); | |
options.setCodeTextAlignment(CodeTextAlignment.Above); | |
// Attach barcode with the image | |
signature.sign(outputFilePath, options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment