xtrareports-404607-feature-guide-to-devexpress-reports-use-report-controls-use-bar-codes-epc-qr-code.md
An EPC QR Code (European Payments Council Quick Response Code) is a two-dimensional barcode used to initiate a SEPA credit transfer (SCT). The following guideline contains general information about this type of barcode and defines the data format for EPC QR Codes: Quick Response Code - Guidelines to Enable the Data Capture for the Initiation of a SEPA Credit Transfer.
Drag the XRBarCode item from the DX.25.2: Report Controls tab and drop it onto the report.
Set the XRBarCode control’s Symbology property to QRCodeEPC (an object of the QRCodeEPCGenerator type).
Specify common barcode properties and properties specific to EPC QR Codes.
AutoModuleGets or sets whether the Module property value should be calculated automatically based on the barcode size.VersionGets or sets the barcode’s version.IncludeQuietZoneGets or sets whether to add a blank space around the QR code.LogoSpecifies the image that overlays the QR code.FrameOptionsGets or sets the frame for QR codes.
EPC QR Codes require data in a specific format. For more information, refer to the following European Payments Council guideline: Quick Response Code - Guidelines to Enable the Data Capture for the Initiation of a SEPA Credit Transfer.
You can specify the barcode data in the following ways:
The Text property.
Pass the data string to Text property. Each data element should be on a new line. Double-click the control to specify the content (editors in the Property grid do not support multi-line text):
In the image above, the following data elements are specified:
| Data Element | Value |
|---|---|
| Service Tag: | BCD |
| Version: | 001 |
| Encoding: | 1 |
| Identification: | SCT |
| BIC: | BPOTBEB1 |
| Beneficiary Name: | Red Cross of Belgium |
| IBAN: | BE72000000001616 |
| Transfer Amount: | EUR1 |
| Transfer Reason: | CHAR |
| Creditor Reference: | Empty line |
| Remittance Information: | Urgency fund |
| Information: | Empty line |
This field is bindable. For more information on data binding, review the following help topic: Bind Report Controls to Data Using Expression Bindings.
The ConvertDataToEPC function.
Use the ConvertDataToEPC function from the Expression Editor to bind to the Text property.
You can specify the data as shown below:
ConvertDataToEPC('Red Cross of Belgium', 'BE72000000001616', 'BPOTBEB1','20.0', '', 'Urgency fund', 'CHAR', 'Sample EPC QR code')
You can not change the default values for Version and Encoding with this function. The default value for the Version data element is 002 and UTF-8 for the Encoding.
The Text property.
Pass the data string to Text property. Data elements should be separated by carriage return or line feed characters.
// ...
XRBarCode barCode = new XRBarCode();
barCode.Symbology = new QRCodeEPCGenerator();
barCode.Text = "BCD\r\n001\r\n1\r\nSCT\r\nBPOTBEB1\r\nRed Cross of Belgium\r\nBE72000000001616\r\nEUR1\r\nCHAR\r\n\r\nUrgency fund\r\nSample EPC QR code";
// ...
' ...
Dim barCode As New XRBarCode()
barCode.Symbology = New QRCodeEPCGenerator()
barCode.Text = "BCD\r\n001\r\n1\r\nSCT\r\nBPOTBEB1\r\nRed Cross of Belgium\r\nBE72000000001616\r\nEUR1\r\nCHAR\r\n\r\nUrgency fund\r\nSample EPC QR code"
' ...
The BinaryData property.Pass the binary data to BinaryData property.The EPCDataConverter class.
Create an instance of the EPCDataConverter class to convert separate data elements to a format required for EPC QR Codes.
The following code snippets transforms the data elements into a formatted string and passes it to the barcode’s Text property:
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraPrinting.BarCode.EPC;
using DevExpress.XtraReports.UI;
//...
XRBarCode barCode = new XRBarCode();
barCode.Symbology = new QRCodeEPCGenerator();
//...
var epcData = new EPCDataConverter() {
Version = EPCVersion.Version1;
BIC = "BPOTBEB1",
BeneficiaryName = "Red Cross of Belgium",
IBAN = "BE72000000001616",
TransferAmount = 20,
TransferPurpose = "CHAR",
RemittanceInformation = "Urgency Fund",
Information = "Sample EPC QR code"
};
barCode.Text = epcData.StringData;
// ...
Imports DevExpress.XtraPrinting.BarCode
Imports DevExpress.XtraPrinting.BarCode.EPC
Imports DevExpress.XtraReports.UI
'...
Private barCode As New XRBarCode()
barCode.Symbology = New QRCodeEPCGenerator()
'...
Dim epcData = New EPCDataConverter() With {
.Version = EPCVersion.Version1,
.BIC = "BPOTBEB1",
.BeneficiaryName = "Red Cross of Belgium",
.IBAN = "BE72000000001616",
.TransferAmount = 20,
.TransferPurpose = "CHAR",
.RemittanceInformation = "Urgency Fund",
.Information = "Sample EPC QR code"
}
barCode.Text = epcData.StringData
'...
You can also pass the barcode data to the barcode’s BinaryData property. Do this use the BinaryData property of the EPCDataConverter class instance:
//...
barCode.BinaryData = epcData.BinaryData;
'...
barCode.BinaryData = epcData.BinaryData
'...
You can also apply a frame with the words “Zahlen mit Code” (to the right from the bottom to the top) to an EPC QR Code. The frame is used to highlight the function of the codes and to secure the identification. For more information, refer to the following Payment Services Austria (PSA) document: Application of QR-Code for initiating of credit transfers.
This frame already contains predefined settings according to the standard. To set this frame at design time, go to Behavior → Symbology → FrameOptions, and select PaymentServicesAustriaQRFrameOptions.
To set this frame in code, assign a new instance of PaymentServicesAustriaQRFrameOptions to the QRCodeGenerator.FrameOptions property.
((QRCodeGenerator)barCode.Symbology).FrameOptions = new PaymentServicesAustriaQRFrameOptions();
CType(barCode.Symbology, QRCodeGenerator).FrameOptions = New PaymentServicesAustriaQRFrameOptions()
The following code creates an EPC QR Code barcode and specifies its properties:
View Example: How to Add a Bar Code to a Report
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraPrinting.BarCode.EPC;
using DevExpress.XtraReports.UI;
// ...
public XRBarCode CreateQRCodeEPCBarCode() {
// Create a barcode control.
XRBarCode barCode = new XRBarCode();
// Set the barcode's type to QRCode.
barCode.Symbology = new QRCodeEPCGenerator();
// Adjust the barcode's main properties.
barCode.Width = 400;
barCode.Height = 400;
var epcData = new EPCDataConverter() {
BIC = "BPOTBEB1",
BeneficiaryName = "Red Cross of Belgium",
IBAN = "BE72000000001616",
TransferAmount = 20,
RemittanceInformation = "Urgency Fund"
};
barCode.Text = epcData.StringData;
return barCode;
}
Imports System
Imports System.Collections.Generic
Imports System.Drawing.Printing
Imports System.Windows.Forms
Imports DevExpress.XtraPrinting.BarCode
Imports DevExpress.XtraPrinting.BarCode.EPC
Imports DevExpress.XtraReports.UI
' ...
Public Function CreateQRCodeEPCBarCode() As XRBarCode
' Create a barcode control.
Dim barCode As New XRBarCode()
' Set the barcode's type to QRCode.
barCode.Symbology = New QRCodeEPCGenerator()
' Adjust the barcode's main properties.
barCode.Width = 400
barCode.Height = 400
Dim epcData = New EPCDataConverter() With {
.BIC = "BPOTBEB1",
.BeneficiaryName = "Red Cross of Belgium",
.IBAN = "BE72000000001616",
.TransferAmount = 1,
.RemittanceInformation = "Urgency Fund"
}
barCode.Text = epcData.StringData
Return barCode
End Function
The code example below shows how to create a report with an EPC QR Code barcode:
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
//...
var barCode = CreateQRCodeEPCBarCode();
var report = new XtraReport() {
Bands = {
new DetailBand() {
Controls = { barCode }
}
}
};
Imports DevExpress.XtraPrinting.BarCode
Imports DevExpress.XtraReports.UI
'...
Private barCode = CreateQRCodeEPCBarCode()
Dim report As New XtraReport()
Dim band = New DetailBand()
band.Controls.Add(barCode)