![]() | QR-Code Contact Information |
This sample generates a contact information QR-Code barcode and saves it to an image file.
using Opait.Barcoder.Api; using Opait.Barcoder.QRCode; // This sample creates a QR-Code encoded contact information barcode. Only few fields are used here. // Many more fields, including addresses and multiple phone numbers, can be added. static void CreateContactInfo(string fileName, string firstName, string lastName, string company, string email, string cellNumber) { // Initialize the barcoder library with default options. var barcoder = new Barcoder(); // Create a contact info payload with specified fields. var contact = new ContactInfo(ContactFormat.VCard30, firstName, lastName) { Organization = company, Email = email, MobilePhone = cellNumber }; // Create a QR-Code encoder and pass the formatted text from the contact info. var encoder = barcoder.CreateEncoder(BarcodeType.QRCode, contact.ToString()); // Create a bitmap renderer for saving the generated barcode. var renderer = barcoder.CreateBitmapRenderer(); // Render the barcode to a bitmap of 400x400 pixels. using (var bitmap = renderer.RenderBarcode(encoder, 400, 400)) { // Save the rendered image. bitmap.Save(fileName); } }