How To Print EPC Barcodes Using C#

What is the EPC format?

EPC barcodes are quite popular in Europe as they make it easy to transfer money between bank accounts using the bank's apps on smartphones. It completely avoids typing errors, making it both easy and reliable to use. EPC QR-Codes are standardized by the European Payment Council and are also known as "GiroCode". Basically, they consist of a standard QR code with a special content string, usually encoded in UTF-8. A brief introduction can be found here. The full specification is available form here

Building the Content

The content string just contains a number of lines separated by a carriage return character (`\r`). Here's an overview of the data elements in tabular form:

Data Element Content
1 Service Tag 'BCD'
2 '002' (for version 2, the current one)
3 Character Set - '1' for UTF-8
4 'SCT' for SEPA Credit Transfer
5 BIC of the recipient's bank (optional for EEA member states)
6 Name of recipient
7 IBAN of recipient
8 Amount in Euro
9 Purpose (optional)
10 Remittance information (optional)
11 Recipient to originator information (optional)

Note that many of the elements are optional. A simple transfer string might look like this:

string barcodeContent = 
/* Service tag */
"BCD\r"+
/* Version */
"002\r"+
/* Character set */
"1\r"+
/* SEPA Credit Transfer */
"SCT\r"
/* Recipient's BIC */
"GENODE61RAD\r"+
/* Recipient's name */
"combit\r"+
/* Recipient's IBAN */
"DE36692910000214809206\r"+
/* Amount */
"EUR0.01\r"+
/* Purpose, optional */
"CHAR\r"+
/* Reference, optional */
"\r"+
/* Remittance information */
"Charity for combit\r"+
/* Hint */
""; 

Printing an EPC Barcode with C#

To actually get the barcode on paper, you can use any library that is capable of printing EPC codes. If you just need the code itself, you can try the free and open sourced QRCoder. If the EPC code is just a part of an invoice and you're looking for a way to print the whole invoice, you might be better of using a reporting tool, as this is what these tools excel at. I recently wrote an article on How To Find The Best .NET Reporting Tool For Your Needs. One of the tools listed also has a specialized component for EPC-Barcodes. However, to just get started you'll be fine with a free QR code renderer.

For QRCoder, using the content from above this would read

QRCodeGenerator qrGenerator = new QRCodeGenerator();
// ECC level needs to be "M" per specification
QRCodeData qrCodeData = qrGenerator.CreateQrCode(barcodeContent, QRCodeGenerator.ECCLevel.M);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);

And what does the result look like

EPC barcode printed with List & Label

This code can then be printed on invoices, making it both easy and hassle free to pay for the recipients.


Similar Articles