|
| 1 | +--- |
| 2 | +title: "Introduction to Complex Barcodes" |
| 3 | +description: "Learn how complex barcodes use typed business data models, carrier symbologies, and structured decoding workflows in Aspose.BarCode for Java." |
| 4 | +type: docs |
| 5 | +weight: 10 |
| 6 | +url: /java/developer-guide/complex-barcode/introduction/ |
| 7 | +--- |
| 8 | + |
| 9 | +# Introduction to Complex Barcodes |
| 10 | + |
| 11 | +Complex barcodes represent structured business data through dedicated Java classes instead of requiring applications to assemble the final encoded text manually. |
| 12 | + |
| 13 | +Aspose.BarCode for Java separates the business model, the physical carrier symbology, and the decoding step. This approach reduces formatting errors and makes decoded fields available through typed Java objects. |
| 14 | + |
| 15 | +The complete source code for this article is available on GitHub: |
| 16 | + |
| 17 | +<a href="https://github.com/aspose-barcode/Aspose.BarCode-for-Java/blob/master/src/test/java/com/aspose/barcode/guide/complex/introduction/ComplexBarcodeIntroduction.java" target="_blank">View ComplexBarcodeIntroduction.java</a> |
| 18 | + |
| 19 | +## Regular and complex barcode generation |
| 20 | + |
| 21 | +A regular `BarcodeGenerator` receives the final payload directly: |
| 22 | + |
| 23 | +```java |
| 24 | +BarcodeGenerator generator = new BarcodeGenerator( |
| 25 | + EncodeTypes.QR, |
| 26 | + constructedCodetext |
| 27 | +); |
| 28 | +``` |
| 29 | + |
| 30 | +A `ComplexBarcodeGenerator` receives an implementation of `IComplexCodetext`: |
| 31 | + |
| 32 | +```java |
| 33 | +SwissQRCodetext codetext = new SwissQRCodetext(); |
| 34 | + |
| 35 | +ComplexBarcodeGenerator generator = |
| 36 | + new ComplexBarcodeGenerator(codetext); |
| 37 | +``` |
| 38 | + |
| 39 | +The complex codetext object constructs the standard-specific payload and selects the appropriate carrier symbology. |
| 40 | + |
| 41 | +## Create typed business data |
| 42 | + |
| 43 | +The following example initializes a Swiss QR payment model: |
| 44 | + |
| 45 | +```java |
| 46 | +SwissQRCodetext codetext = new SwissQRCodetext(); |
| 47 | + |
| 48 | +codetext.getBill().setVersion(QrBillStandardVersion.V2_0); |
| 49 | +codetext.getBill().setAccount("CH4431999123000889012"); |
| 50 | +codetext.getBill().setAmount(100.25); |
| 51 | +codetext.getBill().setCurrency("CHF"); |
| 52 | +``` |
| 53 | + |
| 54 | +The model exposes payment fields such as account, amount, currency, creditor, debtor, reference, and message. |
| 55 | + |
| 56 | +## Supported complex barcode models |
| 57 | + |
| 58 | +Aspose.BarCode for Java provides typed classes for Swiss QR, HIBC LIC, HIBC PAS, Royal Mail Mailmark, MaxiCode, and USA Driver ID. |
| 59 | + |
| 60 | +The supported classes include: |
| 61 | + |
| 62 | +- `SwissQRCodetext`; |
| 63 | +- `HIBCLICCombinedCodetext`; |
| 64 | +- `HIBCPASCodetext`; |
| 65 | +- `MailmarkCodetext`; |
| 66 | +- `Mailmark2DCodetext`; |
| 67 | +- `MaxiCodeCodetextMode2`; |
| 68 | +- `MaxiCodeCodetextMode3`; |
| 69 | +- `USADriveIdCodetext`. |
| 70 | + |
| 71 | +## Understand the carrier symbology |
| 72 | + |
| 73 | +A complex barcode still uses a regular physical barcode type. For example: |
| 74 | + |
| 75 | +- Swiss QR uses QR Code; |
| 76 | +- Mailmark 2D uses Data Matrix; |
| 77 | +- USA Driver ID uses PDF417; |
| 78 | +- MaxiCode business data uses MaxiCode. |
| 79 | + |
| 80 | +The carrier is recognized first. Its text is then passed to a complex codetext decoder. |
| 81 | + |
| 82 | +## Complete processing workflow |
| 83 | + |
| 84 | +```java |
| 85 | +ComplexBarcodeGenerator generator = |
| 86 | + new ComplexBarcodeGenerator(sourceCodetext); |
| 87 | + |
| 88 | +generator.save(outputPath, BarCodeImageFormat.PNG); |
| 89 | + |
| 90 | +BarCodeReader reader = |
| 91 | + new BarCodeReader(outputPath, DecodeType.QR); |
| 92 | + |
| 93 | +BarCodeResult[] results = reader.readBarCodes(); |
| 94 | + |
| 95 | +SwissQRCodetext decodedCodetext = |
| 96 | + ComplexCodetextReader.tryDecodeSwissQR( |
| 97 | + results[0].getCodeText() |
| 98 | + ); |
| 99 | +``` |
| 100 | + |
| 101 | +The workflow consists of creating a typed model, generating the carrier image, recognizing the carrier, and decoding its standardized text into a typed object. |
| 102 | + |
| 103 | +## Recommendations |
| 104 | + |
| 105 | +- Populate all required business fields before generation. |
| 106 | +- Recognize the underlying carrier before complex decoding. |
| 107 | +- Use the decoder that matches the expected complex standard. |
| 108 | +- Validate decoded fields instead of checking only the raw text. |
| 109 | +- Apply a valid license before generation and recognition tests. |
0 commit comments